line |
stmt |
bran |
cond |
sub |
pod |
time |
code |
1
|
|
|
|
|
|
|
package Bot::Cobalt::IRC::Role::UserEvents; |
2
|
|
|
|
|
|
|
$Bot::Cobalt::IRC::Role::UserEvents::VERSION = '0.021003'; |
3
|
|
|
|
|
|
|
## POD lives in Bot::Cobalt::IRC for now ... |
4
|
|
|
|
|
|
|
|
5
|
5
|
|
|
5
|
|
8554
|
use 5.12.1; |
|
5
|
|
|
|
|
14
|
|
6
|
|
|
|
|
|
|
|
7
|
5
|
|
|
5
|
|
18
|
use Bot::Cobalt; |
|
5
|
|
|
|
|
8
|
|
|
5
|
|
|
|
|
32
|
|
8
|
5
|
|
|
5
|
|
3271
|
use Bot::Cobalt::Common; |
|
5
|
|
|
|
|
7
|
|
|
5
|
|
|
|
|
38
|
|
9
|
|
|
|
|
|
|
|
10
|
5
|
|
|
5
|
|
22
|
use Moo::Role; |
|
5
|
|
|
|
|
7
|
|
|
5
|
|
|
|
|
38
|
|
11
|
|
|
|
|
|
|
|
12
|
5
|
|
|
5
|
|
1863
|
use strictures 2; |
|
5
|
|
|
|
|
25
|
|
|
5
|
|
|
|
|
224
|
|
13
|
|
|
|
|
|
|
|
14
|
|
|
|
|
|
|
requires qw/ |
15
|
|
|
|
|
|
|
ircobjs |
16
|
|
|
|
|
|
|
/; |
17
|
|
|
|
|
|
|
|
18
|
0
|
|
|
0
|
0
|
|
sub Bot_send_message { Bot_message(@_) } |
19
|
|
|
|
|
|
|
sub Bot_message { |
20
|
0
|
|
|
0
|
0
|
|
my ($self, $core) = splice @_, 0, 2; |
21
|
|
|
|
|
|
|
|
22
|
0
|
0
|
|
|
|
|
unless (defined $_[2]) { |
23
|
0
|
|
|
|
|
|
logger->error("Bot_message received without enough arguments"); |
24
|
0
|
|
|
|
|
|
return PLUGIN_EAT_NONE |
25
|
|
|
|
|
|
|
} |
26
|
|
|
|
|
|
|
|
27
|
0
|
|
|
|
|
|
my $context = ${$_[0]}; |
|
0
|
|
|
|
|
|
|
28
|
0
|
|
|
|
|
|
my $target = ${$_[1]}; |
|
0
|
|
|
|
|
|
|
29
|
0
|
|
|
|
|
|
my $txt = ${$_[2]}; |
|
0
|
|
|
|
|
|
|
30
|
|
|
|
|
|
|
|
31
|
|
|
|
|
|
|
return PLUGIN_EAT_NONE |
32
|
0
|
0
|
0
|
|
|
|
unless defined $self->ircobjs->{$context} |
33
|
|
|
|
|
|
|
and $core->is_connected($context); |
34
|
|
|
|
|
|
|
|
35
|
|
|
|
|
|
|
## USER event Outgoing_message for output filters |
36
|
0
|
|
|
|
|
|
my @msg = ( $context, $target, $txt ); |
37
|
0
|
|
|
|
|
|
my $eat = $core->send_user_event( 'message', \@msg ); |
38
|
|
|
|
|
|
|
|
39
|
0
|
0
|
|
|
|
|
unless ($eat == PLUGIN_EAT_ALL) { |
40
|
0
|
|
|
|
|
|
my ($target, $txt) = @msg[1,2]; |
41
|
|
|
|
|
|
|
|
42
|
0
|
0
|
0
|
|
|
|
if (defined $target && defined $txt && $txt ne '') { |
|
|
|
0
|
|
|
|
|
43
|
0
|
|
|
|
|
|
$self->ircobjs->{$context}->yield( 'privmsg', |
44
|
|
|
|
|
|
|
$target, |
45
|
|
|
|
|
|
|
$txt |
46
|
|
|
|
|
|
|
); |
47
|
|
|
|
|
|
|
|
48
|
0
|
|
|
|
|
|
broadcast( 'message_sent', |
49
|
|
|
|
|
|
|
$context, $target, $txt |
50
|
|
|
|
|
|
|
); |
51
|
|
|
|
|
|
|
|
52
|
0
|
|
|
|
|
|
++$core->State->{Counters}->{Sent}; |
53
|
|
|
|
|
|
|
} else { |
54
|
0
|
|
|
|
|
|
logger->error( |
55
|
|
|
|
|
|
|
"Bot_message without defined target and txt after Outgoing_message" |
56
|
|
|
|
|
|
|
) |
57
|
|
|
|
|
|
|
} |
58
|
|
|
|
|
|
|
} |
59
|
|
|
|
|
|
|
|
60
|
0
|
|
|
|
|
|
return PLUGIN_EAT_NONE |
61
|
|
|
|
|
|
|
} |
62
|
|
|
|
|
|
|
|
63
|
|
|
|
|
|
|
|
64
|
0
|
|
|
0
|
0
|
|
sub Bot_send_notice { Bot_notice(@_) } |
65
|
|
|
|
|
|
|
sub Bot_notice { |
66
|
0
|
|
|
0
|
0
|
|
my ($self, $core) = splice @_, 0, 2; |
67
|
|
|
|
|
|
|
|
68
|
0
|
0
|
|
|
|
|
unless (defined $_[2]) { |
69
|
0
|
|
|
|
|
|
logger->error("Bot_notice received without enough arguments"); |
70
|
0
|
|
|
|
|
|
return PLUGIN_EAT_NONE |
71
|
|
|
|
|
|
|
} |
72
|
|
|
|
|
|
|
|
73
|
0
|
|
|
|
|
|
my $context = ${$_[0]}; |
|
0
|
|
|
|
|
|
|
74
|
0
|
|
|
|
|
|
my $target = ${$_[1]}; |
|
0
|
|
|
|
|
|
|
75
|
0
|
|
|
|
|
|
my $txt = ${$_[2]}; |
|
0
|
|
|
|
|
|
|
76
|
|
|
|
|
|
|
|
77
|
|
|
|
|
|
|
return PLUGIN_EAT_NONE |
78
|
0
|
0
|
0
|
|
|
|
unless defined $self->ircobjs->{$context} |
79
|
|
|
|
|
|
|
and $core->is_connected($context); |
80
|
|
|
|
|
|
|
|
81
|
|
|
|
|
|
|
## USER event Outgoing_notice |
82
|
0
|
|
|
|
|
|
my @notice = ( $context, $target, $txt ); |
83
|
0
|
|
|
|
|
|
my $eat = $core->send_user_event( 'notice', \@notice ); |
84
|
|
|
|
|
|
|
|
85
|
0
|
0
|
|
|
|
|
unless ($eat == PLUGIN_EAT_ALL) { |
86
|
0
|
|
|
|
|
|
my ($target, $txt) = @notice[1,2]; |
87
|
|
|
|
|
|
|
|
88
|
0
|
|
|
|
|
|
$self->ircobjs->{$context}->yield( 'notice', |
89
|
|
|
|
|
|
|
$target, |
90
|
|
|
|
|
|
|
$txt |
91
|
|
|
|
|
|
|
); |
92
|
|
|
|
|
|
|
|
93
|
0
|
|
|
|
|
|
broadcast( 'notice_sent', $context, $target, $txt ); |
94
|
|
|
|
|
|
|
} |
95
|
|
|
|
|
|
|
|
96
|
0
|
|
|
|
|
|
return PLUGIN_EAT_NONE |
97
|
|
|
|
|
|
|
} |
98
|
|
|
|
|
|
|
|
99
|
|
|
|
|
|
|
|
100
|
0
|
|
|
0
|
0
|
|
sub Bot_send_action { Bot_action(@_) } |
101
|
|
|
|
|
|
|
sub Bot_action { |
102
|
0
|
|
|
0
|
0
|
|
my ($self, $core) = splice @_, 0, 2; |
103
|
|
|
|
|
|
|
|
104
|
0
|
0
|
|
|
|
|
unless (defined $_[2]) { |
105
|
0
|
|
|
|
|
|
logger->error("Bot_action received without enough arguments"); |
106
|
0
|
|
|
|
|
|
return PLUGIN_EAT_NONE |
107
|
|
|
|
|
|
|
} |
108
|
|
|
|
|
|
|
|
109
|
0
|
|
|
|
|
|
my $context = ${$_[0]}; |
|
0
|
|
|
|
|
|
|
110
|
0
|
|
|
|
|
|
my $target = ${$_[1]}; |
|
0
|
|
|
|
|
|
|
111
|
0
|
|
|
|
|
|
my $txt = ${$_[2]}; |
|
0
|
|
|
|
|
|
|
112
|
|
|
|
|
|
|
|
113
|
|
|
|
|
|
|
return PLUGIN_EAT_NONE |
114
|
0
|
0
|
0
|
|
|
|
unless defined $self->ircobjs->{$context} |
115
|
|
|
|
|
|
|
and $core->is_connected($context); |
116
|
|
|
|
|
|
|
|
117
|
|
|
|
|
|
|
## USER event Outgoing_ctcp (CONTEXT, TYPE, TARGET, TEXT) |
118
|
0
|
|
|
|
|
|
my @ctcp = ( $context, 'ACTION', $target, $txt ); |
119
|
0
|
|
|
|
|
|
my $eat = $core->send_user_event( 'ctcp', \@ctcp ); |
120
|
|
|
|
|
|
|
|
121
|
0
|
0
|
|
|
|
|
unless ($eat == PLUGIN_EAT_ALL) { |
122
|
0
|
|
|
|
|
|
my ($target, $txt) = @ctcp[2,3]; |
123
|
|
|
|
|
|
|
|
124
|
0
|
|
|
|
|
|
$self->ircobjs->{$context}->yield( 'ctcp', |
125
|
|
|
|
|
|
|
$target, |
126
|
|
|
|
|
|
|
'ACTION '.$txt |
127
|
|
|
|
|
|
|
); |
128
|
|
|
|
|
|
|
|
129
|
0
|
|
|
|
|
|
broadcast( 'ctcp_sent', $context, 'ACTION', $target, $txt ); |
130
|
|
|
|
|
|
|
} |
131
|
|
|
|
|
|
|
|
132
|
0
|
|
|
|
|
|
return PLUGIN_EAT_NONE |
133
|
|
|
|
|
|
|
} |
134
|
|
|
|
|
|
|
|
135
|
|
|
|
|
|
|
|
136
|
|
|
|
|
|
|
sub Bot_topic { |
137
|
0
|
|
|
0
|
0
|
|
my ($self, $core) = splice @_, 0, 2; |
138
|
|
|
|
|
|
|
|
139
|
0
|
0
|
|
|
|
|
unless (defined $_[1]) { |
140
|
0
|
|
|
|
|
|
logger->error("Bot_topic received without enough arguments"); |
141
|
0
|
|
|
|
|
|
return PLUGIN_EAT_NONE |
142
|
|
|
|
|
|
|
} |
143
|
|
|
|
|
|
|
|
144
|
0
|
|
|
|
|
|
my $context = ${$_[0]}; |
|
0
|
|
|
|
|
|
|
145
|
0
|
|
|
|
|
|
my $channel = ${$_[1]}; |
|
0
|
|
|
|
|
|
|
146
|
0
|
0
|
|
|
|
|
my $topic = defined $_[2] ? ${$_[2]} : "" ; |
|
0
|
|
|
|
|
|
|
147
|
|
|
|
|
|
|
|
148
|
|
|
|
|
|
|
return PLUGIN_EAT_NONE |
149
|
0
|
0
|
0
|
|
|
|
unless defined $self->ircobjs->{$context} |
150
|
|
|
|
|
|
|
and $core->is_connected($context); |
151
|
|
|
|
|
|
|
|
152
|
0
|
0
|
|
|
|
|
return PLUGIN_EAT_NONE unless $core->is_connected($context); |
153
|
|
|
|
|
|
|
|
154
|
0
|
|
|
|
|
|
$self->irc->yield( 'topic', $channel, $topic ); |
155
|
|
|
|
|
|
|
|
156
|
0
|
|
|
|
|
|
return PLUGIN_EAT_NONE |
157
|
|
|
|
|
|
|
} |
158
|
|
|
|
|
|
|
|
159
|
|
|
|
|
|
|
sub Bot_mode { |
160
|
0
|
|
|
0
|
0
|
|
my ($self, $core) = splice @_, 0, 2; |
161
|
|
|
|
|
|
|
|
162
|
0
|
0
|
|
|
|
|
unless (defined $_[2]) { |
163
|
0
|
|
|
|
|
|
logger->error("Bot_mode received without enough arguments"); |
164
|
0
|
|
|
|
|
|
return PLUGIN_EAT_NONE |
165
|
|
|
|
|
|
|
} |
166
|
|
|
|
|
|
|
|
167
|
0
|
|
|
|
|
|
my $context = ${$_[0]}; |
|
0
|
|
|
|
|
|
|
168
|
0
|
|
|
|
|
|
my $target = ${$_[1]}; ## channel or self normally |
|
0
|
|
|
|
|
|
|
169
|
0
|
|
|
|
|
|
my $modestr = ${$_[2]}; ## modes + args |
|
0
|
|
|
|
|
|
|
170
|
|
|
|
|
|
|
|
171
|
|
|
|
|
|
|
return PLUGIN_EAT_NONE |
172
|
0
|
0
|
0
|
|
|
|
unless defined $self->ircobjs->{$context} |
173
|
|
|
|
|
|
|
and $core->is_connected($context); |
174
|
|
|
|
|
|
|
|
175
|
0
|
|
|
|
|
|
my ($mode, @args) = split ' ', $modestr; |
176
|
|
|
|
|
|
|
|
177
|
0
|
|
|
|
|
|
$self->ircobjs->{$context}->yield( 'mode', $target, $mode, @args ); |
178
|
|
|
|
|
|
|
|
179
|
0
|
|
|
|
|
|
return PLUGIN_EAT_NONE |
180
|
|
|
|
|
|
|
} |
181
|
|
|
|
|
|
|
|
182
|
|
|
|
|
|
|
sub Bot_kick { |
183
|
0
|
|
|
0
|
0
|
|
my ($self, $core) = splice @_, 0, 2; |
184
|
|
|
|
|
|
|
|
185
|
0
|
0
|
|
|
|
|
unless (defined $_[2]) { |
186
|
0
|
|
|
|
|
|
logger->error("Bot_kick received without enough arguments"); |
187
|
0
|
|
|
|
|
|
return PLUGIN_EAT_NONE |
188
|
|
|
|
|
|
|
} |
189
|
|
|
|
|
|
|
|
190
|
0
|
|
|
|
|
|
my $context = ${$_[0]}; |
|
0
|
|
|
|
|
|
|
191
|
0
|
|
|
|
|
|
my $channel = ${$_[1]}; |
|
0
|
|
|
|
|
|
|
192
|
0
|
|
|
|
|
|
my $target = ${$_[2]}; |
|
0
|
|
|
|
|
|
|
193
|
0
|
0
|
|
|
|
|
my $reason = defined $_[3] ? ${$_[3]} : 'Kicked'; |
|
0
|
|
|
|
|
|
|
194
|
|
|
|
|
|
|
|
195
|
|
|
|
|
|
|
return PLUGIN_EAT_NONE |
196
|
0
|
0
|
0
|
|
|
|
unless defined $self->ircobjs->{$context} |
197
|
|
|
|
|
|
|
and $core->is_connected($context); |
198
|
|
|
|
|
|
|
|
199
|
0
|
0
|
|
|
|
|
return PLUGIN_EAT_NONE unless $core->is_connected($context); |
200
|
|
|
|
|
|
|
|
201
|
0
|
|
|
|
|
|
$self->ircobjs->{$context}->yield( 'kick', $channel, $target, $reason |
202
|
|
|
|
|
|
|
); |
203
|
|
|
|
|
|
|
|
204
|
0
|
|
|
|
|
|
return PLUGIN_EAT_NONE |
205
|
|
|
|
|
|
|
} |
206
|
|
|
|
|
|
|
|
207
|
|
|
|
|
|
|
|
208
|
|
|
|
|
|
|
sub Bot_join { |
209
|
0
|
|
|
0
|
0
|
|
my ($self, $core) = splice @_, 0, 2; |
210
|
|
|
|
|
|
|
|
211
|
0
|
0
|
|
|
|
|
unless (defined $_[1]) { |
212
|
0
|
|
|
|
|
|
logger->error("Bot_join received without enough arguments"); |
213
|
0
|
|
|
|
|
|
return PLUGIN_EAT_NONE |
214
|
|
|
|
|
|
|
} |
215
|
|
|
|
|
|
|
|
216
|
0
|
|
|
|
|
|
my $context = ${$_[0]}; |
|
0
|
|
|
|
|
|
|
217
|
0
|
|
|
|
|
|
my $channel = ${$_[1]}; |
|
0
|
|
|
|
|
|
|
218
|
|
|
|
|
|
|
|
219
|
|
|
|
|
|
|
return PLUGIN_EAT_NONE |
220
|
0
|
0
|
0
|
|
|
|
unless defined $self->ircobjs->{$context} |
221
|
|
|
|
|
|
|
and $core->is_connected($context); |
222
|
|
|
|
|
|
|
|
223
|
0
|
|
|
|
|
|
$self->ircobjs->{$context}->yield( 'join', $channel ); |
224
|
|
|
|
|
|
|
|
225
|
0
|
|
|
|
|
|
return PLUGIN_EAT_NONE |
226
|
|
|
|
|
|
|
} |
227
|
|
|
|
|
|
|
|
228
|
|
|
|
|
|
|
sub Bot_part { |
229
|
0
|
|
|
0
|
0
|
|
my ($self, $core) = splice @_, 0, 2; |
230
|
|
|
|
|
|
|
|
231
|
0
|
0
|
|
|
|
|
unless (defined $_[1]) { |
232
|
0
|
|
|
|
|
|
logger->error("Bot_part received without enough arguments"); |
233
|
0
|
|
|
|
|
|
return PLUGIN_EAT_NONE |
234
|
|
|
|
|
|
|
} |
235
|
|
|
|
|
|
|
|
236
|
0
|
|
|
|
|
|
my $context = ${$_[0]}; |
|
0
|
|
|
|
|
|
|
237
|
0
|
|
|
|
|
|
my $channel = ${$_[1]}; |
|
0
|
|
|
|
|
|
|
238
|
0
|
0
|
|
|
|
|
my $reason = defined $_[2] ? ${$_[2]} : 'Leaving' ; |
|
0
|
|
|
|
|
|
|
239
|
|
|
|
|
|
|
|
240
|
|
|
|
|
|
|
return PLUGIN_EAT_NONE |
241
|
0
|
0
|
0
|
|
|
|
unless defined $self->ircobjs->{$context} |
242
|
|
|
|
|
|
|
and $core->is_connected($context); |
243
|
|
|
|
|
|
|
|
244
|
0
|
|
|
|
|
|
$self->ircobjs->{$context}->yield( 'part', $channel, $reason ); |
245
|
|
|
|
|
|
|
|
246
|
0
|
|
|
|
|
|
return PLUGIN_EAT_NONE |
247
|
|
|
|
|
|
|
} |
248
|
|
|
|
|
|
|
|
249
|
|
|
|
|
|
|
sub Bot_send_raw { |
250
|
0
|
|
|
0
|
0
|
|
my ($self, $core) = splice @_, 0, 2; |
251
|
|
|
|
|
|
|
|
252
|
0
|
0
|
|
|
|
|
unless (defined $_[1]) { |
253
|
0
|
|
|
|
|
|
logger->error("Bot_send_Raw received without enough arguments"); |
254
|
0
|
|
|
|
|
|
return PLUGIN_EAT_NONE |
255
|
|
|
|
|
|
|
} |
256
|
|
|
|
|
|
|
|
257
|
0
|
|
|
|
|
|
my $context = ${$_[0]}; |
|
0
|
|
|
|
|
|
|
258
|
0
|
|
|
|
|
|
my $raw = ${$_[1]}; |
|
0
|
|
|
|
|
|
|
259
|
|
|
|
|
|
|
|
260
|
|
|
|
|
|
|
return PLUGIN_EAT_NONE |
261
|
0
|
0
|
0
|
|
|
|
unless defined $self->ircobjs->{$context} |
262
|
|
|
|
|
|
|
and $core->is_connected($context); |
263
|
|
|
|
|
|
|
|
264
|
0
|
|
|
|
|
|
$self->ircobjs->{$context}->yield( 'quote', $raw ); |
265
|
|
|
|
|
|
|
|
266
|
0
|
|
|
|
|
|
broadcast( 'raw_sent', $context, $raw ); |
267
|
|
|
|
|
|
|
|
268
|
0
|
|
|
|
|
|
return PLUGIN_EAT_NONE |
269
|
|
|
|
|
|
|
} |
270
|
|
|
|
|
|
|
|
271
|
|
|
|
|
|
|
|
272
|
|
|
|
|
|
|
1 |