mirror of
https://github.com/pragma-/pbot.git
synced 2024-12-23 19:22:40 +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
|
# from unncessarily highlighting people
|
||||||
$output = $self->dehighlight_nicks($output, $to) unless $output =~ m|^/msg |;
|
$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
|
# handle various /command prefixes
|
||||||
|
|
||||||
my $type = 'echo'; # will be set to 'echo' or 'action' depending on /command prefix
|
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') {
|
if ($type eq 'echo') {
|
||||||
# prepend nickprefix to output
|
# prepend nickprefix to output
|
||||||
if ($context->{nickprefix} && (! $context->{nickprefix_disabled} || $context->{nickprefix_forced})) {
|
if ($context->{nickprefix} && (! $context->{nickprefix_disabled} || $context->{nickprefix_forced})) {
|
||||||
@ -930,17 +931,25 @@ sub output_result {
|
|||||||
$output = "$context->{nick}: $output";
|
$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
|
# send the message to the channel/user
|
||||||
$self->{pbot}->{conn}->privmsg($to, $output);
|
$self->{pbot}->{conn}->privmsg($to, $output);
|
||||||
}
|
}
|
||||||
elsif ($type eq 'action') {
|
elsif ($type eq 'action') {
|
||||||
# append nickprefix to output
|
# truncate if necessary, pasting original result to a web paste site
|
||||||
#
|
$output = $self->truncate_result($context, $output, $context->{original_result});
|
||||||
# TODO: probably going to remove this code.
|
|
||||||
#
|
# add bot's output to message history for recall/grab
|
||||||
# if ($context->{nickprefix} && (! $context->{nickprefix_disabled} || $context->{nickprefix_forced})) {
|
if ($to =~ /^#/) {
|
||||||
# $output = "$output (for $context->{nickprefix})";
|
$self->{pbot}->{messagehistory}->add_message($bot_account, $bot_hostmask, $to, "/me $output", MSG_CHAT);
|
||||||
# }
|
}
|
||||||
|
|
||||||
# CTCP ACTION the message to the channel/user
|
# CTCP ACTION the message to the channel/user
|
||||||
$self->{pbot}->{conn}->me($to, $output);
|
$self->{pbot}->{conn}->me($to, $output);
|
||||||
|
@ -25,8 +25,8 @@ use PBot::Imports;
|
|||||||
# These are set by the /misc/update_version script
|
# These are set by the /misc/update_version script
|
||||||
use constant {
|
use constant {
|
||||||
BUILD_NAME => "PBot",
|
BUILD_NAME => "PBot",
|
||||||
BUILD_REVISION => 4369,
|
BUILD_REVISION => 4370,
|
||||||
BUILD_DATE => "2021-08-25",
|
BUILD_DATE => "2021-08-26",
|
||||||
};
|
};
|
||||||
|
|
||||||
sub initialize {}
|
sub initialize {}
|
||||||
|
Loading…
Reference in New Issue
Block a user