blob: 74261c953db5bba142238bd85da01b44af0da651 (
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
|
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 Nick does M { has $.new-nick; }
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, :$.server; }
}
role Privmsg does M { has $.text; }
role Privmsg::Channel does Privmsg {
has $.channel;
method reply ($text, :$where) {
$.irc.send-cmd: 'PRIVMSG', $where // $.channel, $text, :$.server;
}
}
role Privmsg::Me does Privmsg {
method reply ($text, :$where) {
$where //= $.nick;
$.irc.send-cmd: 'PRIVMSG', $where, $text, :$.server;
}
}
|