mirror of
https://github.com/pragma-/pbot.git
synced 2024-11-20 02:49:49 +01:00
Interpreter: log bot output in message history
Bot output now appears in `recall` and can be `grab`bed. Moved truncate_result() a bit further down to truncate after target nick is prefixed to output.
This commit is contained in:
parent
e9a8620fb0
commit
731d795c03
@ -879,9 +879,6 @@ sub output_result {
|
||||
# from unncessarily highlighting people
|
||||
$output = $self->dehighlight_nicks($output, $to) unless $output =~ m|^/msg |;
|
||||
|
||||
# truncate if necessary, pasting original result to a web paste site
|
||||
$output = $self->truncate_result($context, $output, $context->{original_result});
|
||||
|
||||
# handle various /command prefixes
|
||||
|
||||
my $type = 'echo'; # will be set to 'echo' or 'action' depending on /command prefix
|
||||
@ -921,6 +918,10 @@ sub output_result {
|
||||
}
|
||||
}
|
||||
|
||||
my $bot_nick = $self->{pbot}->{registry}->get_value('irc', 'botnick');
|
||||
my $bot_hostmask = "$bot_nick!pbot3\@pbot";
|
||||
my $bot_account = $self->{pbot}->{messagehistory}->get_message_account($bot_nick, 'pbot3', 'pbot');
|
||||
|
||||
if ($type eq 'echo') {
|
||||
# prepend nickprefix to output
|
||||
if ($context->{nickprefix} && (! $context->{nickprefix_disabled} || $context->{nickprefix_forced})) {
|
||||
@ -930,17 +931,25 @@ sub output_result {
|
||||
$output = "$context->{nick}: $output";
|
||||
}
|
||||
|
||||
# truncate if necessary, pasting original result to a web paste site
|
||||
$output = $self->truncate_result($context, $output, $context->{original_result});
|
||||
|
||||
# add bot's output to message history for recall/grab
|
||||
if ($to =~ /^#/) {
|
||||
$self->{pbot}->{messagehistory}->add_message($bot_account, $bot_hostmask, $to, $output, MSG_CHAT);
|
||||
}
|
||||
|
||||
# send the message to the channel/user
|
||||
$self->{pbot}->{conn}->privmsg($to, $output);
|
||||
}
|
||||
elsif ($type eq 'action') {
|
||||
# append nickprefix to output
|
||||
#
|
||||
# TODO: probably going to remove this code.
|
||||
#
|
||||
# if ($context->{nickprefix} && (! $context->{nickprefix_disabled} || $context->{nickprefix_forced})) {
|
||||
# $output = "$output (for $context->{nickprefix})";
|
||||
# }
|
||||
# truncate if necessary, pasting original result to a web paste site
|
||||
$output = $self->truncate_result($context, $output, $context->{original_result});
|
||||
|
||||
# add bot's output to message history for recall/grab
|
||||
if ($to =~ /^#/) {
|
||||
$self->{pbot}->{messagehistory}->add_message($bot_account, $bot_hostmask, $to, "/me $output", MSG_CHAT);
|
||||
}
|
||||
|
||||
# CTCP ACTION the message to the channel/user
|
||||
$self->{pbot}->{conn}->me($to, $output);
|
||||
|
@ -25,8 +25,8 @@ use PBot::Imports;
|
||||
# These are set by the /misc/update_version script
|
||||
use constant {
|
||||
BUILD_NAME => "PBot",
|
||||
BUILD_REVISION => 4369,
|
||||
BUILD_DATE => "2021-08-25",
|
||||
BUILD_REVISION => 4370,
|
||||
BUILD_DATE => "2021-08-26",
|
||||
};
|
||||
|
||||
sub initialize {}
|
||||
|
Loading…
Reference in New Issue
Block a user