mirror of
https://github.com/pragma-/pbot.git
synced 2025-01-09 11:32:34 +01:00
Add functionality to grab multiple nicks in one quotegrab
This commit is contained in:
parent
e3ade2cb09
commit
2cb74ecf95
@ -161,12 +161,17 @@ sub grab_quotegrab {
|
||||
}
|
||||
|
||||
if(not defined $arguments or not length $arguments) {
|
||||
return "Usage: grab <nick> [history [channel]] -- where [history] is an optional argument that is either an integer number of recent messages or a regex (without whitespace) of the text within the message; e.g., to grab the 3rd most recent message for nick, use `grab nick 3` or to grab a message containing 'pizza', use `grab nick pizza`; and [channel] is an optional channel, so you can use it from /msg (you will need to also specify [history] in this case)";
|
||||
return "Usage: grab <nick> [history [channel]] -- where [history] is an optional argument that is either an integral number of recent messages or a regex (without whitespace) of the text within the message; e.g., to grab the 3rd most recent message for nick, use `grab nick 3` or to grab a message containing 'pizza', use `grab nick pizza`; and [channel] is an optional channel, so you can use it from /msg (you will need to also specify [history] in this case)";
|
||||
}
|
||||
|
||||
$arguments = lc $arguments;
|
||||
|
||||
my ($grab_nick, $grab_history, $channel) = split(/\s+/, $arguments, 3);
|
||||
my @grabs = split /\s\+\s/, $arguments;
|
||||
|
||||
my ($grab_nick, $grab_history, $channel, $grab_nicks, $grab_text);
|
||||
|
||||
foreach my $grab (@grabs) {
|
||||
($grab_nick, $grab_history, $channel) = split(/\s+/, $grab, 3);
|
||||
|
||||
if(not defined $grab_history) {
|
||||
$grab_history = $nick eq $grab_nick ? 2 : 1;
|
||||
@ -237,12 +242,31 @@ sub grab_quotegrab {
|
||||
|
||||
$self->{pbot}->logger->log("$nick ($from) grabbed <$grab_nick/$channel> $messages[$grab_history]->{msg}\n");
|
||||
|
||||
if(not defined $grab_nicks) {
|
||||
$grab_nicks = $grab_nick;
|
||||
} else {
|
||||
$grab_nicks .= "+$grab_nick";
|
||||
}
|
||||
|
||||
my $text = $messages[$grab_history]->{msg};
|
||||
|
||||
if(not defined $grab_text) {
|
||||
$grab_text = $text;
|
||||
} else {
|
||||
if($text =~ s/^\/me\s+//) {
|
||||
$grab_text .= " * $grab_nick $text";
|
||||
} else {
|
||||
$grab_text .= " <$grab_nick> $text";
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
my $quotegrab = {};
|
||||
$quotegrab->{nick} = $grab_nick;
|
||||
$quotegrab->{nick} = $grab_nicks;
|
||||
$quotegrab->{channel} = $channel;
|
||||
$quotegrab->{timestamp} = $messages[$grab_history]->{timestamp};
|
||||
$quotegrab->{grabbed_by} = $nick;
|
||||
$quotegrab->{text} = $messages[$grab_history]->{msg};
|
||||
$quotegrab->{timestamp} = gettimeofday;
|
||||
$quotegrab->{grabbed_by} = "$nick!$user\@$host";
|
||||
$quotegrab->{text} = $grab_text;
|
||||
$quotegrab->{id} = $#{ $self->{quotegrabs} } + 2;
|
||||
|
||||
push @{ $self->{quotegrabs} }, $quotegrab;
|
||||
@ -250,6 +274,7 @@ sub grab_quotegrab {
|
||||
$self->save_quotegrabs();
|
||||
|
||||
my $text = $quotegrab->{text};
|
||||
($grab_nick) = split /\+/, $grab_nicks, 2;
|
||||
|
||||
if($text =~ s/^\/me\s+//) {
|
||||
return "Quote grabbed: " . ($#{ $self->{quotegrabs} } + 1) . ": * $grab_nick $text";
|
||||
|
@ -13,8 +13,8 @@ use warnings;
|
||||
# These are set automatically by the build/commit script
|
||||
use constant {
|
||||
BUILD_NAME => "PBot",
|
||||
BUILD_REVISION => 433,
|
||||
BUILD_DATE => "2013-09-16",
|
||||
BUILD_REVISION => 434,
|
||||
BUILD_DATE => "2013-10-03",
|
||||
};
|
||||
|
||||
1;
|
||||
|
Loading…
Reference in New Issue
Block a user