| 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-2014 -- leonerd@leonerd.org.uk |
|
4
|
|
|
|
|
|
|
|
|
5
|
|
|
|
|
|
|
package Circle::Net::IRC::User; |
|
6
|
|
|
|
|
|
|
|
|
7
|
4
|
|
|
4
|
|
24
|
use strict; |
|
|
4
|
|
|
|
|
11
|
|
|
|
4
|
|
|
|
|
162
|
|
|
8
|
4
|
|
|
4
|
|
22
|
use warnings; |
|
|
4
|
|
|
|
|
8
|
|
|
|
4
|
|
|
|
|
1308
|
|
|
9
|
4
|
|
|
4
|
|
26
|
use base qw( Circle::Net::IRC::Target ); |
|
|
4
|
|
|
|
|
7
|
|
|
|
4
|
|
|
|
|
413
|
|
|
10
|
|
|
|
|
|
|
|
|
11
|
4
|
|
|
4
|
|
23
|
use Carp; |
|
|
4
|
|
|
|
|
7
|
|
|
|
4
|
|
|
|
|
3203
|
|
|
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
|
|
|
|
|
|
|
# Send it back |
|
124
|
|
|
|
|
|
|
sub on_message_whois |
|
125
|
|
|
|
|
|
|
{ |
|
126
|
0
|
|
|
0
|
0
|
|
my $self = shift; |
|
127
|
0
|
|
|
|
|
|
my ( $message, $hints ) = @_; |
|
128
|
|
|
|
|
|
|
|
|
129
|
0
|
|
|
|
|
|
my $net = $self->{net}; |
|
130
|
0
|
|
|
|
|
|
$net->on_message_whois( $message, $hints ); |
|
131
|
|
|
|
|
|
|
} |
|
132
|
|
|
|
|
|
|
|
|
133
|
|
|
|
|
|
|
sub command_close |
|
134
|
|
|
|
|
|
|
: Command_description("Close the window") |
|
135
|
|
|
|
|
|
|
{ |
|
136
|
0
|
|
|
0
|
0
|
0
|
my $self = shift; |
|
137
|
|
|
|
|
|
|
|
|
138
|
0
|
|
|
|
|
0
|
$self->destroy; |
|
139
|
4
|
|
|
4
|
|
25
|
} |
|
|
4
|
|
|
|
|
7
|
|
|
|
4
|
|
|
|
|
34
|
|
|
140
|
|
|
|
|
|
|
|
|
141
|
|
|
|
|
|
|
sub command_requery |
|
142
|
|
|
|
|
|
|
: Command_description("Change the target nick for this user query") |
|
143
|
|
|
|
|
|
|
: Command_arg('newnick') |
|
144
|
|
|
|
|
|
|
{ |
|
145
|
0
|
|
|
0
|
0
|
0
|
my $self = shift; |
|
146
|
0
|
|
|
|
|
0
|
my ( $newnick ) = @_; |
|
147
|
|
|
|
|
|
|
|
|
148
|
0
|
|
|
|
|
0
|
my $oldnick = $self->name; |
|
149
|
|
|
|
|
|
|
|
|
150
|
0
|
|
|
|
|
0
|
$self->set_prop_name( $newnick ); |
|
151
|
0
|
|
|
|
|
0
|
$self->set_prop_tag( $newnick ); |
|
152
|
|
|
|
|
|
|
|
|
153
|
0
|
|
|
|
|
0
|
my $oldnick_folded = $self->{irc}->casefold_name( $oldnick ); |
|
154
|
0
|
|
|
|
|
0
|
my $newnick_folded = $self->{irc}->casefold_name( $newnick ); |
|
155
|
|
|
|
|
|
|
|
|
156
|
0
|
|
|
|
|
0
|
$self->fire_event( "change_nick", $oldnick, $oldnick_folded, $newnick, $newnick_folded ); |
|
157
|
|
|
|
|
|
|
|
|
158
|
0
|
|
|
|
|
0
|
return ( "Now talking to $newnick" ); |
|
159
|
4
|
|
|
4
|
|
1292
|
} |
|
|
4
|
|
|
|
|
10
|
|
|
|
4
|
|
|
|
|
18
|
|
|
160
|
|
|
|
|
|
|
|
|
161
|
|
|
|
|
|
|
sub command_whois |
|
162
|
|
|
|
|
|
|
: Command_description("Send a WHOIS query") |
|
163
|
|
|
|
|
|
|
: Command_arg('user?') |
|
164
|
|
|
|
|
|
|
{ |
|
165
|
0
|
|
|
0
|
0
|
|
my $self = shift; |
|
166
|
0
|
|
|
|
|
|
my ( $user, $cinv ) = @_; |
|
167
|
|
|
|
|
|
|
|
|
168
|
0
|
|
0
|
|
|
|
$user //= $self->name; |
|
169
|
|
|
|
|
|
|
|
|
170
|
0
|
|
|
|
|
|
$self->{net}->command_whois( $user, $cinv ); |
|
171
|
4
|
|
|
4
|
|
958
|
} |
|
|
4
|
|
|
|
|
7
|
|
|
|
4
|
|
|
|
|
18
|
|
|
172
|
|
|
|
|
|
|
|
|
173
|
|
|
|
|
|
|
sub make_widget_pre_scroller |
|
174
|
|
|
|
|
|
|
{ |
|
175
|
0
|
|
|
0
|
0
|
|
my $self = shift; |
|
176
|
0
|
|
|
|
|
|
my ( $box ) = @_; |
|
177
|
|
|
|
|
|
|
|
|
178
|
0
|
|
|
|
|
|
my $registry = $self->{registry}; |
|
179
|
|
|
|
|
|
|
|
|
180
|
0
|
|
|
|
|
|
my $identlabel = $registry->construct( |
|
181
|
|
|
|
|
|
|
"Circle::Widget::Label", |
|
182
|
|
|
|
|
|
|
classes => [qw( ident )], |
|
183
|
|
|
|
|
|
|
); |
|
184
|
|
|
|
|
|
|
$self->watch_property( "ident", |
|
185
|
0
|
|
|
0
|
|
|
on_updated => sub { $identlabel->set_prop_text( $_[1] ) } |
|
186
|
0
|
|
|
|
|
|
); |
|
187
|
|
|
|
|
|
|
|
|
188
|
0
|
|
|
|
|
|
$box->add( $identlabel ); |
|
189
|
|
|
|
|
|
|
} |
|
190
|
|
|
|
|
|
|
|
|
191
|
|
|
|
|
|
|
sub get_widget_statusbar |
|
192
|
|
|
|
|
|
|
{ |
|
193
|
0
|
|
|
0
|
0
|
|
my $self = shift; |
|
194
|
|
|
|
|
|
|
|
|
195
|
0
|
|
|
|
|
|
my $registry = $self->{registry}; |
|
196
|
0
|
|
|
|
|
|
my $net = $self->{net}; |
|
197
|
|
|
|
|
|
|
|
|
198
|
0
|
|
|
|
|
|
my $statusbar = $registry->construct( |
|
199
|
|
|
|
|
|
|
"Circle::Widget::Box", |
|
200
|
|
|
|
|
|
|
classes => [qw( status )], |
|
201
|
|
|
|
|
|
|
orientation => "horizontal", |
|
202
|
|
|
|
|
|
|
); |
|
203
|
|
|
|
|
|
|
|
|
204
|
0
|
|
|
|
|
|
$statusbar->add( $net->get_widget_netname ); |
|
205
|
|
|
|
|
|
|
|
|
206
|
0
|
|
|
|
|
|
return $statusbar; |
|
207
|
|
|
|
|
|
|
} |
|
208
|
|
|
|
|
|
|
|
|
209
|
|
|
|
|
|
|
0x55AA; |