blob: 1b38d23515588cc8e645c24a9c1ba0d102fc0881 (
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
|
unit package IRC::Client::Message;
role IRC::Client::Message {
has $.irc is required;
has Str:D $.nick is required;
has Str:D $.username is required;
has Str:D $.host is required;
has Str:D $.usermask is required;
has Str:D $.command is required;
has Str:D $.server is required;
has @.args is required;
method Str { ":$!usermask $!command @!args[]" }
}
constant M = IRC::Client::Message;
role Join does M { has $.channel; }
role Notice does M { has $.text; }
role Notice::Channel does Notice { has $.channel; }
role Notice::Me does Notice { }
role Mode does M { has @.modes; }
role Mode::Channel does Mode { has $.channel; }
role Mode::Me does Mode { }
role Numeric does M { }
role Part does M { has $.channel; }
role Quit does M { }
role Unknown does M {
method Str { "❚⚠❚ :$.usermask $.command @.args[]" }
}
role Ping does M {
method reply { $.irc.send-cmd: 'PONG', @.args; }
}
role Privmsg does M { has $.text; }
role Privmsg::Channel does Privmsg {
has $.channel;
method reply ($text, :$where) {
$.irc.send-cmd: 'PRIVMSG', $where // $.channel, $text;
}
}
role Privmsg::Me does Privmsg {
method reply ($text, :$where) {
$where //= $.nick;
$.irc.send-cmd: 'PRIVMSG', $where, $text;
}
}
|