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