[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

[PATCH] Grys patch for captcha via email


Please ignore previous patch, it included some local changes.

This one has been applied to a clean clone of botnow repo.

Regards,

Ian

---
 BNC.pm | 58 +++++++++++++++++++++++++++++++++++++++-------------------
 1 file changed, 39 insertions(+), 19 deletions(-)

diff --git a/BNC.pm b/BNC.pm
index 0d92083..e096b90 100644
--- a/BNC.pm
+++ b/BNC.pm
@@ -123,7 +123,11 @@ sub mbnc {
 	} 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");
+			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");
 			}
@@ -165,8 +169,8 @@ 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);
+			main::putserv($bot, "PRIVMSG $nick :Wait, we will approve your bouncer account soon.");
+			mailbncPending($username, $email);
 			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.");
@@ -226,10 +230,11 @@ sub mbnc {
 		SQLite::set("bnc", "ircid", $ircid, "hashid", $hashid);
 		main::whois($bot->{sock}, $nick);
 		main::ctcp($bot->{sock}, $nick);
-		main::putserv($bot, "PRIVMSG $nick :".`figlet $captcha`);
+		mailbnc($username, $email, $captcha);
+		# main::putserv($bot, "PRIVMSG $nick :".`figlet $captcha`);
 #main::putserv($bot, "PRIVMSG $nick :https://$hostname/$hashid/captcha.png";);
 #main::putserv($bot, "PRIVMSG $nick :https://$hostname/register.php?hashirc=$hashid";);
-		main::putserv($bot, "PRIVMSG $nick :Type !bnc captcha <text>");
+		main::putserv($bot, "PRIVMSG $nick :Check your email and Type !bnc captcha <text>");
 		foreach my $chan (@teamchans) {
 			main::putservlocalnet($bot, "PRIVMSG $chan :$nick\'s on $bot->{name} bnc captcha is $captcha");
 		}
@@ -408,23 +413,29 @@ EOF
 	return 1;
 }
 sub mailbnc {
-	my( $username, $email, $password, $service, $hashirc )=@_;
+	my( $username, $email, $captcha )=@_;
 	my $passhash = sha256_hex("$username");
 	my $approvemsg;
-	if ($approval eq "true") {
-		$approvemsg = <<"EOF";
 
-*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.
+my $body = <<"EOF";
+Welcome to $bot->{name}!
+
+Please message this number on IRC:
+
+!bnc captcha $captcha
 
+$bot->{name}
 EOF
-	}
+	main::mail($mailfrom, $email, $mailname, "Verify $bot->{name} Account $username", $body);
+}
+
+sub mailbncApproved {
+        my( $username, $email, $password)=@_;
 
 my $body = <<"EOF";
-Welcome to IRCNow!
+Welcome to $bot->{name}!
 
-You created a bouncer:
+We created a bouncer:
 
 Username: $username
 Password: $password
@@ -432,15 +443,24 @@ 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.
+$bot->{name}
+EOF
+        main::mail($mailfrom, $email, $mailname, "Welcome to $bot->{name} Bouncer, $username", $body);
+}
+
+sub mailbncPending {
+        my( $username, $email)=@_;
+
+my $body = <<"EOF";
+$bot->{name} bouncer $username account verified. Thank you.
+
+Please wait for account approval. It may take up to 48 hours.
+Then we will send you login instructions.
 
-IRCNow
+$bot->{name}
 EOF
-	main::mail($mailfrom, $email, $mailname, "Verify IRCNow Account", $body);
+        main::mail($mailfrom, $email, $mailname, "$bot->{name} Bouncer $username account verified", $body);
 }
 
 sub mtaillog {
-- 
2.37.3


Follow-Ups:
Re: [PATCH] Grys patch for captcha via emailjrmu <jrmu@xxxxxxxxxx>