Commit Diff


commit - f661491dcbc3a27b6950fe8a3c92bf9af1b7cd06
commit + 3ae69e2798977f4020618e9bc7a749cc9c03c1a5
blob - 32077711726398c8f207b06b9b7979cd19c1ef53
blob + 386a0ddd5276af6e1210ab87ac6efead4f89e952
--- botnow
+++ botnow
@@ -104,6 +104,9 @@ if (defined($conf{modules})) {
 use lib './lib';
 foreach my $mod (@modules) {
 	eval "require BotNow::$mod";	# Eval required for magic @INC search
+	if ($@) {
+		die "Failed to load $mod: $@";
+	}
 }
 foreach my $mod (@modules) {
 	my $init = "BotNow::${mod}::init";
blob - 0f4be858d5a3dc9e0eb36bf1440ce501909a747b
blob + 55a19e68ec7f0ca1a317cae696d50dc342aa5336
--- lib/BotNow/BNC.pm
+++ lib/BotNow/BNC.pm
@@ -7,10 +7,10 @@ use OpenBSD::Unveil;
 use Digest::SHA qw(sha256_hex);
 use lib qw(./lib);
 use IRCNOW::IO qw(:DEBUG readarray);
-require "BotNow::SQLite";
-require "BotNow::Hash";
-require "BotNow::DNS";
-require "BotNow::Mail";
+use BotNow::SQLite;
+use BotNow::Hash;
+use BotNow::DNS;
+use BotNow::Mail;
 
 my %conf = %main::conf;
 my $chans = $conf{chans};
@@ -93,7 +93,10 @@ sub mbnc {
 	my ($chan, $text);
 	if (@args == 2) {
 		($chan, $text) = ($args[0], $args[1]);
-	} else { $text = $args[0]; }
+	} else { 
+		$text = $args[0]; 
+	}
+	debug(ALL, "mbnc: !BNC Command: $text");
 	my $hostmask = "$nick!$host";
 	if (defined($chan) && $chans =~ /$chan/) {
 		main::putserv($bot, "PRIVMSG $chan :$nick: Please check private message");
@@ -106,7 +109,7 @@ sub mbnc {
 		return;
 	} elsif (main::isstaff($bot, $nick) && $text =~ /^delete\s+([[:ascii:]]+)/) {
 		my $username = $1;
-		if (SQLite::deleterows("bnc", "username", $username)) {
+		if (BotNow::SQLite::deleterows("bnc", "username", $username)) {
 			main::putserv($bot, "PRIVMSG *controlpanel :deluser $username");
 			foreach my $chan (@teamchans) {
 				main::putserv($bot, "PRIVMSG $chan :$username deleted");
@@ -115,8 +118,8 @@ sub mbnc {
 		return;
 	} elsif (main::isstaff($bot, $nick) && $text =~ /^approve\s+([[:ascii:]]+)/) {
 		my $username = $1;
-		if (SQLite::selectrows("bnc", "username", $username)) {
-			my $email = SQLite::get("bnc", "username", $username, "email");
+		if (BotNow::SQLite::selectrows("bnc", "username", $username)) {
+			my $email = BotNow::SQLite::get("bnc", "username", $username, "email");
 			my $password = Hash::newpass();
 			main::putserv($bot,"privmsg *controlpanel :set Password $username $password");
  			main::putserv($bot, "PRIVMSG *blockuser :unblock $username");
@@ -134,9 +137,9 @@ sub mbnc {
 		main::putserv($bot, "PRIVMSG *controlpanel :get Nick cloneuser");
 	}
 	### Check duplicate hostmasks ###
-	my @rows = SQLite::selectrows("irc", "hostmask", $hostmask);
+	my @rows = BotNow::SQLite::selectrows("irc", "hostmask", $hostmask);
 	foreach my $row (@rows) {
-		my $password = SQLite::get("bnc", "ircid", $row->{id}, "password");
+		my $password = BotNow::SQLite::get("bnc", "ircid", $row->{id}, "password");
 		if (defined($password)) {
 			main::putserv($bot, "PRIVMSG $nick :Sorry, only one account per person. Please contact staff if you need help.");
 			return;
@@ -146,19 +149,19 @@ sub mbnc {
 	if ($text =~ /^captcha\s+([[:alnum:]]+)/) {
 		my $text = $1;
 		# TODO avoid using host mask because cloaking can cause problems
-		my $ircid = SQLite::id("irc", "nick", $nick, $expires);
-		my $captcha = SQLite::get("bnc", "ircid", $ircid, "captcha");
+		my $ircid = BotNow::SQLite::id("irc", "nick", $nick, $expires);
+		my $captcha = BotNow::SQLite::get("bnc", "ircid", $ircid, "captcha");
 		if ($text ne $captcha) {
 			main::putserv($bot, "PRIVMSG $nick :Wrong captcha. To get a new captcha, type !bnc <username> <email>");
 			return;
 		}
 		my $pass = Hash::newpass();
 		chomp(my $encrypted = `encrypt $pass`);
-		my $username = SQLite::get("bnc", "ircid", $ircid, "username");
-		my $email = SQLite::get("bnc", "ircid", $ircid, "email");
-		my $hashirc = SQLite::get("irc", "id", $ircid, "hashid");
+		my $username = BotNow::SQLite::get("bnc", "ircid", $ircid, "username");
+		my $email = BotNow::SQLite::get("bnc", "ircid", $ircid, "email");
+		my $hashirc = BotNow::SQLite::get("irc", "id", $ircid, "hashid");
 		my $bindhost = "$username.$hostname";
-		SQLite::set("bnc", "ircid", $ircid, "password", $encrypted);
+		BotNow::SQLite::set("bnc", "ircid", $ircid, "password", $encrypted);
 		if (DNS::nextdns($username)) {
 			sleep(2);
 			createbnc($bot, $username, $pass, $bindhost);
@@ -185,17 +188,17 @@ sub mbnc {
 		return;
 	} elsif ($text =~ /^([[:alnum:]]+)\s+([[:ascii:]]+)/) {
 		my ($username, $email) = ($1, $2);
-		my @userrows = SQLite::selectrows("bnc", "username", $username);
+		my @userrows = BotNow::SQLite::selectrows("bnc", "username", $username);
 		foreach my $row (@userrows) {
-			my $password = SQLite::get("bnc", "ircid", $row->{id}, "password");
+			my $password = BotNow::SQLite::get("bnc", "ircid", $row->{id}, "password");
 			if (defined($password)) {
 				main::putserv($bot, "PRIVMSG $nick :Sorry, only one account per person. Please contact staff if you need help.");
 				return;
 			}
 		}
-		my @emailrows = SQLite::selectrows("bnc", "email", $email);
+		my @emailrows = BotNow::SQLite::selectrows("bnc", "email", $email);
 		foreach my $row (@userrows) {
-			my $password = SQLite::get("bnc", "ircid", $row->{id}, "password");
+			my $password = BotNow::SQLite::get("bnc", "ircid", $row->{id}, "password");
 			if (defined($password)) {
 				main::putserv($bot, "PRIVMSG $nick :Sorry, only one account per person. Please contact staff if you need help.");
 				return;
@@ -214,15 +217,15 @@ sub mbnc {
 		my $captcha = int(rand(999));
 		my $ircid = int(rand(9223372036854775807));
 		my $hashid = sha256_hex("$ircid");
-		SQLite::set("irc", "id", $ircid, "localtime", time());
-		SQLite::set("irc", "id", $ircid, "hashid", sha256_hex($ircid));
-		SQLite::set("irc", "id", $ircid, "date", main::date());
-		SQLite::set("irc", "id", $ircid, "hostmask", $hostmask);
-		SQLite::set("irc", "id", $ircid, "nick", $nick);
-		SQLite::set("bnc", "ircid", $ircid, "username", $username);
-		SQLite::set("bnc", "ircid", $ircid, "email", $email);
-		SQLite::set("bnc", "ircid", $ircid, "captcha", $captcha);
-		SQLite::set("bnc", "ircid", $ircid, "hashid", $hashid);
+		BotNow::SQLite::set("irc", "id", $ircid, "localtime", time());
+		BotNow::SQLite::set("irc", "id", $ircid, "hashid", sha256_hex($ircid));
+		BotNow::SQLite::set("irc", "id", $ircid, "date", main::date());
+		BotNow::SQLite::set("irc", "id", $ircid, "hostmask", $hostmask);
+		BotNow::SQLite::set("irc", "id", $ircid, "nick", $nick);
+		BotNow::SQLite::set("bnc", "ircid", $ircid, "username", $username);
+		BotNow::SQLite::set("bnc", "ircid", $ircid, "email", $email);
+		BotNow::SQLite::set("bnc", "ircid", $ircid, "captcha", $captcha);
+		BotNow::SQLite::set("bnc", "ircid", $ircid, "hashid", $hashid);
 		main::whois($bot->{sock}, $nick);
 		main::ctcp($bot->{sock}, $nick);
 		main::putserv($bot, "PRIVMSG $nick :".`figlet $captcha`);