commit d9793b5f5fae9cccca8dbb43c7b8d5826d9bd624 from: jrmu via: Izzy Blacklock date: Sat Jul 15 22:01:03 2023 UTC Fixes handling of emails/approvals -- thanks to gry's suggested patch, with minor modifications commit - 94bf7a714ccd949f7c0f778f52c844bff1583d5c commit + d9793b5f5fae9cccca8dbb43c7b8d5826d9bd624 blob - 2f3d62b3e5db56da41b5658cc90e8ec6a7bfd7f8 blob + 5f130a3cd207410176173d63c6fd8cc575dff7dc --- lib/BotNow/BNC.pm +++ lib/BotNow/BNC.pm @@ -122,7 +122,11 @@ sub mbnc { } elsif (main::isstaff($bot, $nick) && $text =~ /^approve\s+([[:ascii:]]+)/) { my $username = $1; if (SQLite::selectrows("bnc", "username", $username)) { - main::putserv($bot, "PRIVMSG *blockuser :unblock $username"); + my $email = 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"); + mailbncApproved($username,$email,$password); foreach my $chan (@teamchans) { main::putserv($bot, "PRIVMSG $chan :$username bnc approved"); } @@ -164,14 +168,16 @@ sub mbnc { if (DNS::nextdns($username)) { sleep(2); createbnc($bot, $username, $pass, $bindhost); - main::putserv($bot, "PRIVMSG $nick :Check your email!"); - mailbnc($username, $email, $pass, "bouncer", $hashirc); if ($approval eq "true") { main::putserv($bot, "PRIVMSG *blockuser :block $username"); - main::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) { - main::putservlocalnet($bot, "PRIVMSG $chan :$staff: $nick\'s account $username must be manually unblocked before it can be used."); + main::putserv($bot, "PRIVMSG $nick :Your account has been created but must be approved by your admins ($staff) before it can be used. Please reply to the email and contact staff over IRC."); + mailbncPending($username, $email); + foreach my $chan (@teamchans) { + main::putservlocalnet($bot, "PRIVMSG $chan :$staff: To approve $nick, you must type !bnc approve $username"); } + } else { + main::putserv($bot, "PRIVMSG $nick :Check your email! Please reply to the email and contact staff over IRC."); + mailbncApproved($username,$email,$pass); } foreach my $chan (@teamchans) { main::putservlocalnet($bot, "PRIVMSG $chan :$staff: $nick\'s bnc registration of $username on $bot->{name} was successful, *but* you *must* help him connect. Most users are unable to connect. Show him https://wiki.ircnow.org/?n=Bouncer.Bouncer and give him connection instructions"); @@ -406,23 +412,11 @@ EOF main::putserv($bot, "PRIVMSG *controlpanel :$msg"); return 1; } -sub mailbnc { - my( $username, $email, $password, $service, $hashirc )=@_; - my $passhash = sha256_hex("$username"); - my $approvemsg; - if ($approval eq "true") { - $approvemsg = <<"EOF"; +sub mailbncApproved { + my( $username, $email, $password)=@_; + my $body = <<"EOF"; +Welcome to $conf{localnet}! -*IMPORTANT*: Your account has been created but it has not yet been -approved. To get your account approved, please contact your admins -$staff on IRC and by email. - -EOF - } - -my $body = <<"EOF"; -Welcome to IRCNow! - You created a bouncer: Username: $username @@ -431,19 +425,36 @@ Server: $bnchostname Port: $sslport for SSL (secure connection) Port: $plainport for plaintext Webpanel: $webpanel -$approvemsg -*IMPORTANT*: Verify your email address: -Please reply to this email to indicate you have received the email. You must -reply in order to keep your account. +Connection Instructions: https://wiki.ircnow.org/?n=Bouncer.Bouncer -IRCNow +Enjoy! + +$conf{localnet} +IRCNow Federation EOF - main::mail($mailfrom, $email, $mailname, "Verify IRCNow Account", $body); + main::mail($mailfrom, $email, $mailname, "Your $conf{localnet} Bouncer", $body); } +sub mailbncPending { + my( $username, $email)=@_; + my $body = <<"EOF"; +Welcome to $conf{localnet}! + +Your bouncer needs to be approved by staff ($staff). +Please reply to this email and contact them over IRC. + +Once $staff have been contacted, they will send you login +instructions. This may take up to 48 hours. + +$conf{localnet} +IRCNow Federation +EOF + main::mail($mailfrom, $email, $mailname, "Confirm $conf{localnet} Bouncer", $body); +} + sub mtaillog { - my ($bot, $nick, $host, $hand, @args) = @_; + my ($bot, $nick, $host, $hand, @args) = @_; my ($chan, $text); if (@args == 2) { ($chan, $text) = ($args[0], $args[1]);