aboutsummaryrefslogtreecommitdiff
path: root/lib
diff options
context:
space:
mode:
authorZoffix Znet <cpan@zoffix.com>2016-01-03 11:37:51 -0500
committerZoffix Znet <cpan@zoffix.com>2016-01-03 11:37:51 -0500
commit55b8bd87c6f07d21de8b3037317b54c6a0374c86 (patch)
treed5a2ee2affd7470c6cd4facdb0522669380c77bb /lib
parenta35dad2b1a755cdff3f11a19472090dbd661d48c (diff)
Add irc-to-me method
Diffstat (limited to 'lib')
-rw-r--r--lib/IRC/Client.pm630
1 files changed, 18 insertions, 12 deletions
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<command> eq 'PRIVMSG' and $e<params>[0] eq $!nick )
+ or ( $e<command> eq 'NOTICE' and $e<params>[0] eq $!nick )
+ or ( $e<command> eq 'PRIVMSG'
+ and $e<params>[1] ~~ /:i ^ $nick <[,:]> \s+/
+ )
+ ) {
+ my $where = ($e<who><nick>, $e<who><nick>);
+ $where[0] = $e<params>[0]
+ unless ( $e<command> eq 'PRIVMSG' and $e<params>[0] eq $!nick )
+ or ( $e<command> eq 'NOTICE' and $e<params>[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<command> eq 'PRIVMSG' and $e<params>[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<command> eq 'PRIVMSG' and $e<params>[0] eq $!nick )
- or ( $e<command> eq 'NOTICE' and $e<params>[0] eq $!nick )
- or ( $e<command> eq 'PRIVMSG'
- and $e<params>[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<command>.lc;
for @!plugs.grep(*.^can: $cmd) -> $p {
my $res = $p."$cmd"(self, $e);