blob: 54943bd3dd3f2890bce69738917182472713fa2d (
plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
|
unit class IRC::Client::Grammar::Actions;
use IRC::Client::Message::Numeric;
has $.irc;
has $.server;
method TOP ($/) {
$/.make: (
$<message>ยป.made,
~( $<left-overs> // '' ),
);
}
method message ($match) {
my %args;
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 = $match<params>;
loop {
if ( $p<middle>.defined ) {
%args<params>.append: ~$p<middle>;
}
if ( $p<trailing>.defined ) {
%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>//'',
server => $!server;
.<usermask> = .<nick> ~ '!' ~ .<username> ~ '@' ~ .<host> given %msg-args;
my $msg;
given ~$match<command> {
when /^ $<command>=(<[0..9]>**3) $/ {
$msg = IRC::Client::Message::Numeric.new:
:command( ~$<command> ),
:args( %args<params> ),
|%msg-args;
}
}
$match.make: $msg;
}
|