mirror of
https://github.com/pragma-/pbot.git
synced 2024-12-25 04:02:37 +01:00
Improve handling of /say, etc, in output text
This commit is contained in:
parent
45421aaf30
commit
1378e41c1b
@ -166,6 +166,8 @@ sub execute_module {
|
|||||||
$stuff->{result} = `./$module $stuff->{arguments} 2>> $module-stderr`;
|
$stuff->{result} = `./$module $stuff->{arguments} 2>> $module-stderr`;
|
||||||
chomp $stuff->{result};
|
chomp $stuff->{result};
|
||||||
|
|
||||||
|
$stuff->{result} = "/say $stuff->{result}";
|
||||||
|
|
||||||
my $json = encode_json $stuff;
|
my $json = encode_json $stuff;
|
||||||
print $writer "$json\n";
|
print $writer "$json\n";
|
||||||
exit 0;
|
exit 0;
|
||||||
|
@ -275,8 +275,6 @@ sub interpret {
|
|||||||
|
|
||||||
$self->{pbot}->{logger}->log("piping: [$args][$pipe][$rest]\n");
|
$self->{pbot}->{logger}->log("piping: [$args][$pipe][$rest]\n");
|
||||||
|
|
||||||
$stuff->{prepend} = '/say ' unless exists $self->{pipe};
|
|
||||||
|
|
||||||
$arguments = $args;
|
$arguments = $args;
|
||||||
|
|
||||||
if (exists $stuff->{pipe}) {
|
if (exists $stuff->{pipe}) {
|
||||||
@ -377,6 +375,12 @@ sub handle_result {
|
|||||||
return 0;
|
return 0;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
if ($result =~ s#^(/say|/me) ##) {
|
||||||
|
$stuff->{prepend} = $1;
|
||||||
|
} elsif ($result =~ s#^(/msg \S+) ##) {
|
||||||
|
$stuff->{prepend} = $1;
|
||||||
|
}
|
||||||
|
|
||||||
if (exists $stuff->{subcmd}) {
|
if (exists $stuff->{subcmd}) {
|
||||||
my $command = pop @{$stuff->{subcmd}};
|
my $command = pop @{$stuff->{subcmd}};
|
||||||
|
|
||||||
@ -389,28 +393,15 @@ sub handle_result {
|
|||||||
$stuff->{command} = $command;
|
$stuff->{command} = $command;
|
||||||
$result = $self->interpret($stuff);
|
$result = $self->interpret($stuff);
|
||||||
$stuff->{result}= $result;
|
$stuff->{result}= $result;
|
||||||
|
$self->{pbot}->{logger}->log("subcmd result [$result]\n");
|
||||||
$self->handle_result($stuff);
|
$self->handle_result($stuff);
|
||||||
return 0;
|
return 0;
|
||||||
}
|
}
|
||||||
|
|
||||||
if ($stuff->{pipe} and not $stuff->{authorized}) {
|
if ($stuff->{pipe} and not $stuff->{authorized}) {
|
||||||
my ($pipe, $pipe_rest) = ($stuff->{pipe}, $stuff->{pipe_rest});
|
my ($pipe, $pipe_rest) = (delete $stuff->{pipe}, delete $stuff->{pipe_rest});
|
||||||
|
|
||||||
delete $stuff->{pipe};
|
|
||||||
delete $stuff->{pipe_rest};
|
|
||||||
|
|
||||||
$self->{pbot}->{logger}->log("Handling pipe [$result][$pipe][$pipe_rest]\n");
|
$self->{pbot}->{logger}->log("Handling pipe [$result][$pipe][$pipe_rest]\n");
|
||||||
|
|
||||||
if ($result =~ s{^(/say |/me )}{}i) {
|
|
||||||
$stuff->{prepend} = $1;
|
|
||||||
}
|
|
||||||
=cut
|
|
||||||
elsif ($result =~ s{^/msg ([^ ]+) }{}i) {
|
|
||||||
$stuff->{prepend} = "/msg $1 ";
|
|
||||||
}
|
|
||||||
=cut
|
|
||||||
$stuff->{command} = "$pipe $result$pipe_rest";
|
$stuff->{command} = "$pipe $result$pipe_rest";
|
||||||
|
|
||||||
$result = $self->interpret($stuff);
|
$result = $self->interpret($stuff);
|
||||||
$stuff->{result} = $result;
|
$stuff->{result} = $result;
|
||||||
$self->handle_result($stuff, $result);
|
$self->handle_result($stuff, $result);
|
||||||
@ -418,15 +409,9 @@ sub handle_result {
|
|||||||
}
|
}
|
||||||
|
|
||||||
if ($stuff->{prepend}) {
|
if ($stuff->{prepend}) {
|
||||||
# FIXME: do this better
|
$result = "$stuff->{prepend} $result";
|
||||||
if ($result =~ m{^(/say |/me )}i) {
|
|
||||||
# } elsif ($result =~ m{^/msg ([^ ]+) }i) {
|
|
||||||
} elsif ($result =~ m{^/kick }i) {
|
|
||||||
} else {
|
|
||||||
$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;
|
||||||
|
|
||||||
|
Loading…
Reference in New Issue
Block a user