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
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
|
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 $.server is required;
has $.args is required;
method Str { ":$!usermask $!command $!args[]" }
}
constant M = IRC::Client::Message;
role Join does M { has $.channel; }
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 is rw;
has Bool $.replied is rw = False;
method ACCEPTS ($what) { $.text ~~ $what }
}
role Privmsg::Channel does Privmsg {
has $.channel;
method reply ($text, :$where) {
$.irc.send-cmd: 'PRIVMSG', $where // $.channel, $text,
:$.server, :prefix("$.nick, ");
}
}
role Privmsg::Me does Privmsg {
method reply ($text, :$where) {
$.irc.send-cmd: 'PRIVMSG', $where // $.nick, $text,
:$.server;
}
}
role Notice does M {
has $.text is rw;
has Bool $.replied is rw = False;
method Str { $.text }
}
role Notice::Channel does Notice {
has $.channel;
method reply ($text, :$where) {
$.irc.send-cmd: 'NOTICE', $where // $.channel, $text,
:$.server, :prefix("$.nick, ");
$.replied = True;
}
}
role Notice::Me does Notice {
method reply ($text, :$where) {
$.irc.send-cmd: 'NOTICE', $where // $.nick, $text,
:$.server;
$.replied = True;
}
}
|