blib/lib/Circle/Net/IRC/User.pm

filter: Statementstmt 21.7% 23 / 106 Branchbran 0.0% 0 / 10 Conditioncond 0.0% 0 / 12 MC/DCmcdc 0.0% 0 / 7 Subroutinesub 35.0% 7 / 20 Podpod 0.0% 0 / 12 totaltotal 17.9% 30 / 167 SCAR 41.8
CC
10
Cov
18%
on_message_RPL_AWAY
30.0
update_ident
12.0
on_message
6.0
CRAP 65.2
« blib/lib/Circle/Net/Raw.pm ↑ Summary blib/lib/Circle/Rule/Resultset.pm »
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 ▶use strict;
Subroutine BEGIN: called CC=1 SCAR=0.0
8 4 ▶use warnings;
Subroutine BEGIN: called CC=1 SCAR=0.0
9 4 ▶use base qw( Circle::Net::IRC::Target );
Subroutine BEGIN: called CC=1 SCAR=0.0
10  
11 4 ▶use Carp;
Subroutine BEGIN: called CC=1 SCAR=0.0
12  
13 # Don't reprint RPL_USERISAWAY message within 1 hour
14 # TODO: Some sort of config setting system
15 4 my $awaytime_print = 3600;
16  
17 sub default_message_level
18 {
19 0 ▶ my $self = shift;
Subroutine default_message_level: not called CC=1 SCAR=6.9
Pod undocumented
20 0 my ( $hints ) = @_;
21  
22 0 return 3;
23 }
24  
25 sub on_message
26 {
27 0 ▶ my $self = shift;
Subroutine on_message: not called CC=2 SCAR=17.9
Pod undocumented
28 0 my ( $command, $message, $hints ) = @_;
29  
30 # Messages from the user will have a prefix_user hint, server messages will not.
31 0 ▶ if( defined( my $ident = $hints->{prefix_user} ) ) {
Branch: 1 branch
BranchTrueFalseTotal
if (defined(my $ident = $hints->{"prefix_user"})) 0 0 0
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 ▶ my $self = shift;
Subroutine update_ident: not called CC=3 SCAR=24.8
Pod undocumented
43 0 my ( $ident ) = @_;
44  
45 0 ▶ return if defined $self->get_prop_ident and $self->get_prop_ident eq $ident;
Branch: 1 branch
BranchTrueFalseTotal
if defined $self->get_prop_ident and $self->get_prop_ident eq $ident 0 0 0
Condition0%0/3
defined $self->get_prop_ident and $self->get_prop_ident eq $ident
!ll&&!rl&&r
000
MC/DC0%0/2
defined $self->get_prop_ident and $self->get_prop_ident eq $ident
defined $self->get_prop_ident $self->get_prop_ident eq $ident
Truth table0%0/3
A and B
A= defined $self->get_prop_identB= $self->get_prop_ident eq $ident
ABresult
0X0
100
111
46 0 $self->set_prop_ident( $ident );
47 }
48  
49 sub on_message_NICK
50 {
51 0 ▶ my $self = shift;
Subroutine on_message_NICK: not called CC=1 SCAR=6.9
Pod undocumented
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 ▶ my $self = shift;
Subroutine on_message_QUIT: not called CC=2 SCAR=17.9
Pod undocumented
73 0 my ( $message, $hints ) = @_;
74  
75 0 my $nick = $self->name;
76 0 my $quitmsg = $hints->{text};
77  
78 0 ▶ defined $quitmsg or $quitmsg = "";
Branch: 1 branch
BranchTrueFalseTotal
defined $quitmsg or $quitmsg = "" 0 0 0
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 ▶ my $self = shift;
Subroutine on_message_RPL_AWAY: not called CC=5 SCAR=34.0
Pod undocumented
94 0 my ( $message, $hints ) = @_;
95  
96 0 my $nick = $self->name;
97 0 my $awaymsg = $hints->{text};
98  
99 0 ▶ defined $awaymsg or $awaymsg = "";
Branch: 1 branch
BranchTrueFalseTotal
defined $awaymsg or $awaymsg = "" 0 0 0
100  
101 # Surpress the message if it's already been printed and it's quite soon
102 0 my $now = time;
103 0 ▶ if( defined $self->{printed_awaymsg} and
Branch: 1 branch
BranchTrueFalseTotal
if (defined $self->{"printed_awaymsg"} and $self->{"printed_awaymsg"} eq $awaymsg and $now < $self->{"printed_awaytime"} + $awaytime_print) 0 0 0
Condition0%0/6
defined $self->{"printed_awaymsg"} and $self->{"printed_awaymsg"} eq $awaymsg and $now < $self->{"printed_awaytime"} + $awaytime_print
!ll&&!rl&&r
000
defined $self->{"printed_awaymsg"} and $self->{"printed_awaymsg"} eq $awaymsg
!ll&&!rl&&r
000
MC/DC0%0/3
defined $self->{"printed_awaymsg"} and $self->{"printed_awaymsg"} eq $awaymsg and $now < $self->{"printed_awaytime"} + $awaytime_print
defined $self->{"printed_awaymsg"} $self->{"printed_awaymsg"} eq $awaymsg $now < $self->{"printed_awaytime"} + $awaytime_print
Truth table0%0/4
A and B and C
A= defined $self->{"printed_awaymsg"}B= $self->{"printed_awaymsg"} eq $awaymsgC= $now < $self->{"printed_awaytime"} + $awaytime_print
ABCresult
0XX0
10X0
1100
1111
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 ▶ my $self = shift;
Subroutine on_message_whois: not called CC=1 SCAR=6.9
Pod undocumented
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 ▶ my $self = shift;
Subroutine command_close: not called CC=1 SCAR=6.9
Pod undocumented
137  
138 0 $self->destroy;
139 4 ▶}
Subroutine BEGIN: called CC=1 SCAR=0.0
140  
141 sub command_requery
142 : Command_description("Change the target nick for this user query")
143 : Command_arg('newnick')
144 {
145 0 ▶ my $self = shift;
Subroutine command_requery: not called CC=1 SCAR=6.9
Pod undocumented
146 0 my ( $newnick ) = @_;
147  
148 0 my $oldnick = $self->name;
149  
150 0 $self->set_prop_name( $newnick );
151 0 $self->set_prop_tag( $newnick );
152  
153 0 my $oldnick_folded = $self->{irc}->casefold_name( $oldnick );
154 0 my $newnick_folded = $self->{irc}->casefold_name( $newnick );
155  
156 0 $self->fire_event( "change_nick", $oldnick, $oldnick_folded, $newnick, $newnick_folded );
157  
158 0 return ( "Now talking to $newnick" );
159 4 ▶}
Subroutine BEGIN: called CC=1 SCAR=0.0
160  
161 sub command_whois
162 : Command_description("Send a WHOIS query")
163 : Command_arg('user?')
164 {
165 0 ▶ my $self = shift;
Subroutine command_whois: not called CC=2 SCAR=17.9
Pod undocumented
166 0 my ( $user, $cinv ) = @_;
167  
168 0 ▶ $user //= $self->name;
Condition0%0/3
$user //= $self->name
l!l&&r!l&&!r
000
MC/DC0%0/2
$user //= $self->name
$user $self->name
Truth table0%0/3
A //= B
A= $userB= $self->name
ABresult
1X1
011
000
169  
170 0 $self->{net}->command_whois( $user, $cinv );
171 4 ▶}
Subroutine BEGIN: called CC=1 SCAR=0.0
172  
173 sub make_widget_pre_scroller
174 {
175 0 ▶ my $self = shift;
Subroutine make_widget_pre_scroller: not called CC=1 SCAR=6.9
Pod undocumented
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 ▶ on_updated => sub { $identlabel->set_prop_text( $_[1] ) }
Subroutine __ANON__: not called CC=1 SCAR=6.9
186 0 );
187  
188 0 $box->add( $identlabel );
189 }
190  
191 sub get_widget_statusbar
192 {
193 0 ▶ my $self = shift;
Subroutine get_widget_statusbar: not called CC=1 SCAR=6.9
Pod undocumented
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 4 0x55AA;
« blib/lib/Circle/Net/Raw.pm ↑ Summary blib/lib/Circle/Rule/Resultset.pm »