diff options
author | Zoffix Znet <cpan@zoffix.com> | 2016-06-04 15:16:43 -0400 |
---|---|---|
committer | Zoffix Znet <cpan@zoffix.com> | 2016-06-04 15:16:43 -0400 |
commit | 791d7981cff0cd3a85fdd504f410a7c9833272dc (patch) | |
tree | 8939f72fb9d4c496cf2f988e35a3d6351343c374 /lib/IRC/Client/Grammar/Actions.pm6 | |
parent | cb0a6cace8871d17c9701edc1ccba26d1e6e0bfe (diff) |
More stuff
Diffstat (limited to 'lib/IRC/Client/Grammar/Actions.pm6')
-rw-r--r-- | lib/IRC/Client/Grammar/Actions.pm6 | 33 |
1 files changed, 17 insertions, 16 deletions
diff --git a/lib/IRC/Client/Grammar/Actions.pm6 b/lib/IRC/Client/Grammar/Actions.pm6 index 3e190cd..54943bd 100644 --- a/lib/IRC/Client/Grammar/Actions.pm6 +++ b/lib/IRC/Client/Grammar/Actions.pm6 @@ -5,23 +5,23 @@ use IRC::Client::Message::Numeric; has $.irc; has $.server; -method TOP ($/) { $/.make: ($<message>».made, $<left-overs>) } - -method left-overs ($/) { - $/.made: $/.defined ?? !$/ !! ''; +method TOP ($/) { + $/.make: ( + $<message>».made, + ~( $<left-overs> // '' ), + ); } -method message ($/) { +method message ($match) { my %args; - my $pref = $/<prefix>; + my $pref = $match<prefix>; for qw/nick user host/ { $pref{$_}.defined or next; %args<who>{$_} = ~$pref{$_}; } %args<who><host> = ~$pref<servername> if $pref<servername>.defined; - my $p = $<params>; - + my $p = $match<params>; loop { if ( $p<middle>.defined ) { %args<params>.append: ~$p<middle>; @@ -30,26 +30,27 @@ method message ($/) { %args<params>.append: ~$p<trailing>; last; } + last unless $p<params>.defined; $p = $p<params>; } my %msg-args = irc => $!irc, - nick => %args<who><nick>, - username => %args<who><user>, - host => %args<who><host>, - usermask => "%args<who><nick>!%args<who><user>@%args<who><host>", + nick => %args<who><nick>//'', + username => %args<who><user>//'', + host => %args<who><host>//'', server => $!server; + .<usermask> = .<nick> ~ '!' ~ .<username> ~ '@' ~ .<host> given %msg-args; my $msg; - given ~$<command> { - when /^ ([0..9]**3) $/ { + given ~$match<command> { + when /^ $<command>=(<[0..9]>**3) $/ { $msg = IRC::Client::Message::Numeric.new: - :command( $<command> ), + :command( ~$<command> ), :args( %args<params> ), |%msg-args; } } - $/.make: $msg; + $match.make: $msg; } |