From 7b903854a379683d11489fc8e5cea281dddb69eb Mon Sep 17 00:00:00 2001 From: Pragmatic Software Date: Fri, 17 Nov 2017 21:37:54 -0800 Subject: [PATCH] Remove secretstuff; use $stuff context instead --- PBot/Factoids.pm | 5 ++++- PBot/Interpreter.pm | 6 +----- PBot/PBot.pm | 3 --- 3 files changed, 5 insertions(+), 9 deletions(-) diff --git a/PBot/Factoids.pm b/PBot/Factoids.pm index 5e51321e..4a66c839 100644 --- a/PBot/Factoids.pm +++ b/PBot/Factoids.pm @@ -971,12 +971,15 @@ sub handle_action { return $action; } elsif ($action =~ s/^\/kick\s+//) { if (not exists $self->{factoids}->hash->{$channel}->{$keyword}->{'effective-level'}) { + $stuff->{authorized} = 0; return "/say $stuff->{nick}: $keyword doesn't have the effective-level to do that."; } my $level = 10; if ($self->{factoids}->hash->{$channel}->{$keyword}->{'effective-level'} >= $level) { - return "/$self->{pbot}->{secretstuff}kick " . $action; + $stuff->{authorized} = 1; + return "/kick " . $action; } else { + $stuff->{authorized} = 0; return "/say $stuff->{nick}: My effective-level isn't high enough to do that."; } } else { diff --git a/PBot/Interpreter.pm b/PBot/Interpreter.pm index adac7ea8..ed39f042 100644 --- a/PBot/Interpreter.pm +++ b/PBot/Interpreter.pm @@ -471,15 +471,12 @@ sub output_result { return if not defined $line or not length $line; if ($line =~ s/^\/say\s+//i) { - $line =~ s/\Q$self->{pbot}->{secretstuff}\E//g; $pbot->{conn}->privmsg($stuff->{from}, $line) if defined $stuff->{from} && $stuff->{from} !~ /\Q$botnick\E/i; $pbot->{antiflood}->check_flood($stuff->{from}, $botnick, $pbot->{registry}->get_value('irc', 'username'), 'localhost', $line, 0, 0, 0) if $stuff->{checkflood}; } elsif ($line =~ s/^\/me\s+//i) { - $line =~ s/\Q$self->{pbot}->{secretstuff}\E//g; $pbot->{conn}->me($stuff->{from}, $line) if defined $stuff->{from} && $stuff->{from} !~ /\Q$botnick\E/i; $pbot->{antiflood}->check_flood($stuff->{from}, $botnick, $pbot->{registry}->get_value('irc', 'username'), 'localhost', '/me ' . $line, 0, 0, 0) if $stuff->{checkflood}; } elsif ($line =~ s/^\/msg\s+([^\s]+)\s+//i) { - $line =~ s/\Q$self->{pbot}->{secretstuff}\E//g; my $to = $1; if ($to =~ /,/) { $pbot->{logger}->log("[HACK] Possible HACK ATTEMPT /msg multiple users: [$stuff->{nick}!$stuff->{user}\@$stuff->{host}] [$stuff->{command}] [$line]\n"); @@ -493,7 +490,7 @@ sub output_result { $pbot->{conn}->privmsg($to, $line) if $to !~ /\Q$botnick\E/i; $pbot->{antiflood}->check_flood($to, $botnick, $pbot->{registry}->get_value('irc', 'username'), 'localhost', $line, 0, 0, 0) if $stuff->{checkflood}; } - } elsif ($line =~ s/^\/$self->{pbot}->{secretstuff}kick\s+//) { + } elsif ($stuff->{authorized} && $line =~ s/^\/kick\s+//) { $pbot->{antiflood}->check_flood($stuff->{from}, $botnick, $pbot->{registry}->get_value('irc', 'username'), 'localhost', '/kick ' . $line, 0, 0, 0) if $stuff->{checkflood}; my ($victim, $reason) = split /\s+/, $line, 2; @@ -515,7 +512,6 @@ sub output_result { $pbot->{conn}->privmsg($stuff->{from}, "$victim: $reason") if defined $stuff->{from} && $stuff->{from} !~ /\Q$botnick\E/i; } } else { - $line =~ s/\Q$self->{pbot}->{secretstuff}\E//g; $pbot->{conn}->privmsg($stuff->{from}, $line) if defined $stuff->{from} && $stuff->{from} !~ /\Q$botnick\E/i; $pbot->{antiflood}->check_flood($stuff->{from}, $botnick, $pbot->{registry}->get_value('irc', 'username'), 'localhost', $line, 0, 0, 0) if $stuff->{checkflood}; } diff --git a/PBot/PBot.pm b/PBot/PBot.pm index 5dc9f3f8..1a9d988b 100644 --- a/PBot/PBot.pm +++ b/PBot/PBot.pm @@ -146,9 +146,6 @@ sub initialize { $self->{registry}->load; } - my @chars = ("A".."Z", "a".."z", "0".."9"); - $self->{secretstuff} .= $chars[rand @chars] for 1..64; - # create implicit bot-admin account for bot my $botnick = $self->{registry}->get_value('irc', 'botnick'); $self->{admins}->add_admin($botnick, '.*', "$botnick!stdin\@localhost", 90, 'admin', 1);