3
0
mirror of https://github.com/pragma-/pbot.git synced 2024-11-19 10:29:30 +01:00

Support + in recall command to recall multiple messages, similiar to grab

This commit is contained in:
Pragmatic Software 2013-10-27 07:34:00 +00:00
parent 97261637f1
commit a9adbcf498
2 changed files with 90 additions and 68 deletions

View File

@ -53,7 +53,7 @@ sub initialize {
$pbot->commands->register(sub { $self->delete_quotegrab(@_) }, "delq", 0);
$pbot->commands->register(sub { $self->show_random_quotegrab(@_) }, "rq", 0);
# ought to be in MessageTracker.pm (when it's created)
# ought to be in MessageTracker.pm once we create that module
$pbot->commands->register(sub { $self->recall_message(@_) }, "recall", 0);
}
@ -475,7 +475,12 @@ sub recall_message {
$arguments = lc $arguments;
my ($recall_nick, $recall_history, $channel) = split(/\s+/, $arguments, 3);
my @recalls = split /\s\+\s/, $arguments;
my ($recall_nick, $recall_history, $channel, $recall_nicks, $recall_text);
foreach my $recall (@recalls) {
($recall_nick, $recall_history, $channel) = split(/\s+/, $recall, 3);
if(not defined $recall_history) {
$recall_history = $nick eq $recall_nick ? 2 : 1;
@ -546,14 +551,31 @@ sub recall_message {
$self->{pbot}->logger->log("$nick ($from) recalled <$recall_nick/$channel> $messages[$recall_history]->{msg}\n");
if(not defined $recall_nicks) {
$recall_nicks = $recall_nick;
} else {
$recall_nicks .= "+$recall_nick";
}
my $text = $messages[$recall_history]->{msg};
my $ago = ago(gettimeofday - $messages[$recall_history]->{timestamp});
if(not defined $recall_text) {
if($text =~ s/^\/me\s+//) {
return "$ago: * $recall_nick $text";
$recall_text = "[$ago] * $recall_nick $text";
} else {
return "$ago: <$recall_nick> $text";
$recall_text = "[$ago] <$recall_nick> $text";
}
} else {
if($text =~ s/^\/me\s+//) {
$recall_text .= " [$ago] * $recall_nick $text";
} else {
$recall_text .= " [$ago] <$recall_nick> $text";
}
}
}
return $recall_text;
}
1;

View File

@ -13,8 +13,8 @@ use warnings;
# These are set automatically by the build/commit script
use constant {
BUILD_NAME => "PBot",
BUILD_REVISION => 460,
BUILD_DATE => "2013-10-26",
BUILD_REVISION => 461,
BUILD_DATE => "2013-10-27",
};
1;