From 55b8bd87c6f07d21de8b3037317b54c6a0374c86 Mon Sep 17 00:00:00 2001 From: Zoffix Znet Date: Sun, 3 Jan 2016 11:37:51 -0500 Subject: Add irc-to-me method --- lib/IRC/Client.pm6 | 30 ++++++++++++++++++------------ 1 file changed, 18 insertions(+), 12 deletions(-) (limited to 'lib/IRC/Client.pm6') diff --git a/lib/IRC/Client.pm6 b/lib/IRC/Client.pm6 index d003efb..bcc1c6e 100644 --- a/lib/IRC/Client.pm6 +++ b/lib/IRC/Client.pm6 @@ -77,6 +77,24 @@ method handle-event ($e) { return unless $res === IRC_NOT_HANDLED; } + my $nick = $!nick; + if ( ( $e eq 'PRIVMSG' and $e[0] eq $!nick ) + or ( $e eq 'NOTICE' and $e[0] eq $!nick ) + or ( $e eq 'PRIVMSG' + and $e[1] ~~ /:i ^ $nick <[,:]> \s+/ + ) + ) { + my $where = ($e, $e); + $where[0] = $e[0] + unless ( $e eq 'PRIVMSG' and $e[0] eq $!nick ) + or ( $e eq 'NOTICE' and $e[0] eq $!nick ); + + for @!plugs.grep(*.^can: 'irc-to-me') -> $p { + my $res = $p.irc-to-me(self, $e, |$where); + return unless $res === IRC_NOT_HANDLED; + } + } + if ( $e eq 'PRIVMSG' and $e[0] eq $!nick ) { for @!plugs.grep(*.^can: 'irc-privmsg-me') -> $p { my $res = $p.irc-privmsg-me(self, $e); @@ -91,18 +109,6 @@ method handle-event ($e) { } } - if ( ( $e eq 'PRIVMSG' and $e[0] eq $!nick ) - or ( $e eq 'NOTICE' and $e[0] eq $!nick ) - or ( $e eq 'PRIVMSG' - and $e[1] ~~ /:i ^ "$.nick" <[,:]> \s+/ - ) - ) { - for @!plugs.grep(*.^can: 'irc-addressed') -> $p { - my $res = $p.irc-notice-me(self, $e); - return unless $res === IRC_NOT_HANDLED; - } - } - my $cmd = 'irc-' ~ $e.lc; for @!plugs.grep(*.^can: $cmd) -> $p { my $res = $p."$cmd"(self, $e); -- cgit v1.1