Commit Diff


commit - 87c2ee73df928072c3224eb2354eb94a7ab43df0
commit + d90e80ee5920e18974506fdf16e99e201fe69e3d
blob - 5e870074f6348904c5c7517ef11295838eae3ca9
blob + f5aed27e5c0f2bf763f3cc7f049ceeb90c357bdb
--- BNC.pm
+++ BNC.pm
@@ -193,7 +193,7 @@ sub mbnc {
 	} elsif ($text =~ /^([[:alnum:]]+)\s+([[:ascii:]]+)/) {
 		my ($username, $email) = ($1, $2);
 		#XXX Check if this user is staff - hotfix for bug
-		if (main::isstaff($bot, $username)) {
+		if (bncExists($bot,$username)) {
 			main::putserv($bot, "PRIVMSG $nick :Sorry, that account already exists");
 			return;
 		}
@@ -393,6 +393,21 @@ EOF
 	}
 }
 
+sub bncExists {
+	my ($bot, $username) = @_;
+	return 1 if (main::isstaff($bot, $username));
+	if (!defined($SQLite::dbh)) { SQLite::connectdb() || die "Can't open database"; }
+	my $dbh = $SQLite::dbh;
+	my $exists = $dbh->selectrow_array(
+		"SELECT count(*) FROM BNC WHERE username = ? and password is not null", 
+		undef,$username
+	); #count will be only element in array
+	return $exists; #should be 0 if it doesnt exist
+	#XXX Need to add signaling to query znc directly.
+}
+
+
+
 sub createbnc {
 	my ($bot, $username, $password, $bindhost) = @_;
 	my $netname = $bot->{name};
blob - 463e5263fa5b53ebabf0ad940cbae3e69e534db4
blob + d8b0b0755f76825aca551674bab33efb485613a1
--- SQLite.pm
+++ SQLite.pm
@@ -18,7 +18,7 @@ use constant {
 };
 my %conf = %main::conf;
 my $staff = $conf{staff};
-my $dbh;
+our $dbh;
 my $verbose = $conf{verbose};
 my $dbpath = "/var/www/botnow/botnow.db";
 my $database = "/var/www/botnow/"; # database path