Allow bot admins to factset factoids from /msg

Fix some channel/from discrepancies in factset, etc.
This commit is contained in:
Pragmatic Software 2015-09-03 20:43:16 -07:00
parent b6f7dd87e5
commit 97bbb298e4
2 changed files with 6 additions and 14 deletions

View File

@ -145,17 +145,8 @@ sub find_admin {
my $result = eval { my $result = eval {
foreach my $channel_regex (keys %{ $self->{admins}->hash }) { foreach my $channel_regex (keys %{ $self->{admins}->hash }) {
if($from !~ m/^#/) { if($from !~ m/^#/) {
# if not from a channel, make sure that nick portion of hostmask matches $from
foreach my $hostmask_regex (keys %{ $self->{admins}->hash->{$channel_regex} }) { foreach my $hostmask_regex (keys %{ $self->{admins}->hash->{$channel_regex} }) {
my $nick; return $self->{admins}->hash->{$channel_regex}->{$hostmask_regex} if $hostmask =~ m/$hostmask_regex/i;
if($hostmask_regex =~ m/^([^!]+)!.*/) {
$nick = $1;
} else {
$nick = $hostmask_regex;
}
return $self->{admins}->hash->{$channel_regex}->{$hostmask_regex} if($from =~ m/$nick/i and $hostmask =~ m/$hostmask_regex/i);
} }
} elsif($from =~ m/^$channel_regex$/i) { } elsif($from =~ m/^$channel_regex$/i) {
foreach my $hostmask_regex (keys %{ $self->{admins}->hash->{$channel_regex} }) { foreach my $hostmask_regex (keys %{ $self->{admins}->hash->{$channel_regex} }) {

View File

@ -117,7 +117,7 @@ sub factset {
if (defined $owner_channel) { if (defined $owner_channel) {
$admininfo = $self->{pbot}->{admins}->loggedin($owner_channel, "$nick!$user\@$host"); $admininfo = $self->{pbot}->{admins}->loggedin($owner_channel, "$nick!$user\@$host");
} else { } else {
$admininfo = $self->{pbot}->{admins}->loggedin($from, "$nick!$user\@$host"); $admininfo = $self->{pbot}->{admins}->loggedin($channel, "$nick!$user\@$host");
} }
my $level = 0; my $level = 0;
@ -172,7 +172,7 @@ sub factunset {
if (defined $owner_channel) { if (defined $owner_channel) {
$admininfo = $self->{pbot}->{admins}->loggedin($owner_channel, "$nick!$user\@$host"); $admininfo = $self->{pbot}->{admins}->loggedin($owner_channel, "$nick!$user\@$host");
} else { } else {
$admininfo = $self->{pbot}->{admins}->loggedin($from, "$nick!$user\@$host"); $admininfo = $self->{pbot}->{admins}->loggedin($channel, "$nick!$user\@$host");
} }
my $level = 0; my $level = 0;
@ -955,13 +955,14 @@ sub factchange {
return "Usage: factchange <channel> <keyword> s/<pattern>/<replacement>/"; return "Usage: factchange <channel> <keyword> s/<pattern>/<replacement>/";
} }
my $chan = $channel;
($channel, $trigger) = $self->{pbot}->{factoids}->find_factoid($channel, $keyword, undef, 1, 1); ($channel, $trigger) = $self->{pbot}->{factoids}->find_factoid($channel, $keyword, undef, 1, 1);
if(not defined $trigger) { if(not defined $trigger) {
return "$keyword not found in channel $from."; return "$keyword not found in channel $chan.";
} }
if(not $self->{pbot}->{admins}->loggedin($from, "$nick!$user\@$host") and $factoids->{$channel}->{$trigger}->{'locked'}) { if(not $self->{pbot}->{admins}->loggedin($channel, "$nick!$user\@$host") and $factoids->{$channel}->{$trigger}->{'locked'}) {
return "$trigger is locked and cannot be changed."; return "$trigger is locked and cannot be changed.";
} }