line |
stmt |
bran |
cond |
sub |
pod |
time |
code |
1
|
|
|
|
|
|
|
# You may distribute under the terms of the GNU General Public License |
2
|
|
|
|
|
|
|
# |
3
|
|
|
|
|
|
|
# (C) Paul Evans, 2008-2016 -- leonerd@leonerd.org.uk |
4
|
|
|
|
|
|
|
|
5
|
|
|
|
|
|
|
package Circle::Net::IRC::User; |
6
|
|
|
|
|
|
|
|
7
|
4
|
|
|
4
|
|
24
|
use strict; |
|
4
|
|
|
|
|
8
|
|
|
4
|
|
|
|
|
219
|
|
8
|
4
|
|
|
4
|
|
18
|
use warnings; |
|
4
|
|
|
|
|
7
|
|
|
4
|
|
|
|
|
94
|
|
9
|
4
|
|
|
4
|
|
16
|
use base qw( Circle::Net::IRC::Target ); |
|
4
|
|
|
|
|
6
|
|
|
4
|
|
|
|
|
398
|
|
10
|
|
|
|
|
|
|
|
11
|
|
|
|
|
|
|
our $VERSION = '0.173320'; |
12
|
|
|
|
|
|
|
|
13
|
4
|
|
|
4
|
|
21
|
use Carp; |
|
4
|
|
|
|
|
6
|
|
|
4
|
|
|
|
|
3300
|
|
14
|
|
|
|
|
|
|
|
15
|
|
|
|
|
|
|
# Don't reprint RPL_USERISAWAY message within 1 hour |
16
|
|
|
|
|
|
|
# TODO: Some sort of config setting system |
17
|
|
|
|
|
|
|
my $awaytime_print = 3600; |
18
|
|
|
|
|
|
|
|
19
|
|
|
|
|
|
|
sub default_message_level |
20
|
|
|
|
|
|
|
{ |
21
|
0
|
|
|
0
|
0
|
|
my $self = shift; |
22
|
0
|
|
|
|
|
|
my ( $hints ) = @_; |
23
|
|
|
|
|
|
|
|
24
|
0
|
|
|
|
|
|
return 3; |
25
|
|
|
|
|
|
|
} |
26
|
|
|
|
|
|
|
|
27
|
|
|
|
|
|
|
sub on_message |
28
|
|
|
|
|
|
|
{ |
29
|
0
|
|
|
0
|
0
|
|
my $self = shift; |
30
|
0
|
|
|
|
|
|
my ( $command, $message, $hints ) = @_; |
31
|
|
|
|
|
|
|
|
32
|
|
|
|
|
|
|
# Messages from the user will have a prefix_user hint, server messages will not. |
33
|
0
|
0
|
|
|
|
|
if( defined( my $ident = $hints->{prefix_user} ) ) { |
34
|
0
|
|
|
|
|
|
my $hostname = $hints->{prefix_host}; |
35
|
|
|
|
|
|
|
|
36
|
0
|
|
|
|
|
|
$self->update_ident( "$ident\@$hostname" ); |
37
|
|
|
|
|
|
|
} |
38
|
|
|
|
|
|
|
|
39
|
0
|
|
|
|
|
|
return $self->SUPER::on_message( @_ ); |
40
|
|
|
|
|
|
|
} |
41
|
|
|
|
|
|
|
|
42
|
|
|
|
|
|
|
sub update_ident |
43
|
|
|
|
|
|
|
{ |
44
|
0
|
|
|
0
|
0
|
|
my $self = shift; |
45
|
0
|
|
|
|
|
|
my ( $ident ) = @_; |
46
|
|
|
|
|
|
|
|
47
|
0
|
0
|
0
|
|
|
|
return if defined $self->get_prop_ident and $self->get_prop_ident eq $ident; |
48
|
0
|
|
|
|
|
|
$self->set_prop_ident( $ident ); |
49
|
|
|
|
|
|
|
} |
50
|
|
|
|
|
|
|
|
51
|
|
|
|
|
|
|
sub on_message_NICK |
52
|
|
|
|
|
|
|
{ |
53
|
0
|
|
|
0
|
0
|
|
my $self = shift; |
54
|
0
|
|
|
|
|
|
my ( $message, $hints ) = @_; |
55
|
|
|
|
|
|
|
|
56
|
0
|
|
|
|
|
|
my $oldnick = $self->name; |
57
|
0
|
|
|
|
|
|
my $newnick = $hints->{new_nick}; |
58
|
|
|
|
|
|
|
|
59
|
0
|
|
|
|
|
|
$self->push_displayevent( "irc.nick", { oldnick => $oldnick, newnick => $newnick } ); |
60
|
0
|
|
|
|
|
|
$self->bump_level( 1 ); |
61
|
|
|
|
|
|
|
|
62
|
0
|
|
|
|
|
|
$self->set_prop_name( $newnick ); |
63
|
0
|
|
|
|
|
|
$self->set_prop_tag( $newnick ); |
64
|
|
|
|
|
|
|
|
65
|
0
|
|
|
|
|
|
my $oldnick_folded = $self->{irc}->casefold_name( $oldnick ); |
66
|
|
|
|
|
|
|
|
67
|
0
|
|
|
|
|
|
$self->fire_event( "change_nick", $oldnick, $oldnick_folded, $newnick, $hints->{new_nick_folded} ); |
68
|
|
|
|
|
|
|
|
69
|
0
|
|
|
|
|
|
return 1; |
70
|
|
|
|
|
|
|
} |
71
|
|
|
|
|
|
|
|
72
|
|
|
|
|
|
|
sub on_message_QUIT |
73
|
|
|
|
|
|
|
{ |
74
|
0
|
|
|
0
|
0
|
|
my $self = shift; |
75
|
0
|
|
|
|
|
|
my ( $message, $hints ) = @_; |
76
|
|
|
|
|
|
|
|
77
|
0
|
|
|
|
|
|
my $nick = $self->name; |
78
|
0
|
|
|
|
|
|
my $quitmsg = $hints->{text}; |
79
|
|
|
|
|
|
|
|
80
|
0
|
0
|
|
|
|
|
defined $quitmsg or $quitmsg = ""; |
81
|
|
|
|
|
|
|
|
82
|
0
|
|
|
|
|
|
my $net = $self->{net}; |
83
|
0
|
|
|
|
|
|
my $quitmsg_formatted = $net->format_text( $quitmsg ); |
84
|
|
|
|
|
|
|
|
85
|
0
|
|
|
|
|
|
my $userhost = "$hints->{prefix_user}\@$hints->{prefix_host}"; |
86
|
|
|
|
|
|
|
|
87
|
0
|
|
|
|
|
|
$self->push_displayevent( "irc.quit", { nick => $nick, userhost => $userhost, quitmsg => $quitmsg_formatted } ); |
88
|
0
|
|
|
|
|
|
$self->bump_level( 1 ); |
89
|
|
|
|
|
|
|
|
90
|
0
|
|
|
|
|
|
return 1; |
91
|
|
|
|
|
|
|
} |
92
|
|
|
|
|
|
|
|
93
|
|
|
|
|
|
|
sub on_message_RPL_AWAY |
94
|
|
|
|
|
|
|
{ |
95
|
0
|
|
|
0
|
0
|
|
my $self = shift; |
96
|
0
|
|
|
|
|
|
my ( $message, $hints ) = @_; |
97
|
|
|
|
|
|
|
|
98
|
0
|
|
|
|
|
|
my $nick = $self->name; |
99
|
0
|
|
|
|
|
|
my $awaymsg = $hints->{text}; |
100
|
|
|
|
|
|
|
|
101
|
0
|
0
|
|
|
|
|
defined $awaymsg or $awaymsg = ""; |
102
|
|
|
|
|
|
|
|
103
|
|
|
|
|
|
|
# Surpress the message if it's already been printed and it's quite soon |
104
|
0
|
|
|
|
|
|
my $now = time; |
105
|
0
|
0
|
0
|
|
|
|
if( defined $self->{printed_awaymsg} and |
|
|
|
0
|
|
|
|
|
106
|
|
|
|
|
|
|
$self->{printed_awaymsg} eq $awaymsg and |
107
|
|
|
|
|
|
|
$now < $self->{printed_awaytime} + $awaytime_print ) { |
108
|
0
|
|
|
|
|
|
return 1; |
109
|
|
|
|
|
|
|
} |
110
|
|
|
|
|
|
|
|
111
|
0
|
|
|
|
|
|
my $net = $self->{net}; |
112
|
0
|
|
|
|
|
|
my $awaymsg_formatted = $net->format_text( $awaymsg ); |
113
|
|
|
|
|
|
|
|
114
|
0
|
|
|
|
|
|
my $userhost = "$hints->{prefix_user}\@$hints->{prefix_host}"; |
115
|
|
|
|
|
|
|
|
116
|
0
|
|
|
|
|
|
$self->push_displayevent( "irc.away", { nick => $nick, userhost => $userhost, text => $awaymsg_formatted } ); |
117
|
0
|
|
|
|
|
|
$self->bump_level( 1 ); |
118
|
|
|
|
|
|
|
|
119
|
0
|
|
|
|
|
|
$self->{printed_awaymsg} = $awaymsg; |
120
|
0
|
|
|
|
|
|
$self->{printed_awaytime} = $now; |
121
|
|
|
|
|
|
|
|
122
|
0
|
|
|
|
|
|
return 1; |
123
|
|
|
|
|
|
|
} |
124
|
|
|
|
|
|
|
|
125
|
|
|
|
|
|
|
sub on_message_RPL_LOGON |
126
|
|
|
|
|
|
|
{ |
127
|
0
|
|
|
0
|
0
|
|
my $self = shift; |
128
|
0
|
|
|
|
|
|
$self->on_message_RPL_NOWON( @_ ); |
129
|
|
|
|
|
|
|
|
130
|
0
|
|
|
|
|
|
my $nick = $self->name; |
131
|
|
|
|
|
|
|
|
132
|
0
|
|
|
|
|
|
$self->push_displayevent( "irc.online", { nick => $nick } ); |
133
|
0
|
|
|
|
|
|
$self->bump_level( 1 ); |
134
|
|
|
|
|
|
|
|
135
|
0
|
|
|
|
|
|
return 1; |
136
|
|
|
|
|
|
|
} |
137
|
|
|
|
|
|
|
|
138
|
|
|
|
|
|
|
sub on_message_RPL_LOGOFF |
139
|
|
|
|
|
|
|
{ |
140
|
0
|
|
|
0
|
0
|
|
my $self = shift; |
141
|
0
|
|
|
|
|
|
$self->on_message_RPL_NOWOFF( @_ ); |
142
|
|
|
|
|
|
|
|
143
|
0
|
|
|
|
|
|
my $nick = $self->name; |
144
|
|
|
|
|
|
|
|
145
|
0
|
|
|
|
|
|
$self->push_displayevent( "irc.offline", { nick => $nick } ); |
146
|
0
|
|
|
|
|
|
$self->bump_level( 1 ); |
147
|
|
|
|
|
|
|
|
148
|
0
|
|
|
|
|
|
return 1; |
149
|
|
|
|
|
|
|
} |
150
|
|
|
|
|
|
|
|
151
|
|
|
|
|
|
|
sub on_message_RPL_NOWON |
152
|
|
|
|
|
|
|
{ |
153
|
0
|
|
|
0
|
0
|
|
my $self = shift; |
154
|
|
|
|
|
|
|
|
155
|
0
|
|
|
|
|
|
$self->set_prop_presence( "online" ); |
156
|
|
|
|
|
|
|
|
157
|
0
|
|
|
|
|
|
return 1; |
158
|
|
|
|
|
|
|
} |
159
|
|
|
|
|
|
|
|
160
|
|
|
|
|
|
|
sub on_message_RPL_NOWOFF |
161
|
|
|
|
|
|
|
{ |
162
|
0
|
|
|
0
|
0
|
|
my $self = shift; |
163
|
|
|
|
|
|
|
|
164
|
0
|
|
|
|
|
|
$self->set_prop_presence( "offline" ); |
165
|
|
|
|
|
|
|
|
166
|
0
|
|
|
|
|
|
return 1; |
167
|
|
|
|
|
|
|
} |
168
|
|
|
|
|
|
|
|
169
|
|
|
|
|
|
|
# Send it back |
170
|
|
|
|
|
|
|
sub on_message_whois |
171
|
|
|
|
|
|
|
{ |
172
|
0
|
|
|
0
|
0
|
|
my $self = shift; |
173
|
0
|
|
|
|
|
|
my ( $message, $hints ) = @_; |
174
|
|
|
|
|
|
|
|
175
|
0
|
|
|
|
|
|
my $net = $self->{net}; |
176
|
0
|
|
|
|
|
|
$net->on_message_whois( $message, $hints ); |
177
|
|
|
|
|
|
|
} |
178
|
|
|
|
|
|
|
|
179
|
|
|
|
|
|
|
sub command_close |
180
|
|
|
|
|
|
|
: Command_description("Close the window") |
181
|
|
|
|
|
|
|
{ |
182
|
0
|
|
|
0
|
0
|
0
|
my $self = shift; |
183
|
|
|
|
|
|
|
|
184
|
0
|
|
|
|
|
0
|
$self->destroy; |
185
|
4
|
|
|
4
|
|
26
|
} |
|
4
|
|
|
|
|
7
|
|
|
4
|
|
|
|
|
19
|
|
186
|
|
|
|
|
|
|
|
187
|
|
|
|
|
|
|
sub command_requery |
188
|
|
|
|
|
|
|
: Command_description("Change the target nick for this user query") |
189
|
|
|
|
|
|
|
: Command_arg('newnick') |
190
|
|
|
|
|
|
|
{ |
191
|
0
|
|
|
0
|
0
|
0
|
my $self = shift; |
192
|
0
|
|
|
|
|
0
|
my ( $newnick ) = @_; |
193
|
|
|
|
|
|
|
|
194
|
0
|
|
|
|
|
0
|
my $oldnick = $self->name; |
195
|
|
|
|
|
|
|
|
196
|
0
|
|
|
|
|
0
|
$self->set_prop_name( $newnick ); |
197
|
0
|
|
|
|
|
0
|
$self->set_prop_tag( $newnick ); |
198
|
|
|
|
|
|
|
|
199
|
0
|
|
|
|
|
0
|
my $oldnick_folded = $self->{irc}->casefold_name( $oldnick ); |
200
|
0
|
|
|
|
|
0
|
my $newnick_folded = $self->{irc}->casefold_name( $newnick ); |
201
|
|
|
|
|
|
|
|
202
|
0
|
|
|
|
|
0
|
$self->fire_event( "change_nick", $oldnick, $oldnick_folded, $newnick, $newnick_folded ); |
203
|
|
|
|
|
|
|
|
204
|
0
|
|
|
|
|
0
|
return ( "Now talking to $newnick" ); |
205
|
4
|
|
|
4
|
|
1022
|
} |
|
4
|
|
|
|
|
7
|
|
|
4
|
|
|
|
|
22
|
|
206
|
|
|
|
|
|
|
|
207
|
|
|
|
|
|
|
sub command_whois |
208
|
|
|
|
|
|
|
: Command_description("Send a WHOIS query") |
209
|
|
|
|
|
|
|
: Command_arg('user?') |
210
|
|
|
|
|
|
|
{ |
211
|
0
|
|
|
0
|
0
|
|
my $self = shift; |
212
|
0
|
|
|
|
|
|
my ( $user, $cinv ) = @_; |
213
|
|
|
|
|
|
|
|
214
|
0
|
|
0
|
|
|
|
$user //= $self->name; |
215
|
|
|
|
|
|
|
|
216
|
0
|
|
|
|
|
|
$self->{net}->command_whois( $user, $cinv ); |
217
|
4
|
|
|
4
|
|
689
|
} |
|
4
|
|
|
|
|
7
|
|
|
4
|
|
|
|
|
12
|
|
218
|
|
|
|
|
|
|
|
219
|
|
|
|
|
|
|
sub make_widget_pre_scroller |
220
|
|
|
|
|
|
|
{ |
221
|
0
|
|
|
0
|
0
|
|
my $self = shift; |
222
|
0
|
|
|
|
|
|
my ( $box ) = @_; |
223
|
|
|
|
|
|
|
|
224
|
0
|
|
|
|
|
|
my $registry = $self->{registry}; |
225
|
|
|
|
|
|
|
|
226
|
0
|
|
|
|
|
|
my $identlabel = $registry->construct( |
227
|
|
|
|
|
|
|
"Circle::Widget::Label", |
228
|
|
|
|
|
|
|
classes => [qw( ident )], |
229
|
|
|
|
|
|
|
); |
230
|
|
|
|
|
|
|
$self->watch_property( "ident", |
231
|
0
|
|
|
0
|
|
|
on_updated => sub { $identlabel->set_prop_text( $_[1] ) } |
232
|
0
|
|
|
|
|
|
); |
233
|
|
|
|
|
|
|
|
234
|
0
|
|
|
|
|
|
$box->add( $identlabel ); |
235
|
|
|
|
|
|
|
} |
236
|
|
|
|
|
|
|
|
237
|
|
|
|
|
|
|
sub get_widget_presence |
238
|
|
|
|
|
|
|
{ |
239
|
0
|
|
|
0
|
0
|
|
my $self = shift; |
240
|
|
|
|
|
|
|
|
241
|
0
|
|
|
|
|
|
my $registry = $self->{registry}; |
242
|
0
|
|
|
|
|
|
my $presencelabel = $registry->construct( |
243
|
|
|
|
|
|
|
"Circle::Widget::Label", |
244
|
|
|
|
|
|
|
classes => [qw( presence )], |
245
|
|
|
|
|
|
|
); |
246
|
|
|
|
|
|
|
$self->watch_property( "presence", |
247
|
0
|
|
|
0
|
|
|
on_updated => sub { $presencelabel->set_prop_text( "($_[1])" ) }, |
248
|
0
|
|
|
|
|
|
); |
249
|
|
|
|
|
|
|
|
250
|
0
|
|
|
|
|
|
return $presencelabel; |
251
|
|
|
|
|
|
|
} |
252
|
|
|
|
|
|
|
|
253
|
|
|
|
|
|
|
sub get_widget_statusbar |
254
|
|
|
|
|
|
|
{ |
255
|
0
|
|
|
0
|
0
|
|
my $self = shift; |
256
|
|
|
|
|
|
|
|
257
|
0
|
|
|
|
|
|
my $registry = $self->{registry}; |
258
|
0
|
|
|
|
|
|
my $net = $self->{net}; |
259
|
|
|
|
|
|
|
|
260
|
0
|
|
|
|
|
|
my $statusbar = $registry->construct( |
261
|
|
|
|
|
|
|
"Circle::Widget::Box", |
262
|
|
|
|
|
|
|
classes => [qw( status )], |
263
|
|
|
|
|
|
|
orientation => "horizontal", |
264
|
|
|
|
|
|
|
); |
265
|
|
|
|
|
|
|
|
266
|
0
|
|
|
|
|
|
$statusbar->add( $net->get_widget_netname ); |
267
|
|
|
|
|
|
|
|
268
|
0
|
|
|
|
|
|
$statusbar->add( $self->get_widget_presence ); |
269
|
|
|
|
|
|
|
|
270
|
0
|
|
|
|
|
|
return $statusbar; |
271
|
|
|
|
|
|
|
} |
272
|
|
|
|
|
|
|
|
273
|
|
|
|
|
|
|
0x55AA; |