mirror of
https://github.com/pragma-/pbot.git
synced 2024-12-25 04:02:37 +01:00
Improvements to piping and stuff
This commit is contained in:
parent
73e61b72a7
commit
656adae53c
@ -222,7 +222,7 @@ sub interpret {
|
|||||||
return undef;
|
return undef;
|
||||||
}
|
}
|
||||||
|
|
||||||
if ($stuff->{command} =~ /^tell\s+(\p{PosixGraph}{1,20})\s+about\s+(.*?)\s+(.*)$/i) {
|
if ($stuff->{command} =~ /^tell\s+(\p{PosixGraph}{1,20})\s+about\s+(.*?)\s+(.*)$/is) {
|
||||||
($keyword, $arguments, $stuff->{nickoverride}) = ($2, $3, $1);
|
($keyword, $arguments, $stuff->{nickoverride}) = ($2, $3, $1);
|
||||||
my $similar = $self->{pbot}->{nicklist}->is_present_similar($stuff->{from}, $stuff->{nickoverride});
|
my $similar = $self->{pbot}->{nicklist}->is_present_similar($stuff->{from}, $stuff->{nickoverride});
|
||||||
if ($similar) {
|
if ($similar) {
|
||||||
@ -230,7 +230,7 @@ sub interpret {
|
|||||||
} else {
|
} else {
|
||||||
$stuff->{nickoverride} = undef;
|
$stuff->{nickoverride} = undef;
|
||||||
}
|
}
|
||||||
} elsif ($stuff->{command} =~ /^tell\s+(\p{PosixGraph}{1,20})\s+about\s+(.*)$/i) {
|
} elsif ($stuff->{command} =~ /^tell\s+(\p{PosixGraph}{1,20})\s+about\s+(.*)$/is) {
|
||||||
($keyword, $stuff->{nickoverride}) = ($2, $1);
|
($keyword, $stuff->{nickoverride}) = ($2, $1);
|
||||||
my $similar = $self->{pbot}->{nicklist}->is_present_similar($stuff->{from}, $stuff->{nickoverride});
|
my $similar = $self->{pbot}->{nicklist}->is_present_similar($stuff->{from}, $stuff->{nickoverride});
|
||||||
if ($similar) {
|
if ($similar) {
|
||||||
@ -238,7 +238,7 @@ sub interpret {
|
|||||||
} else {
|
} else {
|
||||||
$stuff->{nickoverride} = undef;
|
$stuff->{nickoverride} = undef;
|
||||||
}
|
}
|
||||||
} elsif ($stuff->{command} =~ /^(.*?)\s+(.*)$/) {
|
} elsif ($stuff->{command} =~ /^(.*?)\s+(.*)$/s) {
|
||||||
($keyword, $arguments) = ($1, $2);
|
($keyword, $arguments) = ($1, $2);
|
||||||
} else {
|
} else {
|
||||||
$keyword = $stuff->{command};
|
$keyword = $stuff->{command};
|
||||||
@ -249,9 +249,21 @@ sub interpret {
|
|||||||
$self->{pbot}->{logger}->log("Truncating keyword to 30 chars: $keyword\n");
|
$self->{pbot}->{logger}->log("Truncating keyword to 30 chars: $keyword\n");
|
||||||
}
|
}
|
||||||
|
|
||||||
|
if (defined $arguments && $arguments =~ m/\|\s*\{\s*[^}]+\}\s*$/) {
|
||||||
|
$arguments =~ m/(.*?)\s*\|\s*\{\s*([^}]+)\}(.*)/;
|
||||||
|
my ($args, $pipe, $rest) = ($1, $2, $3);
|
||||||
|
$pipe =~ s/\s+$//;
|
||||||
|
|
||||||
|
$self->{pbot}->{logger}->log("piping: [$args][$pipe][$rest]\n");
|
||||||
|
|
||||||
|
$stuff->{arguments} = $args;
|
||||||
|
$stuff->{pipe} = $pipe;
|
||||||
|
$stuff->{pipe_rest} = $rest;
|
||||||
|
}
|
||||||
|
|
||||||
$stuff->{nickoverride} = $stuff->{nick} if defined $stuff->{nickoverride} and $stuff->{nickoverride} eq 'me';
|
$stuff->{nickoverride} = $stuff->{nick} if defined $stuff->{nickoverride} and $stuff->{nickoverride} eq 'me';
|
||||||
|
|
||||||
if ($keyword !~ /^(?:factrem|forget|set|factdel|factadd|add|factfind|find|factshow|show|forget|factdel|factset|factchange|change|msg|tell|cc|eval|u|udict|ud|actiontrigger|urban|perl)$/) {
|
if ((not exists $stuff->{pipe}) and $keyword !~ /^(?:factrem|forget|set|factdel|factadd|add|factfind|find|factshow|show|forget|factdel|factset|factchange|change|msg|tell|cc|eval|u|udict|ud|actiontrigger|urban|perl)$/) {
|
||||||
$keyword =~ s/(\w+)([?!.]+)$/$1/;
|
$keyword =~ s/(\w+)([?!.]+)$/$1/;
|
||||||
$arguments =~ s/(?<![\w\/\-\\])me\b/$stuff->{nick}/gi if defined $arguments && $stuff->{interpret_depth} <= 2;
|
$arguments =~ s/(?<![\w\/\-\\])me\b/$stuff->{nick}/gi if defined $arguments && $stuff->{interpret_depth} <= 2;
|
||||||
$arguments =~ s/(?<![\w\/\-\\])my\b/$stuff->{nick}'s/gi if defined $arguments && $stuff->{interpret_depth} <= 2;
|
$arguments =~ s/(?<![\w\/\-\\])my\b/$stuff->{nick}'s/gi if defined $arguments && $stuff->{interpret_depth} <= 2;
|
||||||
@ -282,21 +294,8 @@ sub interpret {
|
|||||||
if (not exists $stuff->{root_keyword}) {
|
if (not exists $stuff->{root_keyword}) {
|
||||||
$stuff->{root_keyword} = $keyword;
|
$stuff->{root_keyword} = $keyword;
|
||||||
}
|
}
|
||||||
$stuff->{arguments} = $arguments;
|
|
||||||
|
|
||||||
my $result;
|
$stuff->{arguments} = $arguments unless exists $stuff->{pipe};
|
||||||
|
|
||||||
if (defined $arguments && $arguments =~ m/\|\s*\{\s*[^}]+\}/) {
|
|
||||||
$arguments =~ m/(.*?)\s*\|\s*\{\s*([^}]+)\}(.*)/;
|
|
||||||
my ($args, $pipe, $rest) = ($1, $2, $3);
|
|
||||||
$pipe =~ s/\s+$//;
|
|
||||||
|
|
||||||
$self->{pbot}->{logger}->log("piping: [$args][$pipe][$rest]\n");
|
|
||||||
|
|
||||||
$stuff->{arguments} = $args;
|
|
||||||
$stuff->{pipe} = $pipe;
|
|
||||||
$stuff->{pipe_rest} = $rest;
|
|
||||||
}
|
|
||||||
|
|
||||||
return $self->SUPER::execute_all($stuff);
|
return $self->SUPER::execute_all($stuff);
|
||||||
}
|
}
|
||||||
@ -372,15 +371,13 @@ sub handle_result {
|
|||||||
|
|
||||||
if ($stuff->{prepend}) {
|
if ($stuff->{prepend}) {
|
||||||
# FIXME: do this better
|
# FIXME: do this better
|
||||||
if ($result =~ s{^(/say |/me )}{}i) {
|
if ($result =~ m{^(/say |/me )}i) {
|
||||||
#$stuff->{prepend} = $1;
|
} elsif ($result =~ m{^/msg ([^ ]+) }i) {
|
||||||
} elsif ($result =~ s{^/msg ([^ ]+) }{}i) {
|
} else {
|
||||||
#$stuff->{prepend} = "/msg $1 ";
|
|
||||||
}
|
|
||||||
|
|
||||||
$result = "$stuff->{prepend}$result";
|
$result = "$stuff->{prepend}$result";
|
||||||
$self->{pbot}->{logger}->log("Prepending [$stuff->{prepend}] to result [$result]\n");
|
$self->{pbot}->{logger}->log("Prepending [$stuff->{prepend}] to result [$result]\n");
|
||||||
}
|
}
|
||||||
|
}
|
||||||
|
|
||||||
my $original_result = $result;
|
my $original_result = $result;
|
||||||
|
|
||||||
@ -474,12 +471,15 @@ sub output_result {
|
|||||||
return if not defined $line or not length $line;
|
return if not defined $line or not length $line;
|
||||||
|
|
||||||
if ($line =~ s/^\/say\s+//i) {
|
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->{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};
|
$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) {
|
} 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->{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};
|
$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) {
|
} elsif ($line =~ s/^\/msg\s+([^\s]+)\s+//i) {
|
||||||
|
$line =~ s/\Q$self->{pbot}->{secretstuff}\E//g;
|
||||||
my $to = $1;
|
my $to = $1;
|
||||||
if ($to =~ /,/) {
|
if ($to =~ /,/) {
|
||||||
$pbot->{logger}->log("[HACK] Possible HACK ATTEMPT /msg multiple users: [$stuff->{nick}!$stuff->{user}\@$stuff->{host}] [$stuff->{command}] [$line]\n");
|
$pbot->{logger}->log("[HACK] Possible HACK ATTEMPT /msg multiple users: [$stuff->{nick}!$stuff->{user}\@$stuff->{host}] [$stuff->{command}] [$line]\n");
|
||||||
@ -515,6 +515,7 @@ sub output_result {
|
|||||||
$pbot->{conn}->privmsg($stuff->{from}, "$victim: $reason") if defined $stuff->{from} && $stuff->{from} !~ /\Q$botnick\E/i;
|
$pbot->{conn}->privmsg($stuff->{from}, "$victim: $reason") if defined $stuff->{from} && $stuff->{from} !~ /\Q$botnick\E/i;
|
||||||
}
|
}
|
||||||
} else {
|
} 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->{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};
|
$pbot->{antiflood}->check_flood($stuff->{from}, $botnick, $pbot->{registry}->get_value('irc', 'username'), 'localhost', $line, 0, 0, 0) if $stuff->{checkflood};
|
||||||
}
|
}
|
||||||
|
Loading…
Reference in New Issue
Block a user