summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorAvatar Anders Ossowicki <arkanoid@exherbo.org> 2010-01-20 18:49:00 +0100
committerAvatar Anders Ossowicki <arkanoid@exherbo.org> 2010-01-20 18:49:00 +0100
commitdd6058101fdf1285782c1ebd2c8e321b56686ddd (patch)
tree98a11c810774ac522bf9e9a4bf89d19ec5b4fa8b
parent63e0c10dacb943a3cd91c62933d208b957ef3fae (diff)
downloadhacchi-master.tar.gz
hacchi-master.tar.xz
support !pl foo in privmsgHEADmaster
-rwxr-xr-xhacchi.pl20
1 files changed, 12 insertions, 8 deletions
diff --git a/hacchi.pl b/hacchi.pl
index 60a4091..fd34343 100755
--- a/hacchi.pl
+++ b/hacchi.pl
@@ -165,14 +165,18 @@ sub irc_msg {
my ( $sender, $who, $where, $what ) = @_[ SENDER, ARG0 .. ARG2 ];
my $nick = ( split /!/, $who )[0];
- if ( $what =~ /^!?(patchlist|pl)$/ ) {
- if (@patches) {
- $irc->yield( privmsg => $nick => "Patch list:" );
- foreach my $patch (@patches) {
- send_patch( $patch, $nick );
- }
- } else {
- $irc->yield( privmsg => $nick => "0 patches in queue." );
+ if ( my ($match) = $what =~ /^!(?:patchlist|pl)(?:\s+(.+))?$/ ) {
+ my @p = @patches;
+ if ($match) {
+ @p = grep { ($_->{nick} =~ /\Q$match\E/ or $_->{url} =~ /\Q$match\E/ or $_->{summary} =~ /\Q$match\E/ ) } @p;
+ }
+ my $msg = @p . " ";
+ $msg .= "matching " if ($match);
+ $msg .= pluralise_patch(scalar @p) . " in queue";
+ $irc->yield( privmsg => $nick => $msg );
+
+ foreach my $patch (@p) {
+ send_patch( $patch, $nick );
}
}