3
0
mirror of https://github.com/pragma-/pbot.git synced 2024-10-01 17:16:39 +02:00

BotAdmins: admin hostmasks are no longer treated as regex. They support the normal * and ? wildcards. Removed stdin admin from data/admins.

This commit is contained in:
Pragmatic Software 2020-01-03 21:39:22 -08:00
parent 97dd3ea56e
commit 3188b690e8
3 changed files with 5 additions and 17 deletions

View File

@ -120,13 +120,11 @@ sub find_admin {
foreach my $channel_regex (keys %{ $self->{admins}->hash }) {
if ($from !~ m/^#/ or $from =~ m/^$channel_regex$/i) {
foreach my $hostmask_regex (keys %{ $self->{admins}->hash->{$channel_regex} }) {
if ($hostmask_regex =~ m/\.\*/) {
# contains .* so it's considered a regex
return $self->{admins}->hash->{$channel_regex}->{$hostmask_regex} if $hostmask =~ m/^$hostmask_regex$/i;
} elsif ($hostmask_regex =~ m/\*/) {
# contains * so it's converted to a regex
if ($hostmask_regex =~ m/[*?]/) {
# contains * or ? so it's converted to a regex
my $hostmask_quoted = quotemeta $hostmask_regex;
$hostmask_quoted =~ s/\\\*/.*/g;
$hostmask_quoted =~ s/\\\*/.*?/g;
$hostmask_quoted =~ s/\\\?/./g;
return $self->{admins}->hash->{$channel_regex}->{$hostmask_regex} if $hostmask =~ m/^$hostmask_quoted$/i;
} else {
# direct comparison

View File

@ -212,7 +212,7 @@ sub initialize {
# create implicit bot-admin account for bot
my $botnick = $self->{registry}->get_value('irc', 'botnick');
$self->{admins}->add_admin($botnick, '.*', ".*!stdin\@pbot", 100, 'notused', 1);
$self->{admins}->add_admin($botnick, '.*', "*!stdin\@pbot", 100, 'notused', 1);
$self->{admins}->login($botnick, "$botnick!stdin\@pbot", 'notused');
# start timer

View File

@ -1,10 +0,0 @@
{
".*" : {
"pbot3!stdin@localhost" : {
"password" : "admin",
"level" : "90",
"name" : "pbot3"
}
}
}