| 1 | package Mojo::IRC::Server::Chinese::User; | ||||||||||||||||||||||||||||||||||||||||||
| 2 | 1 | ▶ | use Mojo::IRC::Server::Chinese::Base 'Mojo::IRC::Server::Chinese::Object'; | ||||||||||||||||||||||||||||||||||||||||
|
Subroutine
BEGIN: called CC=1 SCAR=0.0
| |||||||||||||||||||||||||||||||||||||||||||
| 3 | 1 | ▶ | use List::Util qw(first); | ||||||||||||||||||||||||||||||||||||||||
|
Subroutine
BEGIN: called CC=1 SCAR=0.0
| |||||||||||||||||||||||||||||||||||||||||||
| 4 | 1 | has [qw(id name io)]; | |||||||||||||||||||||||||||||||||||||||||
| 5 | 1 | has user => '*'; | |||||||||||||||||||||||||||||||||||||||||
| 6 | 1 | has pass => undef; | |||||||||||||||||||||||||||||||||||||||||
| 7 | 1 | has nick => '*'; | |||||||||||||||||||||||||||||||||||||||||
| 8 | 1 | has mode => 'i'; | |||||||||||||||||||||||||||||||||||||||||
| 9 | 1 | has buffer => ''; | |||||||||||||||||||||||||||||||||||||||||
| 10 | 1 | has virtual => 0; | |||||||||||||||||||||||||||||||||||||||||
| 11 | 0 | ▶ | has host => sub{$_[0]->virtual?"virtualhost":"hidden"}; | ||||||||||||||||||||||||||||||||||||||||
|
Subroutine
__ANON__: not called CC=2 SCAR=13.0
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||
| 12 | 0 | ▶ | has port => sub{$_[0]->virtual?"virtualport":"hidden"}; | ||||||||||||||||||||||||||||||||||||||||
|
Subroutine
__ANON__: not called CC=2 SCAR=13.0
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||
| 13 | 0 | ▶ | has ctime => sub{time()}; | ||||||||||||||||||||||||||||||||||||||||
|
Subroutine
__ANON__: not called CC=1 SCAR=1.2
| |||||||||||||||||||||||||||||||||||||||||||
| 14 | 1 | has 'last_speak_time'; | |||||||||||||||||||||||||||||||||||||||||
| 15 | 1 | has 'last_active_time'; | |||||||||||||||||||||||||||||||||||||||||
| 16 | 1 | has ping_count => 0; | |||||||||||||||||||||||||||||||||||||||||
| 17 | 1 | has close_reason => undef; | |||||||||||||||||||||||||||||||||||||||||
| 18 | 0 | ▶ | has channel => sub{[]}; | ||||||||||||||||||||||||||||||||||||||||
|
Subroutine
__ANON__: not called CC=1 SCAR=1.2
| |||||||||||||||||||||||||||||||||||||||||||
| 19 | 1 | has realname => 'unset'; | |||||||||||||||||||||||||||||||||||||||||
| 20 | 1 | has is_quit => 0; | |||||||||||||||||||||||||||||||||||||||||
| 21 | 1 | has is_away => 0; | |||||||||||||||||||||||||||||||||||||||||
| 22 | 1 | has away_info => undef; | |||||||||||||||||||||||||||||||||||||||||
| 23 | |||||||||||||||||||||||||||||||||||||||||||
| 24 | 0 | ▶ | sub is_registered { | ||||||||||||||||||||||||||||||||||||||||
|
Subroutine
is_registered: not called CC=2 SCAR=17.9
Pod
undocumented
| |||||||||||||||||||||||||||||||||||||||||||
| 25 | 0 | my $s = shift; | |||||||||||||||||||||||||||||||||||||||||
| 26 | 0 | ▶ | if(@_==0){return $s->{is_registered}} | ||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||
| 27 | else{ | ||||||||||||||||||||||||||||||||||||||||||
| 28 | 0 | $s->{is_registered} = $_[0]; | |||||||||||||||||||||||||||||||||||||||||
| 29 | 0 | $s->{_server}->emit(user_registered=>$s); | |||||||||||||||||||||||||||||||||||||||||
| 30 | } | ||||||||||||||||||||||||||||||||||||||||||
| 31 | 0 | return $s; | |||||||||||||||||||||||||||||||||||||||||
| 32 | } | ||||||||||||||||||||||||||||||||||||||||||
| 33 | 0 | ▶ | sub is_virtual { | ||||||||||||||||||||||||||||||||||||||||
|
Subroutine
is_virtual: not called CC=1 SCAR=6.9
Pod
undocumented
| |||||||||||||||||||||||||||||||||||||||||||
| 34 | 0 | $_[0]->virtual; | |||||||||||||||||||||||||||||||||||||||||
| 35 | } | ||||||||||||||||||||||||||||||||||||||||||
| 36 | 0 | ▶ | sub away { | ||||||||||||||||||||||||||||||||||||||||
|
Subroutine
away: not called CC=1 SCAR=6.9
Pod
undocumented
| |||||||||||||||||||||||||||||||||||||||||||
| 37 | 0 | my $s = shift; | |||||||||||||||||||||||||||||||||||||||||
| 38 | 0 | my $away_info = shift; | |||||||||||||||||||||||||||||||||||||||||
| 39 | 0 | $s->send($s->serverident,"306",$s->nick,"你已经被标记为离开"); | |||||||||||||||||||||||||||||||||||||||||
| 40 | 0 | $s->is_away(1); | |||||||||||||||||||||||||||||||||||||||||
| 41 | 0 | $s->set_mode("+a"); | |||||||||||||||||||||||||||||||||||||||||
| 42 | 0 | $s->away_info($away_info); | |||||||||||||||||||||||||||||||||||||||||
| 43 | } | ||||||||||||||||||||||||||||||||||||||||||
| 44 | 0 | ▶ | sub back { | ||||||||||||||||||||||||||||||||||||||||
|
Subroutine
back: not called CC=1 SCAR=6.9
Pod
undocumented
| |||||||||||||||||||||||||||||||||||||||||||
| 45 | 0 | my $s = shift; | |||||||||||||||||||||||||||||||||||||||||
| 46 | 0 | $s->send($s->serverident,"305",$s->nick,"你不再被标记为离开"); | |||||||||||||||||||||||||||||||||||||||||
| 47 | 0 | $s->is_away(0); | |||||||||||||||||||||||||||||||||||||||||
| 48 | 0 | $s->set_mode("-a"); | |||||||||||||||||||||||||||||||||||||||||
| 49 | 0 | $s->away_info(undef); | |||||||||||||||||||||||||||||||||||||||||
| 50 | } | ||||||||||||||||||||||||||||||||||||||||||
| 51 | 0 | ▶ | sub quit{ | ||||||||||||||||||||||||||||||||||||||||
|
Subroutine
quit: not called CC=3 SCAR=24.8
Pod
undocumented
| |||||||||||||||||||||||||||||||||||||||||||
| 52 | 0 | my $s = shift; | |||||||||||||||||||||||||||||||||||||||||
| 53 | 0 | ▶ | my $quit_reason = shift || ""; | ||||||||||||||||||||||||||||||||||||||||
|
Condition0%0/2
shift() || ''
MC/DC0%0/1
shift() || ''
shift()
Truth table0%0/2
A
A= shift()
| |||||||||||||||||||||||||||||||||||||||||||
| 54 | 0 | $s->broadcast($s->ident,"QUIT",$quit_reason); | |||||||||||||||||||||||||||||||||||||||||
| 55 | 0 | $s->info("[" . $s->name . "] 已退出($quit_reason)"); | |||||||||||||||||||||||||||||||||||||||||
| 56 | 0 | ▶ | $s->io->close_gracefully() if not $s->is_virtual; | ||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||
| 57 | 0 | $s->{_server}->remove_user($s); | |||||||||||||||||||||||||||||||||||||||||
| 58 | } | ||||||||||||||||||||||||||||||||||||||||||
| 59 | 0 | ▶ | sub ident{ | ||||||||||||||||||||||||||||||||||||||||
|
Subroutine
ident: not called CC=1 SCAR=6.9
Pod
undocumented
| |||||||||||||||||||||||||||||||||||||||||||
| 60 | 0 | my $s = shift; | |||||||||||||||||||||||||||||||||||||||||
| 61 | 0 | return $s->nick . '!' . $s->user . '@' . $s->host; | |||||||||||||||||||||||||||||||||||||||||
| 62 | } | ||||||||||||||||||||||||||||||||||||||||||
| 63 | 0 | ▶ | sub set_nick{ | ||||||||||||||||||||||||||||||||||||||||
|
Subroutine
set_nick: not called CC=13 SCAR=52.0
Pod
undocumented
| |||||||||||||||||||||||||||||||||||||||||||
| 64 | 0 | my $s = shift; | |||||||||||||||||||||||||||||||||||||||||
| 65 | 0 | my $nick = shift; | |||||||||||||||||||||||||||||||||||||||||
| 66 | 0 | $nick =~s/\s|\@|!//g; | |||||||||||||||||||||||||||||||||||||||||
| 67 | 0 | my $user = $s->search_user(nick=>$nick); | |||||||||||||||||||||||||||||||||||||||||
| 68 | 0 | ▶ | if(defined $user and $user->id ne $s->id){ | ||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
Condition0%0/3
defined $user and $user->id ne $s->id
MC/DC0%0/2
defined $user and $user->id ne $s->id
defined $user
$user->id ne $s->id
Truth table0%0/3
A and B
A= defined $userB= $user->id ne $s->id
| |||||||||||||||||||||||||||||||||||||||||||
| 69 | 0 | ▶ | if($user->is_virtual){ | ||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||
| 70 | 0 | $user->quit("虚拟帐号被移除"); | |||||||||||||||||||||||||||||||||||||||||
| 71 | 0 | ▶ | $s->once(close=>sub{$s->{_server}->add_user($user)}); | ||||||||||||||||||||||||||||||||||||||||
|
Subroutine
__ANON__: not called CC=1 SCAR=6.9
| |||||||||||||||||||||||||||||||||||||||||||
| 72 | 0 | $s->broadcast($s->ident,NICK => $nick); | |||||||||||||||||||||||||||||||||||||||||
| 73 | 0 | $s->info("[" . $s->nick . "] 修改昵称为 [$nick]"); | |||||||||||||||||||||||||||||||||||||||||
| 74 | 0 | $s->nick($nick); | |||||||||||||||||||||||||||||||||||||||||
| 75 | 0 | $s->name($nick); | |||||||||||||||||||||||||||||||||||||||||
| 76 | 0 | ▶ | if(!$s->is_registered and $s->nick ne "*" and $s->user ne "*"){ | ||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
Condition0%0/6
not $s->is_registered and $s->nick ne "*" and $s->user ne "*"
not $s->is_registered and $s->nick ne "*"
MC/DC0%0/3
not $s->is_registered and $s->nick ne "*" and $s->user ne "*"
not $s->is_registered
$s->nick ne "*"
$s->user ne "*"
Truth table0%0/4
not(A) and B and C
A= not $s->is_registeredB= $s->nick ne "*"C= $s->user ne "*"
| |||||||||||||||||||||||||||||||||||||||||||
| 77 | 0 | $s->is_registered(1); | |||||||||||||||||||||||||||||||||||||||||
| 78 | } | ||||||||||||||||||||||||||||||||||||||||||
| 79 | } | ||||||||||||||||||||||||||||||||||||||||||
| 80 | else{ | ||||||||||||||||||||||||||||||||||||||||||
| 81 | 0 | $s->send($s->serverident,"433",$s->nick,$nick,'昵称已经被使用'); | |||||||||||||||||||||||||||||||||||||||||
| 82 | 0 | $s->info("昵称 [$nick] 已经被使用"); | |||||||||||||||||||||||||||||||||||||||||
| 83 | } | ||||||||||||||||||||||||||||||||||||||||||
| 84 | } | ||||||||||||||||||||||||||||||||||||||||||
| 85 | else{ | ||||||||||||||||||||||||||||||||||||||||||
| 86 | 0 | ▶ | if(defined $s->{_server}->auth and ref $s->{_server}->auth eq "CODE"){ | ||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
Condition0%0/3
defined $s->{"_server"}->auth and ref $s->{"_server"}->auth eq "CODE"
MC/DC0%0/2
defined $s->{"_server"}->auth and ref $s->{"_server"}->auth eq "CODE"
defined $s->{"_server"}->auth
ref $s->{"_server"}->auth eq "CODE"
Truth table0%0/3
A and B
A= defined $s->{"_server"}->authB= ref $s->{"_server"}->auth eq "CODE"
| |||||||||||||||||||||||||||||||||||||||||||
| 87 | 0 | ▶ | if(! $s->{_server}->auth->($nick,$s->user,$s->pass)){ | ||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||
| 88 | 0 | $s->send($s->serverident,"464",$s->nick,"认证失败"); | |||||||||||||||||||||||||||||||||||||||||
| 89 | 0 | return; | |||||||||||||||||||||||||||||||||||||||||
| 90 | } | ||||||||||||||||||||||||||||||||||||||||||
| 91 | } | ||||||||||||||||||||||||||||||||||||||||||
| 92 | 0 | $s->broadcast($s->ident,NICK => $nick); | |||||||||||||||||||||||||||||||||||||||||
| 93 | 0 | $s->info("[" . $s->nick . "] 修改昵称为 [$nick]"); | |||||||||||||||||||||||||||||||||||||||||
| 94 | 0 | $s->nick($nick); | |||||||||||||||||||||||||||||||||||||||||
| 95 | 0 | $s->name($nick); | |||||||||||||||||||||||||||||||||||||||||
| 96 | 0 | ▶ | if(!$s->is_registered and $s->nick ne "*" and $s->user ne "*"){ | ||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
Condition0%0/6
not $s->is_registered and $s->nick ne "*" and $s->user ne "*"
not $s->is_registered and $s->nick ne "*"
MC/DC0%0/3
not $s->is_registered and $s->nick ne "*" and $s->user ne "*"
not $s->is_registered
$s->nick ne "*"
$s->user ne "*"
Truth table0%0/4
not(A) and B and C
A= not $s->is_registeredB= $s->nick ne "*"C= $s->user ne "*"
| |||||||||||||||||||||||||||||||||||||||||||
| 97 | 0 | $s->is_registered(1); | |||||||||||||||||||||||||||||||||||||||||
| 98 | } | ||||||||||||||||||||||||||||||||||||||||||
| 99 | } | ||||||||||||||||||||||||||||||||||||||||||
| 100 | } | ||||||||||||||||||||||||||||||||||||||||||
| 101 | 0 | ▶ | sub set_mode{ | ||||||||||||||||||||||||||||||||||||||||
|
Subroutine
set_mode: not called CC=6 SCAR=37.4
Pod
undocumented
| |||||||||||||||||||||||||||||||||||||||||||
| 102 | 0 | my $s = shift; | |||||||||||||||||||||||||||||||||||||||||
| 103 | 0 | my $mode = shift; | |||||||||||||||||||||||||||||||||||||||||
| 104 | 0 | my %mode = map {$_=>1} split //,$s->mode; | |||||||||||||||||||||||||||||||||||||||||
| 105 | 0 | ▶ | if(substr($mode,0,1) eq "+"){ | ||||||||||||||||||||||||||||||||||||||||
|
Branch: 2 branches
| |||||||||||||||||||||||||||||||||||||||||||
| 106 | 0 | $mode{$_}=1 for split //,substr($mode,1,); | |||||||||||||||||||||||||||||||||||||||||
| 107 | } | ||||||||||||||||||||||||||||||||||||||||||
| 108 | elsif(substr($mode,0,1) eq "-"){ | ||||||||||||||||||||||||||||||||||||||||||
| 109 | 0 | delete $mode{$_} for split //,substr($mode,1,); | |||||||||||||||||||||||||||||||||||||||||
| 110 | } | ||||||||||||||||||||||||||||||||||||||||||
| 111 | else{ | ||||||||||||||||||||||||||||||||||||||||||
| 112 | 0 | %mode = (); | |||||||||||||||||||||||||||||||||||||||||
| 113 | 0 | $mode{$_}=1 for split //,$mode; | |||||||||||||||||||||||||||||||||||||||||
| 114 | } | ||||||||||||||||||||||||||||||||||||||||||
| 115 | 0 | $s->mode(join "",keys %mode); | |||||||||||||||||||||||||||||||||||||||||
| 116 | 0 | $s->send($s->ident,"MODE",$s->nick,$mode); | |||||||||||||||||||||||||||||||||||||||||
| 117 | 0 | $s->info("[" . $s->nick . "] 模式设置为: " . $s->mode); | |||||||||||||||||||||||||||||||||||||||||
| 118 | } | ||||||||||||||||||||||||||||||||||||||||||
| 119 | 0 | ▶ | sub join_channel{ | ||||||||||||||||||||||||||||||||||||||||
|
Subroutine
join_channel: not called CC=4 SCAR=30.0
Pod
undocumented
| |||||||||||||||||||||||||||||||||||||||||||
| 120 | 0 | my $s = shift; | |||||||||||||||||||||||||||||||||||||||||
| 121 | 0 | my $channel; | |||||||||||||||||||||||||||||||||||||||||
| 122 | 0 | ▶ | $channel = ref($_[0]) eq "Mojo::IRC::Server::Chinese::Channel"?$_[0]:$s->search_channel(id=>$_[0]); | ||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||
| 123 | 0 | ▶ | return if not defined $channel; | ||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||
| 124 | 0 | ▶ | if(not $s->is_join_channel($channel->id)){ | ||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||
| 125 | 0 | push @{$s->channel},$channel->id; | |||||||||||||||||||||||||||||||||||||||||
| 126 | 0 | $channel->add_user($s->id); | |||||||||||||||||||||||||||||||||||||||||
| 127 | 0 | $channel->broadcast($s->ident,"JOIN",$channel->name); | |||||||||||||||||||||||||||||||||||||||||
| 128 | } | ||||||||||||||||||||||||||||||||||||||||||
| 129 | 0 | else{$s->send($s->ident,"JOIN",$channel->name);} | |||||||||||||||||||||||||||||||||||||||||
| 130 | 0 | $s->send($s->serverident,"332",$s->nick,$channel->name,$channel->topic); | |||||||||||||||||||||||||||||||||||||||||
| 131 | 0 | $s->send($s->serverident,"353",$s->nick,'=',$channel->name,join " ",map {$_->nick} $channel->users); | |||||||||||||||||||||||||||||||||||||||||
| 132 | 0 | $s->send($s->serverident,"366",$s->nick,$channel->name,"End of NAMES list"); | |||||||||||||||||||||||||||||||||||||||||
| 133 | #$s->send($s->serverident,"329",$s->nick,$channel->name,$channel->ctime); | ||||||||||||||||||||||||||||||||||||||||||
| 134 | 0 | $s->info("[" . $s->name . "] 加入频道 " . $channel->name); | |||||||||||||||||||||||||||||||||||||||||
| 135 | } | ||||||||||||||||||||||||||||||||||||||||||
| 136 | 0 | ▶ | sub part_channel{ | ||||||||||||||||||||||||||||||||||||||||
|
Subroutine
part_channel: not called CC=5 SCAR=34.0
Pod
undocumented
| |||||||||||||||||||||||||||||||||||||||||||
| 137 | 0 | my $s = shift; | |||||||||||||||||||||||||||||||||||||||||
| 138 | 0 | ▶ | my $channel = ref($_[0]) eq "Mojo::IRC::Server::Chinese::Channel"?$_[0]:$s->search_channel(id=>$_[0]); | ||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||
| 139 | 0 | my $part_info = $_[1]; | |||||||||||||||||||||||||||||||||||||||||
| 140 | 0 | ▶ | return if not defined $channel; | ||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||
| 141 | 0 | $channel->broadcast($s->ident,"PART",$channel->name,$part_info); | |||||||||||||||||||||||||||||||||||||||||
| 142 | 0 | ▶ | for(my $i=0;$i<@{$s->channel};$i++){ | ||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||
| 143 | 0 | ▶ | if($channel->id eq $s->channel->[$i]){ | ||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||
| 144 | 0 | splice @{$s->channel},$i,1; | |||||||||||||||||||||||||||||||||||||||||
| 145 | 0 | last; | |||||||||||||||||||||||||||||||||||||||||
| 146 | } | ||||||||||||||||||||||||||||||||||||||||||
| 147 | } | ||||||||||||||||||||||||||||||||||||||||||
| 148 | 0 | $channel->remove_user($s->id); | |||||||||||||||||||||||||||||||||||||||||
| 149 | 0 | $s->info("[" . $s->nick . "] 离开频道 " . $channel->name); | |||||||||||||||||||||||||||||||||||||||||
| 150 | |||||||||||||||||||||||||||||||||||||||||||
| 151 | } | ||||||||||||||||||||||||||||||||||||||||||
| 152 | 0 | ▶ | sub is_join_channel{ | ||||||||||||||||||||||||||||||||||||||||
|
Subroutine
is_join_channel: not called CC=4 SCAR=30.0
Pod
undocumented
| |||||||||||||||||||||||||||||||||||||||||||
| 153 | 0 | my $s = shift; | |||||||||||||||||||||||||||||||||||||||||
| 154 | 0 | ▶ | my $cid = ref($_[0]) eq "Mojo::IRC::Server::Chinese::Channel"?$_[0]->id:$_[0]; | ||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||
| 155 | 0 | ▶ | if(defined $cid){ | ||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||
| 156 | 0 | ▶ | return (first {$cid eq $_} @{$s->channel})?1:0; | ||||||||||||||||||||||||||||||||||||||||
|
Subroutine
__ANON__: not called CC=1 SCAR=6.9
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||
| 157 | } | ||||||||||||||||||||||||||||||||||||||||||
| 158 | else{ | ||||||||||||||||||||||||||||||||||||||||||
| 159 | 0 | return 0+@{$s->channel}; | |||||||||||||||||||||||||||||||||||||||||
| 160 | } | ||||||||||||||||||||||||||||||||||||||||||
| 161 | } | ||||||||||||||||||||||||||||||||||||||||||
| 162 | 0 | ▶ | sub forward{ | ||||||||||||||||||||||||||||||||||||||||
|
Subroutine
forward: not called CC=5 SCAR=34.0
Pod
undocumented
| |||||||||||||||||||||||||||||||||||||||||||
| 163 | 0 | my $s = shift; | |||||||||||||||||||||||||||||||||||||||||
| 164 | 0 | my %unique; | |||||||||||||||||||||||||||||||||||||||||
| 165 | 0 | for my $channel ($s->channels){ | |||||||||||||||||||||||||||||||||||||||||
| 166 | 0 | for my $user ($channel->users){ | |||||||||||||||||||||||||||||||||||||||||
| 167 | 0 | ▶ | next if $user->id eq $s->id; | ||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||
| 168 | 0 | ▶ | next if exists $unique{$user->id}; | ||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||
| 169 | 0 | $user->send(@_); | |||||||||||||||||||||||||||||||||||||||||
| 170 | 0 | $unique{$user->id} = 1; | |||||||||||||||||||||||||||||||||||||||||
| 171 | } | ||||||||||||||||||||||||||||||||||||||||||
| 172 | } | ||||||||||||||||||||||||||||||||||||||||||
| 173 | } | ||||||||||||||||||||||||||||||||||||||||||
| 174 | |||||||||||||||||||||||||||||||||||||||||||
| 175 | 0 | ▶ | sub broadcast{ | ||||||||||||||||||||||||||||||||||||||||
|
Subroutine
broadcast: not called CC=5 SCAR=34.0
Pod
undocumented
| |||||||||||||||||||||||||||||||||||||||||||
| 176 | 0 | my $s = shift; | |||||||||||||||||||||||||||||||||||||||||
| 177 | 0 | $s->send(@_); | |||||||||||||||||||||||||||||||||||||||||
| 178 | 0 | my %unique; | |||||||||||||||||||||||||||||||||||||||||
| 179 | 0 | for my $channel ($s->channels){ | |||||||||||||||||||||||||||||||||||||||||
| 180 | 0 | for my $user ($channel->users){ | |||||||||||||||||||||||||||||||||||||||||
| 181 | 0 | ▶ | next if $user->id eq $s->id; | ||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||
| 182 | 0 | ▶ | next if exists $unique{$user->id}; | ||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||
| 183 | 0 | $user->send(@_); | |||||||||||||||||||||||||||||||||||||||||
| 184 | 0 | $unique{$user->id} = 1; | |||||||||||||||||||||||||||||||||||||||||
| 185 | } | ||||||||||||||||||||||||||||||||||||||||||
| 186 | } | ||||||||||||||||||||||||||||||||||||||||||
| 187 | } | ||||||||||||||||||||||||||||||||||||||||||
| 188 | 0 | ▶ | sub channels{ | ||||||||||||||||||||||||||||||||||||||||
|
Subroutine
channels: not called CC=3 SCAR=24.8
Pod
undocumented
| |||||||||||||||||||||||||||||||||||||||||||
| 189 | 0 | my $s = shift; | |||||||||||||||||||||||||||||||||||||||||
| 190 | 0 | my @channels = (); | |||||||||||||||||||||||||||||||||||||||||
| 191 | 0 | for my $cid (@{$s->channel}){ | |||||||||||||||||||||||||||||||||||||||||
| 192 | 0 | my $channel = $s->search_channel(id=>$cid); | |||||||||||||||||||||||||||||||||||||||||
| 193 | 0 | ▶ | push @channels ,$channel if defined $channel; | ||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||
| 194 | } | ||||||||||||||||||||||||||||||||||||||||||
| 195 | 0 | return @channels; | |||||||||||||||||||||||||||||||||||||||||
| 196 | } | ||||||||||||||||||||||||||||||||||||||||||
| 197 | 0 | ▶ | sub each_channel{ | ||||||||||||||||||||||||||||||||||||||||
|
Subroutine
each_channel: not called CC=4 SCAR=30.0
Pod
undocumented
| |||||||||||||||||||||||||||||||||||||||||||
| 198 | 0 | my $s = shift; | |||||||||||||||||||||||||||||||||||||||||
| 199 | 0 | my $callback = shift; | |||||||||||||||||||||||||||||||||||||||||
| 200 | 0 | ▶ | return if not $s->is_join_channel(); | ||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||
| 201 | 0 | for my $cid (@{$s->channel}){ | |||||||||||||||||||||||||||||||||||||||||
| 202 | 0 | my $channel = $s->search_channel(id=>$cid); | |||||||||||||||||||||||||||||||||||||||||
| 203 | 0 | ▶ | $callback->($s,$channel,@_) if defined $channel; | ||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||
| 204 | } | ||||||||||||||||||||||||||||||||||||||||||
| 205 | } | ||||||||||||||||||||||||||||||||||||||||||
| 206 | |||||||||||||||||||||||||||||||||||||||||||
| 207 | 0 | ▶ | sub send{ | ||||||||||||||||||||||||||||||||||||||||
|
Subroutine
send: not called CC=5 SCAR=34.0
Pod
undocumented
| |||||||||||||||||||||||||||||||||||||||||||
| 208 | 0 | my $s = shift; | |||||||||||||||||||||||||||||||||||||||||
| 209 | 0 | ▶ | return if $s->is_virtual ; | ||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||
| 210 | 0 | my($prefix,$command,@params)=@_; | |||||||||||||||||||||||||||||||||||||||||
| 211 | 0 | my $msg = ""; | |||||||||||||||||||||||||||||||||||||||||
| 212 | 0 | ▶ | $msg .= defined $prefix ? ":$prefix " : ""; | ||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||
| 213 | 0 | $msg .= $command; | |||||||||||||||||||||||||||||||||||||||||
| 214 | 0 | my $trail; | |||||||||||||||||||||||||||||||||||||||||
| 215 | 0 | $trail = pop @params; | |||||||||||||||||||||||||||||||||||||||||
| 216 | 0 | $msg .= " $_" for @params; | |||||||||||||||||||||||||||||||||||||||||
| 217 | 0 | ▶ | $msg .= defined $trail ? " :$trail" : ""; | ||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||
| 218 | 0 | $msg .= "\r\n"; | |||||||||||||||||||||||||||||||||||||||||
| 219 | 0 | $s->io->write($msg); | |||||||||||||||||||||||||||||||||||||||||
| 220 | 0 | $s->debug("S[".$s->name."] $msg"); | |||||||||||||||||||||||||||||||||||||||||
| 221 | } | ||||||||||||||||||||||||||||||||||||||||||
| 222 | 0 | ▶ | sub is_localhost{ | ||||||||||||||||||||||||||||||||||||||||
|
Subroutine
is_localhost: not called CC=3 SCAR=24.8
Pod
undocumented
| |||||||||||||||||||||||||||||||||||||||||||
| 223 | 0 | my $s = shift; | |||||||||||||||||||||||||||||||||||||||||
| 224 | 0 | ▶ | return 0 if $s->is_virtual; | ||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||
| 225 | 0 | ▶ | return 1 if $s->io->handle->peerhost eq "127.0.0.1"; | ||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||
| 226 | } | ||||||||||||||||||||||||||||||||||||||||||
| 227 | 1 | 1; | |||||||||||||||||||||||||||||||||||||||||