Commit Diff


commit - c8955f309a194e89ac95e693e0803dfb4d2c009e
commit + b15a3128cdaa0f3f1a2013f45cb8dd71560b7cd4
blob - cf0e088ca4e13e263abd86615d38a43500cfc497
blob + 626898f6ee96c6a5dfc9735b2a7495c8ca967914
--- lib/IRCNOW/Acct/Mail.pm
+++ lib/IRCNOW/Acct/Mail.pm
@@ -1,4 +1,4 @@
-package BotNow::Mail;
+package IRCNOW::Acct::Mail;
 
 use strict;
 use warnings;
@@ -30,8 +30,6 @@ my $virtualspath = "/etc/mail/virtuals";
 my $senderspath = "/etc/mail/users";
 my @users;
 
-IRCNOW::IO::IRC::cbind("msg", "-", "mail", \&mmail);
-
 sub init {
 	#dependencies for encrypt
 	unveil("/usr/bin/encrypt", "rx") or die "Unable to unveil $!";
@@ -47,156 +45,6 @@ sub init {
 	unveil("/bin/sh", "rx") or die "Unable to unveil $!";
 }
 
-sub mmail {
-	my ($bot, $nick, $host, $hand, @args) = @_;
-	my ($chan, $text);
-	if (@args == 2) {
-		($chan, $text) = ($args[0], $args[1]);
-	} else { $text = $args[0]; }
-	my $hostmask = "$nick!$host";
-	if (defined($chan) && $chans =~ /$chan/) {
-		IRCNOW::IO::IRC::putserv($bot, "PRIVMSG $chan :$nick: Please check private message");
-	}
-	if ($text =~ /^$/) {
-		IRCNOW::IO::IRC::putserv($bot, "PRIVMSG $nick :Type !help for new instructions");
-		foreach my $chan (@teamchans) {
-			IRCNOW::IO::IRC::putservlocalnet($bot, "PRIVMSG $chan :$staff: Help *$nick* on network ".$bot->{name}." with mail");
-		}
-		return;
-	} elsif (IRCNOW::IO::IRC::isstaff($bot, $nick) && $text =~ /^delete\s+([[:ascii:]]+)/) {
-		my $username = $1;
-		if (BotNow::SQLite::deleterows("mail", "username", $username)) {
-			deletemail($username);
-			foreach my $chan (@teamchans) {
-				IRCNOW::IO::IRC::putserv($bot, "PRIVMSG $chan :$username email deleted");
-			}
-		}
-		return;
-	} elsif (IRCNOW::IO::IRC::isstaff($bot, $nick) && $text =~ /^approve\s+([[:ascii:]]+)/) {
-		my $username = $1;
-		my @passwd = readarray($passwdpath);
-		foreach my $line (@passwd) {
-			$line =~ s/^#(${username}\@${mailhostname}.*)/$1/;
-		}
-		# trailing newline necessary
-		`doas touch $passwdpath.bak`;
-		`doas chmod g+w $passwdpath.bak`;
-		writefile("$passwdpath.bak", join("\n", @passwd)."\n");
-		copy "${passwdpath}.bak", $passwdpath;
-
-		foreach my $chan (@teamchans) {
-			IRCNOW::IO::IRC::putserv($bot, "PRIVMSG $chan :$username mail approved");
-		}
-		return;
-	}
-	### Check duplicate hostmasks ###
-	my @rows = BotNow::SQLite::selectrows("irc", "hostmask", $hostmask);
-	foreach my $row (@rows) {
-		my $password = BotNow::SQLite::get("mail", "ircid", $row->{id}, "password");
-		if (defined($password)) {
-			IRCNOW::IO::IRC::putserv($bot, "PRIVMSG $nick :Sorry, only one account per person. Please contact staff if you need help.");
-			return;
-		}
-	}
-
-	if ($text =~ /^captcha\s+([[:alnum:]]+)/) {
-		my $text = $1;
-		# TODO avoid using host mask because cloaking can cause problems
-		my $ircid = BotNow::SQLite::id("irc", "nick", $nick, $expires);
-		my $captcha = BotNow::SQLite::get("mail", "ircid", $ircid, "captcha");
-		if ($text ne $captcha) {
-			IRCNOW::IO::IRC::putserv($bot, "PRIVMSG $nick :Wrong captcha. To get a new captcha, type !mail <username> <email>");
-			return;
-		}
-		my $pass = BotNot::Hash::newpass();
-		chomp(my $encrypted = `encrypt $pass`);
-		my $username = BotNow::SQLite::get("mail", "ircid", $ircid, "username");
-		my $email = BotNow::SQLite::get("mail", "ircid", $ircid, "email");
-		my $hashirc = BotNow::SQLite::get("irc", "id", $ircid, "hashid");
-		BotNow::SQLite::set("mail", "ircid", $ircid, "password", $encrypted);
-		sleep(2);
-		createmail($pass, $username);
-		IRCNOW::IO::IRC::putserv($bot, "PRIVMSG $nick :Check your email!");
-		sleep(5);
-		mailmail($username, $pass, $email);
-		if ($approval) {
-			my @passwd = readarray($passwdpath);
-			foreach my $line (@passwd) {
-				$line =~ s/^(${username}\@${mailhostname}.*)/#$1/;
-			}
-			# trailing newline necessary
-			`doas touch $passwdpath.bak`;
-			`doas chmod g+w $passwdpath.bak`;
-			writefile("$passwdpath.bak", join("\n", @passwd)."\n");
-			copy "${passwdpath}.bak", $passwdpath;
-
-			IRCNOW::IO::IRC::putserv($bot, "PRIVMSG $nick :Your account has been created but must be manually approved by your admins ($staff) before it can be used.");
-			foreach my $chan (@teamchans) {
-				IRCNOW::IO::IRC::putservlocalnet($bot, "PRIVMSG $chan :$staff: $nick\'s account $username must be manually unblocked before it can be used.");
-			}
-		}
-		foreach my $chan (@teamchans) {
-			IRCNOW::IO::IRC::putservlocalnet($bot, "PRIVMSG $chan :$staff: $nick\'s mail registration of $username\@$mailhostname on $bot->{name} was successful, but you *must* help him to connect. Most users are unable to connect. Show him https://wiki.ircnow.org/?n=Email.Email");
-		}
-		#www($newnick, $reply, $password, "bouncer");
-		return;
-	} elsif ($text =~ /^([[:alnum:]]+)\s+([[:ascii:]]+)/) {
-		my ($username, $email) = ($1, $2);
-		my @userrows = BotNow::SQLite::selectrows("mail", "username", $username);
-		foreach my $row (@userrows) {
-			my $password = BotNow::SQLite::get("mail", "ircid", $row->{id}, "password");
-			if (defined($password)) {
-				IRCNOW::IO::IRC::putserv($bot, "PRIVMSG $nick :Sorry, only one account per person. Please contact staff if you need help.");
-				return;
-			}
-		}
-		my @emailrows = BotNow::SQLite::selectrows("mail", "email", $email);
-		foreach my $row (@userrows) {
-			my $password = BotNow::SQLite::get("mail", "ircid", $row->{id}, "password");
-			if (defined($password)) {
-				IRCNOW::IO::IRC::putserv($bot, "PRIVMSG $nick :Sorry, only one account per person. Please contact staff if you need help.");
-				return;
-			}
-		}
-
-#		my @users = treeget($znctree, "User", "Node");
-		foreach my $user (@users) {
-			if ($user eq $username) {
-				IRCNOW::IO::IRC::putserv($bot, "PRIVMSG $nick :Sorry, username taken. Please contact staff if you need help.");
-				return;
-			}
-		}
-
-		#my $captcha = join'', map +(0..9,'a'..'z','A'..'Z')[rand(10+26*2)], 1..4;
-		my $captcha = int(rand(999));
-		my $ircid = int(rand(9223372036854775807));
-		my $hashid = sha256_hex("$ircid");
-		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", IRCNOW::IO::data());
-		BotNow::SQLite::set("irc", "id", $ircid, "hostmask", $hostmask);
-		BotNow::SQLite::set("irc", "id", $ircid, "nick", $nick);
-		BotNow::SQLite::set("mail", "ircid", $ircid, "username", $username);
-		BotNow::SQLite::set("mail", "ircid", $ircid, "email", $email);
-		BotNow::SQLite::set("mail", "ircid", $ircid, "captcha", $captcha);
-		BotNow::SQLite::set("mail", "ircid", $ircid, "hashid", $hashid);
-		IRCNOW::IO::IRC::whois($bot->{sock}, $nick);
-		IRCNOW::IO::IRC::ctcp($bot->{sock}, $nick);
-		IRCNOW::IO::IRC::putserv($bot, "PRIVMSG $nick :".`figlet $captcha`);
-#IRCNOW::IO::IRC::putserv($bot, "PRIVMSG $nick :https://$hostname/$hashid/captcha.png");
-#IRCNOW::IO::IRC::putserv($bot, "PRIVMSG $nick :https://$hostname/register.php?hashirc=$hashid");
-		IRCNOW::IO::IRC::putserv($bot, "PRIVMSG $nick :Type !mail captcha <text>");
-		foreach my $chan (@teamchans) {
-			IRCNOW::IO::IRC::putservlocalnet($bot, "PRIVMSG $chan :$nick\'s on $bot->{name} mail captcha is $captcha");
-		}
-	} else {
-		IRCNOW::IO::IRC::putserv($bot, "PRIVMSG $nick :Invalid username or email. Type !mail <username> <email> to try again.");
-		foreach my $chan (@teamchans) {
-			IRCNOW::IO::IRC::putservlocalnet($bot, "PRIVMSG $chan :$staff: Help *$nick* on network ".$bot->{name}." with mail");
-		}
-	}
-}
-
 sub mailmail {
 	my( $username, $password, $email )=@_;
 	my $approvemsg;
blob - 74f111b30cdf483d670c95dd133b06cb00ccc4c1
blob + 3731567f8533095c364649ed060001567c963693
--- lib/IRCNOW/Acct/VPN.pm
+++ lib/IRCNOW/Acct/VPN.pm
@@ -1,4 +1,4 @@
-package BotNow::VPN;
+package IRCNOW::Acct::VPN;
 
 use strict;
 use warnings;