Webqq/Model.pm

filter: Statementstmt 11.9% 115 / 964 Branchbran 0.0% 0 / 412 Conditioncond 0.0% 0 / 70 MC/DCmcdc 0.0% 0 / 44 Subroutinesub 31.9% 38 / 119 Podpod 0.0% 0 / 43 totaltotal 9.2% 153 / 1652 CC 271 SCAR 41.2
CC
271
Cov
8%
update_group
240.0
update_group_ext
210.0
__ANON__
182.0
CRAP 61.4
« Webqq/Log.pm ↑ Summary Webqq/Message/Base.pm »
1 package Mojo::Webqq::Model;
2 1 ▶use strict;
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 ▶use base qw(Mojo::Webqq::Model::Base);
Subroutine BEGIN: called CC=1 SCAR=0.0
5 1 ▶use Mojo::Webqq::User;
Subroutine BEGIN: called CC=1 SCAR=0.0
6 1 ▶use Mojo::Webqq::Friend;
Subroutine BEGIN: called CC=1 SCAR=0.0
7 1 ▶use Mojo::Webqq::Group;
Subroutine BEGIN: called CC=1 SCAR=0.0
8 1 ▶use Mojo::Webqq::Discuss;
Subroutine BEGIN: called CC=1 SCAR=0.0
9 1 ▶use Mojo::Webqq::Discuss::Member;
Subroutine BEGIN: called CC=1 SCAR=0.0
10 1 ▶use Mojo::Webqq::Group::Member;
Subroutine BEGIN: called CC=1 SCAR=0.0
11 1 ▶use Mojo::Webqq::Model::Remote::_get_user_info;
Subroutine BEGIN: called CC=1 SCAR=0.0
12 1 ▶use Mojo::Webqq::Model::Remote::get_single_long_nick;
Subroutine BEGIN: called CC=1 SCAR=0.0
13 1 ▶use Mojo::Webqq::Model::Remote::get_qq_from_id;
Subroutine BEGIN: called CC=1 SCAR=0.0
14 1 ▶use Mojo::Webqq::Model::Remote::_get_user_friends;
Subroutine BEGIN: called CC=1 SCAR=0.0
15 1 ▶use Mojo::Webqq::Model::Remote::_get_user_friends_ext;
Subroutine BEGIN: called CC=1 SCAR=0.0
16 1 ▶use Mojo::Webqq::Model::Remote::_get_friends_state;
Subroutine BEGIN: called CC=1 SCAR=0.0
17 1 ▶use Mojo::Webqq::Model::Remote::_get_group_list_info;
Subroutine BEGIN: called CC=1 SCAR=0.0
18 1 ▶use Mojo::Webqq::Model::Remote::_get_group_list_info_ext;
Subroutine BEGIN: called CC=1 SCAR=0.0
19 1 ▶use Mojo::Webqq::Model::Remote::_get_group_info;
Subroutine BEGIN: called CC=1 SCAR=0.0
20 1 ▶use Mojo::Webqq::Model::Remote::_get_group_info_ext;
Subroutine BEGIN: called CC=1 SCAR=0.0
21 1 ▶use Mojo::Webqq::Model::Remote::_get_discuss_info;
Subroutine BEGIN: called CC=1 SCAR=0.0
22 1 ▶use Mojo::Webqq::Model::Remote::_get_discuss_list_info;
Subroutine BEGIN: called CC=1 SCAR=0.0
23 1 ▶use Mojo::Webqq::Model::Remote::_get_recent_info;
Subroutine BEGIN: called CC=1 SCAR=0.0
24 1 ▶use Mojo::Webqq::Model::Remote::_invite_friend;
Subroutine BEGIN: called CC=1 SCAR=0.0
25 1 ▶use Mojo::Webqq::Model::Remote::_set_group_admin;
Subroutine BEGIN: called CC=1 SCAR=0.0
26 1 ▶use Mojo::Webqq::Model::Remote::_remove_group_admin;
Subroutine BEGIN: called CC=1 SCAR=0.0
27 1 ▶use Mojo::Webqq::Model::Remote::_kick_group_member;
Subroutine BEGIN: called CC=1 SCAR=0.0
28 1 ▶use Mojo::Webqq::Model::Remote::_set_group_member_card;
Subroutine BEGIN: called CC=1 SCAR=0.0
29 1 ▶use Mojo::Webqq::Model::Remote::_shutup_group_member;
Subroutine BEGIN: called CC=1 SCAR=0.0
30 1 ▶use Mojo::Webqq::Model::Remote::_qiandao;
Subroutine BEGIN: called CC=1 SCAR=0.0
31 1 ▶use Encode ();
Subroutine BEGIN: called CC=1 SCAR=0.0
32  
33 0 ▶sub time33 {
Subroutine time33: not called CC=2 SCAR=13.0
Pod undocumented
34 1 ▶ use integer;
Subroutine BEGIN: called CC=1 SCAR=0.0
35 0 my $self = shift;
36 0 my $t = shift;
37 0 my $e = 0;
38 0 my $i = 0;
39 0 ▶ for( my $n = length($t); $i<$n; $i++ ){
Branch: 1 branch
BranchTrueFalseTotal
if ($i < $n) 0 0 0
40 0 $e = ( 33 * $e + ord(substr($t,$i,1)) ) % 4294967296;
41 }
42 0 return $e;
43 }
44 0 ▶sub hash33{
Subroutine hash33: not called CC=2 SCAR=13.0
Pod undocumented
45 1 ▶ use integer;
Subroutine BEGIN: called CC=1 SCAR=0.0
46 0 my $self = shift;
47 0 my $t = shift;
48 0 my $n = length($t);
49 0 my $e = 0;
50 0 ▶ for(my $i=0;$n>$i;$i++ ){
Branch: 1 branch
BranchTrueFalseTotal
if ($n > $i) 0 0 0
51 0 $e += ($e << 5) + ord(substr($t,$i,1));
52 }
53 0 return 2147483647 & $e;
54 }
55 0 ▶sub hash {
Subroutine hash: not called CC=5 SCAR=34.0
Pod undocumented
56 0 my $self = shift;
57 0 my $ptwebqq = shift;
58 0 my $uin = shift;
59  
60 0 $uin .= "";
61 0 my @ptb;
62 0 ▶ for(my $i =0;$i<length($ptwebqq);$i++){
Branch: 1 branch
BranchTrueFalseTotal
if ($i < length $ptwebqq) 0 0 0
63 0 $ptb[$i % 4] ^= ord(substr($ptwebqq,$i,1));
64 }
65 0 my @salt = ("EC", "OK");
66 0 my @uinByte;
67 0 $uinByte[0] = $uin >> 24 & 0xFF ^ ord(substr($salt[0],0,1));
68 0 $uinByte[1] = $uin >> 16 & 0xFF ^ ord(substr($salt[0],1,1));
69 0 $uinByte[2] = $uin >> 8 & 0xFF ^ ord(substr($salt[1],0,1));
70 0 $uinByte[3] = $uin & 0xFF ^ ord(substr($salt[1],1,1));
71 0 my @result;
72 0 ▶ for(my $i=0;$i<8;$i++){
Branch: 1 branch
BranchTrueFalseTotal
if ($i < 8) 0 0 0
73 0 ▶ $result[$i] = $i%2==0?$ptb[$i>>1]:$uinByte[$i>>1];
Branch: 1 branch
BranchTrueFalseTotal
$i % 2 == 0 ? : 0 0 0
74 }
75 0 my @hex = ("0", "1", "2", "3", "4", "5", "6", "7", "8", "9", "A", "B", "C", "D", "E", "F");
76 0 my $buf = "";
77 0 ▶ for(my $i=0;$i<@result;$i++){
Branch: 1 branch
BranchTrueFalseTotal
if ($i < @result) 0 0 0
78 0 $buf .= $hex[$result[$i] >> 4 & 0xF];
79 0 $buf .= $hex[$result[$i] & 0xF];
80 }
81  
82 0 return $buf;
83 }
84  
85 0 ▶sub is_support_model_ext {
Subroutine is_support_model_ext: not called CC=1 SCAR=6.9
Pod undocumented
86 0 my $self = shift;
87 0 return $self->model_ext;
88 #return $self->uid && $self->pwd
89 #my $ret = $self->search_cookie("p_skey") && $self->search_cookie("skey");
90 #$self->model_ext($ret || 0);
91 #return $ret;
92 }
93 0 ▶sub get_model_status{
Subroutine get_model_status: not called CC=5 SCAR=34.0
Pod undocumented
94 0 my $self = shift;
95 0 ▶ if( defined $self->model_status->{friend}
Branch: 1 branch
BranchTrueFalseTotal
if (defined $self->model_status->{'friend'} and defined $self->model_status->{'group'}) { } 0 0 0
Condition0%0/3
defined $self->model_status->{"friend"} and defined $self->model_status->{"group"}
!ll&&!rl&&r
000
MC/DC0%0/2
defined $self->model_status->{"friend"} and defined $self->model_status->{"group"}
defined $self->model_status->{"friend"} defined $self->model_status->{"group"}
Truth table0%0/3
A and B
A= defined $self->model_status->{"friend"}B= defined $self->model_status->{"group"}
ABresult
0X0
100
111
96 and defined $self->model_status->{group}
97 ){
98 my $is_fail =
99 $self->model_status->{friend} == 0
100 0 ▶ && $self->model_status->{group} == 0
Condition0%0/3
$self->model_status->{'friend'} == 0 && $self->model_status->{'group'} == 0
!ll&&!rl&&r
000
MC/DC0%0/2
$self->model_status->{'friend'} == 0 && $self->model_status->{'group'} == 0
$self->model_status->{'friend'} == 0 $self->model_status->{'group'} == 0
Truth table0%0/3
A && B
A= $self->model_status->{'friend'} == 0B= $self->model_status->{'group'} == 0
ABresult
0X0
100
111
101 ;
102 0 ▶ return $is_fail?0:1;
Branch: 1 branch
BranchTrueFalseTotal
$is_fail ? : 0 0 0
103 }
104 else{
105 0 return -1;
106 }
107 }
108 0 ▶sub get_csrf_token {
Subroutine get_csrf_token: not called CC=5 SCAR=31.0
Pod undocumented
109 1 ▶ use integer;
Subroutine BEGIN: called CC=1 SCAR=0.0
110 0 my $self = shift;
111 0 ▶ if(not $self->is_support_model_ext){
Branch: 1 branch
BranchTrueFalseTotal
unless ($self->is_support_model_ext) 0 0 0
112 0 $self->error("当前不支持获取扩展信息,无法获取CSRF Token");
113 0 return;
114 }
115 0 ▶ return $self->csrf_token if defined $self->csrf_token;
Branch: 1 branch
BranchTrueFalseTotal
if defined $self->csrf_token 0 0 0
116 0 my $t = $self->search_cookie("skey");
117 0 my $n = 0;
118 0 my $o=length($t);
119 0 my $r;
120 0 ▶ if($t){
Branch: 1 branch
BranchTrueFalseTotal
if ($t) 0 0 0
121 0 ▶ for($r=5381;$o>$n;$n++){
Branch: 1 branch
BranchTrueFalseTotal
if ($o > $n) 0 0 0
122 0 $r += ($r<<5) + ord(substr($t,$n,1));
123 }
124 0 my $token = 2147483647 & $r;
125 0 $self->csrf_token($token);
126 0 return $token;
127 }
128 }
129 0 ▶sub each_friend{
Subroutine each_friend: not called CC=4 SCAR=30.0
Pod undocumented
130 0 my $self = shift;
131 0 my $callback = shift;
132 0 ▶ $self->die("参数必须是函数引用") if ref $callback ne "CODE";
Branch: 1 branch
BranchTrueFalseTotal
if ref $callback ne "CODE" 0 0 0
133 0 ▶ $self->update_friend(is_blocking=>1,is_update_friend_ext=>1) if @{$self->friend} == 0;
Branch: 1 branch
BranchTrueFalseTotal
if @{$self->friend;} == 0 0 0 0
134 0 for (@{$self->friend}){
135 0 $callback->($self,$_);
136 }
137 }
138 0 ▶sub each_group{
Subroutine each_group: not called CC=4 SCAR=30.0
Pod undocumented
139 0 my $self = shift;
140 0 my $callback = shift;
141 0 ▶ $self->die("参数必须是函数引用") if ref $callback ne "CODE";
Branch: 1 branch
BranchTrueFalseTotal
if ref $callback ne "CODE" 0 0 0
142 0 ▶ $self->update_group(is_blocking=>1,is_update_group_member=>0) if @{$self->group} == 0;
Branch: 1 branch
BranchTrueFalseTotal
if @{$self->group;} == 0 0 0 0
143 0 for (@{$self->group}){
144 0 $callback->($self,$_);
145 }
146 }
147  
148 0 ▶sub each_discuss{
Subroutine each_discuss: not called CC=4 SCAR=30.0
Pod undocumented
149 0 my $self = shift;
150 0 my $callback = shift;
151 0 ▶ $self->die("参数必须是函数引用") if ref $callback ne "CODE";
Branch: 1 branch
BranchTrueFalseTotal
if ref $callback ne "CODE" 0 0 0
152 0 ▶ $self->update_discuss(is_blocking=>1,is_update_discuss_member=>0) if @{$self->discuss} == 0;
Branch: 1 branch
BranchTrueFalseTotal
if @{$self->discuss;} == 0 0 0 0
153 0 for (@{$self->discuss}){
154 0 $callback->($self,$_);
155 }
156 }
157 0 ▶sub each_group_member{
Subroutine each_group_member: not called CC=6 SCAR=37.4
Pod undocumented
158 0 my $self = shift;
159 0 my $callback = shift;
160 0 ▶ $self->die("参数必须是函数引用") if ref $callback ne "CODE";
Branch: 1 branch
BranchTrueFalseTotal
if ref $callback ne "CODE" 0 0 0
161 0 ▶ if(@{$self->group} == 0){
Branch: 1 branch
BranchTrueFalseTotal
if (@{$self->group;} == 0) { } 0 0 0
162 0 $self->update_group(is_blocking=>1,is_update_group_member=>1);
163 }
164 else{
165 0 for( @{$self->group}){
166 0 ▶ $_->update_group_member(is_blocking=>1,) if $_->is_empty;
Branch: 1 branch
BranchTrueFalseTotal
if $_->is_empty 0 0 0
167 }
168 }
169 0 my @member = map {@{$_->member}} grep {ref $_->member eq "ARRAY"} @{$self->group};
170 0 for (@member){
171 0 $callback->($self,$_);
172 }
173 }
174 0 ▶sub each_discuss_member{
Subroutine each_discuss_member: not called CC=6 SCAR=37.4
Pod undocumented
175 0 my $self = shift;
176 0 my $callback = shift;
177 0 ▶ $self->die("参数必须是函数引用") if ref $callback ne "CODE";
Branch: 1 branch
BranchTrueFalseTotal
if ref $callback ne "CODE" 0 0 0
178 0 ▶ if(@{$self->discuss} == 0){
Branch: 1 branch
BranchTrueFalseTotal
if (@{$self->discuss;} == 0) { } 0 0 0
179 0 $self->update_discuss(is_blocking=>1,is_update_discuss_member=>1);
180 }
181 else{
182 0 for( @{$self->discuss}){
183 0 ▶ $_->update_discuss_member(is_blocking=>1,) if $_->is_empty;
Branch: 1 branch
BranchTrueFalseTotal
if $_->is_empty 0 0 0
184 }
185 }
186 0 my @member = map {@{$_->member}} grep {ref $_->member eq "ARRAY"} @{$self->discuss};
187 0 for (@member){
188 0 $callback->($self,$_);
189 }
190 }
191  
192 0 ▶sub update_user {
Subroutine update_user: not called CC=2 SCAR=17.9
Pod undocumented
193 0 my $self = shift;
194 0 my $is_blocking = ! shift;
195 0 $self->info("更新个人信息...\n");
196 0 ▶ my $handle = sub{
Subroutine __ANON__: not called CC=2 SCAR=17.9
197 0 my $user_info = shift;
198 0 ▶ unless ( defined $user_info ) {
Branch: 1 branch
BranchTrueFalseTotal
unless (defined $user_info) 0 0 0
199 0 $self->warn("更新个人信息失败\n");
200 0 $self->user(Mojo::Webqq::User->new({id=>$self->uid,uid=>$self->uid}));
201 0 $self->emit("model_update"=>"user",0);
202 0 return;
203 }
204 0 $self->user(Mojo::Webqq::User->new($user_info));
205 0 $self->emit("model_update"=>"user",1);
206 0 };
207 0 ▶ if($is_blocking){
Branch: 1 branch
BranchTrueFalseTotal
if ($is_blocking) { } 0 0 0
208 0 my $user_info = $self->_get_user_info();
209 0 $handle->($user_info);
210 }
211 else{
212 0 $self->_get_user_info($handle);
213 }
214 }
215  
216 0 ▶sub remove_friend {
Subroutine remove_friend: not called CC=4 SCAR=30.0
Pod undocumented
217 0 my $self = shift;
218 0 my $friend = shift;
219 0 ▶ $self->die("不支持的数据类型\n") if ref $friend ne "Mojo::Webqq::Friend";
Branch: 1 branch
BranchTrueFalseTotal
if ref $friend ne "Mojo::Webqq::Friend" 0 0 0
220 0 ▶ for(my $i=0;@{$self->friend};$i++){
Branch: 1 branch
BranchTrueFalseTotal
if (@{$self->friend;}) 0 0 0
221 0 ▶ if($friend->id eq $self->friend->[$i]->id){
Branch: 1 branch
BranchTrueFalseTotal
if ($friend->id eq $self->friend->[$i]->id) 0 0 0
222 0 splice @{$self->friend},$i,1;
223 0 return 1;
224 }
225 }
226 0 return 0;
227 }
228 0 ▶sub add_friend {
Subroutine add_friend: not called CC=5 SCAR=34.0
Pod undocumented
229 0 my $self = shift;
230 0 my $friend = shift;
231 0 my $nocheck = shift;
232 0 ▶ $self->die("不支持的数据类型\n") if ref $friend ne "Mojo::Webqq::Friend";
Branch: 1 branch
BranchTrueFalseTotal
if ref $friend ne "Mojo::Webqq::Friend" 0 0 0
233 0 ▶ if(@{$self->friend} == 0){
Branch: 1 branch
BranchTrueFalseTotal
if (@{$self->friend;} == 0) 0 0 0
234 0 push @{$self->friend},$friend;
235 0 return $self;
236 }
237 0 ▶ if($nocheck){
Branch: 1 branch
BranchTrueFalseTotal
if ($nocheck) 0 0 0
238 0 push @{$self->friend},$friend;
239 0 return $self;
240 }
241 0 my $f = $self->search_friend(id => $friend->id);
242 0 ▶ if(defined $f){
Branch: 1 branch
BranchTrueFalseTotal
if (defined $f) { } 0 0 0
243 0 %$f = %$friend;
244 }
245 else{
246 0 push @{$self->friend},$friend;
247 }
248 0 return $self;
249 }
250  
251 0 ▶sub update_friend_ext {
Subroutine update_friend_ext: not called CC=4 SCAR=30.0
Pod undocumented
252 0 my $self = shift;
253 0 my %p = @_;
254 0 ▶ $p{is_blocking} = 1 if not defined $p{is_blocking} ;
Branch: 1 branch
BranchTrueFalseTotal
unless defined $p{"is_blocking"} 0 0 0
255 0 ▶ if ( not $self->is_support_model_ext){
Branch: 1 branch
BranchTrueFalseTotal
unless ($self->is_support_model_ext) 0 0 0
256 0 $self->warn("无法支持获取扩展信息");
257 0 return;
258 }
259 0 ▶ my $handle = sub{
Subroutine __ANON__: not called CC=8 SCAR=42.8
260 0 my $friends_ext_info = shift;
261 0 ▶ if(defined $friends_ext_info and ref $friends_ext_info eq "ARRAY"){
Branch: 1 branch
BranchTrueFalseTotal
if (defined $friends_ext_info and ref $friends_ext_info eq 'ARRAY') { } 0 0 0
Condition0%0/3
defined $friends_ext_info and ref $friends_ext_info eq "ARRAY"
!ll&&!rl&&r
000
MC/DC0%0/2
defined $friends_ext_info and ref $friends_ext_info eq "ARRAY"
defined $friends_ext_info ref $friends_ext_info eq "ARRAY"
Truth table0%0/3
A and B
A= defined $friends_ext_infoB= ref $friends_ext_info eq "ARRAY"
ABresult
0X0
100
111
262 0 $self->info("更新好友扩展信息...");
263 0 ▶ my(undef,$ext)=$self->array_unique($friends_ext_info,sub{$_[0]->{displayname} . "|" . $_[0]->{category}},"friend_ext");
Subroutine __ANON__: not called CC=1 SCAR=6.9
264 0 ▶ my $unique_friend = $self->array_unique($self->friend,sub{$_[0]->displayname . "|" . $_[0]->category},"friend");
Subroutine __ANON__: not called CC=1 SCAR=6.9
265 0 for my $f(@$unique_friend){
266 0 my $id = $f->displayname . "|" . $f->category;
267 0 ▶ next if not exists $ext->{$id};
Branch: 1 branch
BranchTrueFalseTotal
unless exists $ext->{$id} 0 0 0
268 0 $f->{uid} = $ext->{$id}{uid};
269 }
270
271 0 ▶ if($self->log_level eq 'debug'){
Branch: 1 branch
BranchTrueFalseTotal
if ($self->log_level eq "debug") 0 0 0
272 0 for(@{$self->friend}){
273 0 ▶ $self->debug("更新好友[" . $_->displayname . "|" . $_->category . "]扩展信息uid失败") if not $_->uid;
Branch: 1 branch
BranchTrueFalseTotal
unless $_->uid 0 0 0
274 }
275 }
276  
277 0 $self->emit("model_update"=>"friend_ext",1);
278 }
279 else{
280 0 $self->warn("更新好友扩展信息失败");
281 0 $self->emit("model_update"=>"friend_ext",0);
282 }
283 0 };
284 0 ▶ if($p{is_blocking}){
Branch: 1 branch
BranchTrueFalseTotal
if ($p{'is_blocking'}) { } 0 0 0
285 0 my $friends_ext_info = $self->_get_user_friends_ext();
286 0 $handle->($friends_ext_info);
287 }
288 else{
289 0 $self->_get_user_friends_ext($handle);
290 }
291 }
292 0 ▶sub update_friend {
Subroutine update_friend: not called CC=7 SCAR=40.3
Pod undocumented
293 0 my $self = shift;
294 0 ▶ if(ref $_[0] eq "Mojo::Webqq::Friend"){
Branch: 1 branch
BranchTrueFalseTotal
if (ref $_[0] eq "Mojo::Webqq::Friend") 0 0 0
295 0 my $friend = shift;
296 0 my %p = @_;
297 0 ▶ $p{is_blocking} = 1 if not defined $p{is_blocking};
Branch: 1 branch
BranchTrueFalseTotal
unless defined $p{"is_blocking"} 0 0 0
298 0 $self->info("更新好友 [ " . $friend->displayname . " ] 信息...");
299 0 ▶ my $handle = sub{
Subroutine __ANON__: not called CC=2 SCAR=17.9
300 0 my $friend_info = shift;
301 0 ▶ if(defined $friend_info){$friend->update($friend_info);}
Branch: 1 branch
BranchTrueFalseTotal
if (defined $friend_info) { } 0 0 0
302 0 else{$self->warn("更新好友 [ " . $friend->displayname . " ] 信息失败...");}
303 0 };
304 0 ▶ if($p{is_blocking}){
Branch: 1 branch
BranchTrueFalseTotal
if ($p{'is_blocking'}) { } 0 0 0
305 0 my $friend_info = $self->_get_friend_info($friend->id);
306 0 $handle->($friend_info);
307 }
308 else{
309 0 $self->_get_friend_info($friend->id,$handle);
310 }
311 0 return $self;
312 }
313 0 my %p = @_;
314 0 ▶ $p{is_blocking} = 1 if not defined $p{is_blocking};
Branch: 1 branch
BranchTrueFalseTotal
unless defined $p{"is_blocking"} 0 0 0
315 0 ▶ $p{is_update_friend_ext} = 1 if not defined $p{is_update_friend_ext};
Branch: 1 branch
BranchTrueFalseTotal
unless defined $p{"is_update_friend_ext"} 0 0 0
316 0 ▶ my $handle = sub{
Subroutine __ANON__: not called CC=9 SCAR=45.0
317 0 my @friends;
318 0 my $friends_info = shift;
319 0 ▶ if(defined $friends_info){
Branch: 1 branch
BranchTrueFalseTotal
if (defined $friends_info) { } 0 0 0
320 0 $self->info("更新好友信息...");
321 0 push @friends,Mojo::Webqq::Friend->new($_) for @{$friends_info};
322 0 ▶ if(ref $self->friend eq "ARRAY" and @{$self->friend} == 0){
Branch: 1 branch
BranchTrueFalseTotal
if (ref $self->friend eq 'ARRAY' and @{$self->friend;} == 0) { } 0 0 0
Condition0%0/3
ref $self->friend eq "ARRAY" and @{$self->friend;} == 0
!ll&&!rl&&r
000
MC/DC0%0/2
ref $self->friend eq "ARRAY" and @{$self->friend;} == 0
ref $self->friend eq "ARRAY" @{$self->friend;} == 0
Truth table0%0/3
A and B
A= ref $self->friend eq "ARRAY"B= @{$self->friend;} == 0
ABresult
0X0
100
111
323 0 $self->friend(\@friends);
324 }
325 else{
326 0 ▶ my($new_friends,$lost_friends,$sames) = $self->array_diff($self->friend,\@friends,sub{$_[0]->id});
Subroutine __ANON__: not called CC=1 SCAR=6.9
327 0 for(@{$new_friends}){
328 0 $self->add_friend($_);
329 0 $self->emit(new_friend=>$_);
330 }
331 0 for(@{$lost_friends}){
332 0 $self->remove_friend($_);
333 0 $self->emit(lose_friend=>$_);
334 }
335 0 for(@{$sames}){
336 0 my($old,$new) = @$_;
337 0 $old->update($new);
338 }
339 }
340 0 $self->emit("model_update","friend",1);
341 0 ▶ $self->update_friend_ext(is_blocking=>$p{is_blocking}) if $p{is_update_friend_ext};
Branch: 1 branch
BranchTrueFalseTotal
if $p{"is_update_friend_ext"} 0 0 0
342 }
343 0 else{$self->warn("更新好友信息失败");$self->emit("model_update","friend",0);}
344 0 };
345 0 ▶ if($p{is_blocking}){
Branch: 1 branch
BranchTrueFalseTotal
if ($p{'is_blocking'}) { } 0 0 0
346 0 my $friends_info = $self->_get_user_friends();
347 0 $handle->($friends_info);
348 }
349 else{
350 0 $self->_get_user_friends($handle);
351 }
352 }
353 0 ▶sub search_friend {
Subroutine search_friend: not called CC=5 SCAR=31.6
Pod undocumented
354 1 ▶ no warnings 'uninitialized';
Subroutine BEGIN: called CC=1 SCAR=0.0
355 0 my $self = shift;
356 0 my %p = @_;
357 0 ▶ return if 0 == grep {defined $p{$_}} keys %p;
Branch: 1 branch
BranchTrueFalseTotal
if 0 == grep({defined $p{$_};} keys %p) 0 0 0
358 0 ▶ $self->update_friend(is_blocking=>1,is_update_friend_ext=>1) if @{ $self->friend } == 0;
Branch: 1 branch
BranchTrueFalseTotal
if @{$self->friend;} == 0 0 0 0
359 0 ▶ if(wantarray){
Branch: 1 branch
BranchTrueFalseTotal
if (wantarray) { } 0 0 0
360 0 ▶ return grep {my $f = $_;(first {$p{$_} ne $f->$_} grep {defined $p{$_}} keys %p) ? 0 : 1;} @{$self->friend};
Subroutine __ANON__: not called CC=1 SCAR=6.9
Branch: 1 branch
BranchTrueFalseTotal
&first(sub { $p{$_} ne $f->$_; } , grep({defined $p{$_};} keys %p)) ? : 0 0 0
361 }
362 else{
363 0 ▶ return first {my $f = $_;(first {$p{$_} ne $f->$_} grep {defined $p{$_}} keys %p) ? 0 : 1;} @{$self->friend};
Subroutine __ANON__: not called CC=2 SCAR=17.9
Subroutine __ANON__: not called CC=1 SCAR=6.9
Branch: 1 branch
BranchTrueFalseTotal
&first(sub { $p{$_} ne $f->$_; } , grep({defined $p{$_};} keys %p)) ? : 0 0 0
364 }
365 }
366  
367 0 ▶sub add_group{
Subroutine add_group: not called CC=5 SCAR=34.0
Pod undocumented
368 0 my $self = shift;
369 0 my $group = shift;
370 0 my $nocheck = shift;
371 0 ▶ $self->die("不支持的数据类型") if ref $group ne "Mojo::Webqq::Group";
Branch: 1 branch
BranchTrueFalseTotal
if ref $group ne "Mojo::Webqq::Group" 0 0 0
372 0 ▶ if(@{$self->group} == 0){
Branch: 1 branch
BranchTrueFalseTotal
if (@{$self->group;} == 0) 0 0 0
373 0 push @{$self->group},$group;
374 0 return $self;
375 }
376 0 ▶ if($nocheck){
Branch: 1 branch
BranchTrueFalseTotal
if ($nocheck) 0 0 0
377 0 push @{$self->group},$group;
378 0 return $self;
379 }
380 0 my $g = $self->search_group(id => $group->id);
381 0 ▶ if(defined $g){
Branch: 1 branch
BranchTrueFalseTotal
if (defined $g) { } 0 0 0
382 0 %$g = %$group;
383 }
384 else{#new group
385 0 push @{$self->group},$group;
386 }
387 0 return $self;
388 }
389 0 ▶sub remove_group{
Subroutine remove_group: not called CC=4 SCAR=30.0
Pod undocumented
390 0 my $self = shift;
391 0 my $group = shift;
392 0 ▶ $self->die("不支持的数据类型") if ref $group ne "Mojo::Webqq::Group";
Branch: 1 branch
BranchTrueFalseTotal
if ref $group ne "Mojo::Webqq::Group" 0 0 0
393 0 ▶ for(my $i=0;@{$self->group};$i++){
Branch: 1 branch
BranchTrueFalseTotal
if (@{$self->group;}) 0 0 0
394 0 ▶ if($group->id eq $self->group->[$i]->id){
Branch: 1 branch
BranchTrueFalseTotal
if ($group->id eq $self->group->[$i]->id) 0 0 0
395 0 splice @{$self->group},$i,1;
396 0 return 1;
397 }
398 }
399 0 return 0;
400 }
401 0 ▶sub update_group_ext {
Subroutine update_group_ext: not called CC=14 SCAR=53.5
Pod undocumented
402 0 my $self = shift;
403 0 ▶ if ( not $self->is_support_model_ext){
Branch: 1 branch
BranchTrueFalseTotal
unless ($self->is_support_model_ext) 0 0 0
404 0 $self->warn("无法支持获取扩展信息");
405 0 return;
406 }
407 0 ▶ return if @{ $self->group } == 0;
Branch: 1 branch
BranchTrueFalseTotal
if @{$self->group;} == 0 0 0 0
408 0 my $group;
409 0 ▶ $group = shift if ref $_[0] eq "Mojo::Webqq::Group";
Branch: 1 branch
BranchTrueFalseTotal
if ref $_[0] eq "Mojo::Webqq::Group" 0 0 0
410 0 my %p = @_;
411 0 ▶ $p{is_blocking} = 1 if not defined $p{is_blocking};
Branch: 1 branch
BranchTrueFalseTotal
unless defined $p{"is_blocking"} 0 0 0
412 0 ▶ $p{is_update_group_member_ext} = 1 if not defined $p{is_update_group_member_ext};
Branch: 1 branch
BranchTrueFalseTotal
unless defined $p{"is_update_group_member_ext"} 0 0 0
413  
414 0 ▶ if(defined $group and defined $group->uid){#要更新的指定群组已经包含扩展信息
Branch: 2 branches
BranchTrueFalseTotal
if (defined $group and defined $group->uid) { } 0 0 0
elsif (not defined $group || &first(sub { not defined $_->uid; } , @{$self->group;})) { } 0 0 0
Condition0%0/3
defined $group and defined $group->uid
!ll&&!rl&&r
000
MC/DC0%0/2
defined $group and defined $group->uid
defined $group defined $group->uid
Truth table0%0/3
A and B
A= defined $groupB= defined $group->uid
ABresult
0X0
100
111
415 0 ▶ $self->update_group_member_ext($group,%p) if $p{is_update_group_member_ext};
Branch: 1 branch
BranchTrueFalseTotal
if $p{"is_update_group_member_ext"} 0 0 0
416 0 return;
417 }
418 0 ▶ elsif( (!defined $group) and (! first { !defined $_->uid} @{$self->group} ) ){ #所有群组都包含扩展信息了
Subroutine __ANON__: not called CC=1 SCAR=6.9
Condition0%0/3
defined $group || &first(sub { not defined $_->uid; } , @{$self->group;})
l!l&&r!l&&!r
000
MC/DC0%0/2
defined $group || &first(sub { not defined $_->uid; } , @{$self->group;})
defined $group &first(sub { not defined $_->uid; } , @{$self->group;})
Truth table0%0/3
A || B
A= defined $groupB= &first(sub { not defined $_->uid; } , @{$self->group;})
ABresult
1X1
011
000
419 0 for(@{$self->group}){
420 0 ▶ $self->update_group_member_ext($_,%p) if $p{is_update_group_member_ext};
Branch: 1 branch
BranchTrueFalseTotal
if $p{"is_update_group_member_ext"} 0 0 0
421 }
422 0 return;
423 }
424 0 ▶ my $handle = sub{
Subroutine __ANON__: not called CC=10 SCAR=47.0
425 0 my $group_list_ext = shift;
426 0 ▶ if(defined $group_list_ext and ref $group_list_ext eq "ARRAY"){
Branch: 1 branch
BranchTrueFalseTotal
if (defined $group_list_ext and ref $group_list_ext eq 'ARRAY') { } 0 0 0
Condition0%0/3
defined $group_list_ext and ref $group_list_ext eq "ARRAY"
!ll&&!rl&&r
000
MC/DC0%0/2
defined $group_list_ext and ref $group_list_ext eq "ARRAY"
defined $group_list_ext ref $group_list_ext eq "ARRAY"
Truth table0%0/3
A and B
A= defined $group_list_extB= ref $group_list_ext eq "ARRAY"
ABresult
0X0
100
111
427 0 $self->info("更新群列表扩展信息...");
428 0 ▶ my(undef,$gext)= $self->array_unique($group_list_ext,sub{$_[0]->{name}},"group_ext");
Subroutine __ANON__: not called CC=1 SCAR=6.9
429 0 ▶ my $unique_group = $self->array_unique($self->group,sub{$_[0]->name},"group");
Subroutine __ANON__: not called CC=1 SCAR=6.9
430 0 ▶ my @groups = defined $group?(grep {$_->id eq $group->id} @$unique_group) : @$unique_group;
Branch: 1 branch
BranchTrueFalseTotal
defined $group ? : 0 0 0
431 0 ▶ if($p{is_blocking}){
Branch: 1 branch
BranchTrueFalseTotal
if ($p{'is_blocking'}) { } 0 0 0
432 0 for my $g (@groups){
433 0 my $id = $g->name;
434 0 ▶ next if not exists $gext->{$id};
Branch: 1 branch
BranchTrueFalseTotal
unless exists $gext->{$id} 0 0 0
435 0 $g->update($gext->{$id});
436 0 ▶ $self->update_group_member_ext($g,%p) if $p{is_update_group_member_ext};
Branch: 1 branch
BranchTrueFalseTotal
if $p{"is_update_group_member_ext"} 0 0 0
437 }
438 }
439 else{
440 0 my $i = -3;
441 0 for my $g (@groups){
442 0 my $id = $g->name;
443 0 ▶ next if not exists $gext->{$id};
Branch: 1 branch
BranchTrueFalseTotal
unless exists $gext->{$id} 0 0 0
444 0 $g->update($gext->{$id});
445 0 ▶ $self->timer($i+3,sub{
Subroutine __ANON__: not called CC=2 SCAR=17.9
446 0 ▶ $self->update_group_member_ext($g,%p) if $p{is_update_group_member_ext};
Branch: 1 branch
BranchTrueFalseTotal
if $p{"is_update_group_member_ext"} 0 0 0
447 0 });
448 0 $i++;
449 }
450 }
451 0 $self->emit("model_update","group_ext",1);
452 }
453 0 else{$self->warn("更新群扩展信息失败");$self->emit("model_update","group_ext",0);}
454 0 };
455 0 ▶ if($p{is_blocking}){
Branch: 1 branch
BranchTrueFalseTotal
if ($p{'is_blocking'}) { } 0 0 0
456 0 my $group_list_ext = $self->_get_group_list_info_ext();
457 0 $handle->($group_list_ext);
458 }
459 else{
460 0 $self->_get_group_list_info_ext($handle);
461 }
462 }
463 0 ▶sub update_group_member_ext {
Subroutine update_group_member_ext: not called CC=7 SCAR=40.3
Pod undocumented
464 0 my $self = shift;
465 0 my $group = shift;
466 0 ▶ if ( not $self->is_support_model_ext){
Branch: 1 branch
BranchTrueFalseTotal
unless ($self->is_support_model_ext) 0 0 0
467 0 $self->warn("群组[ ". $group->name . " ]当前无法支持获取扩展信息");
468 0 return;
469 }
470 0 ▶ $self->die("不支持的数据类型") if ref $group ne "Mojo::Webqq::Group";
Branch: 1 branch
BranchTrueFalseTotal
if ref $group ne "Mojo::Webqq::Group" 0 0 0
471 0 ▶ if(not defined $group->uid){
Branch: 1 branch
BranchTrueFalseTotal
unless (defined $group->uid) 0 0 0
472 0 $self->warn("群组[ ". $group->name . " ]未包含有效的uid,无法更新群成员扩展信息");
473 0 return;
474 }
475 0 ▶ if($group->is_empty){
Branch: 1 branch
BranchTrueFalseTotal
if ($group->is_empty) 0 0 0
476 0 $self->warn("群组[ ". $group->name . " ]未包含群成员,忽略更新群成员扩展信息");
477 0 return;
478 }
479 0 my %p = @_;
480 0 ▶ $p{is_blocking} = 1 if not defined $p{is_blocking};
Branch: 1 branch
BranchTrueFalseTotal
unless defined $p{"is_blocking"} 0 0 0
481 0 ▶ my $handle = sub{
Subroutine __ANON__: not called CC=9 SCAR=45.0
482 0 my $group_info_ext = shift;
483 0 ▶ if(defined $group_info_ext){
Branch: 1 branch
BranchTrueFalseTotal
if (defined $group_info_ext) { } 0 0 0
484 0 $self->info("更新群组[ ". $group->name . " ]成员扩展信息");
485 0 ▶ my $unique_sub = sub{
Subroutine __ANON__: not called CC=5 SCAR=34.0
486 0 ▶ my $name = $_[0]->{name} // "";
Condition0%0/2
$_[0]{"name"} // ""
l!l
00
MC/DC0%0/1
$_[0]{"name"} // ""
$_[0]{"name"}
Truth table0%0/2
A
A= $_[0]{"name"}
Aresult
11
00
487 0 ▶ my $card = $_[0]->{card} // "";
Condition0%0/2
$_[0]{"card"} // ""
l!l
00
MC/DC0%0/1
$_[0]{"card"} // ""
$_[0]{"card"}
Truth table0%0/2
A
A= $_[0]{"card"}
Aresult
11
00
488 0 ▶ if(ref $self->group_member_identify_callback eq 'CODE'){
Branch: 1 branch
BranchTrueFalseTotal
if (ref $self->group_member_identify_callback eq 'CODE') { } 0 0 0
489 0 return $self->group_member_identify_callback->($name,$card);
490 }
491 else{
492 0 ▶ return $self->group_member_card_ext_only? $name: $name . $card;
Branch: 1 branch
BranchTrueFalseTotal
$self->group_member_card_ext_only ? : 0 0 0
493 }
494 0 };
495 0 my(undef,$mext) = $self->array_unique($group_info_ext->{member},$unique_sub,$group->name . " member_ext");
496 0 my $unique_member = $self->array_unique($group->member,$unique_sub,$group->name . " member");
497 0 for(@$unique_member){
498 0 my $id = $unique_sub->($_);
499 0 ▶ next if not exists $mext->{$id};
Branch: 1 branch
BranchTrueFalseTotal
unless exists $mext->{$id} 0 0 0
500 0 $_->update($mext->{$id});
501 }
502 0 ▶ if($self->log_level eq 'debug'){
Branch: 1 branch
BranchTrueFalseTotal
if ($self->log_level eq "debug") 0 0 0
503 0 for(@{$group->member}){
504 0 ▶ $self->debug("更新群成员[".$_->name . "|" . $group->name ."]扩展信息uid失败") if not $_->uid;
Branch: 1 branch
BranchTrueFalseTotal
unless $_->uid 0 0 0
505 }
506 }
507 0 ▶ $group->{max_member} //= $group_info_ext->{max_member};
Condition0%0/3
$group->{"max_member"} //= $group_info_ext->{"max_member"}
l!l&&r!l&&!r
000
MC/DC0%0/2
$group->{"max_member"} //= $group_info_ext->{"max_member"}
$group->{"max_member"} $group_info_ext->{"max_member"}
Truth table0%0/3
A //= B
A= $group->{"max_member"}B= $group_info_ext->{"max_member"}
ABresult
1X1
011
000
508 0 ▶ $group->{max_admin} //= $group_info_ext->{max_admin};
Condition0%0/3
$group->{"max_admin"} //= $group_info_ext->{"max_admin"}
l!l&&r!l&&!r
000
MC/DC0%0/2
$group->{"max_admin"} //= $group_info_ext->{"max_admin"}
$group->{"max_admin"} $group_info_ext->{"max_admin"}
Truth table0%0/3
A //= B
A= $group->{"max_admin"}B= $group_info_ext->{"max_admin"}
ABresult
1X1
011
000
509 0 $group->{_is_hold_member_ext} = 1;
510 0 $self->emit("model_update","group_member_ext",1);
511 }
512 0 else{$self->warn("更新群组[ " . $group->name . " ]成员扩展信息失败");}
513 0 };
514 0 ▶ if($p{is_blocking}){
Branch: 1 branch
BranchTrueFalseTotal
if ($p{'is_blocking'}) { } 0 0 0
515 0 my $group_info_ext = $self->_get_group_info_ext($group->uid);
516 0 $handle->($group_info_ext);
517 }
518 else{
519 0 $self->_get_group_info_ext($group->uid,$handle);
520 }
521
522 }
523 0 ▶sub update_group_member {
Subroutine update_group_member: not called CC=5 SCAR=34.0
Pod undocumented
524 0 my $self = shift;
525 0 my $group = shift;
526 0 ▶ $self->die("不支持的数据类型") if ref $group ne "Mojo::Webqq::Group";
Branch: 1 branch
BranchTrueFalseTotal
if ref $group ne "Mojo::Webqq::Group" 0 0 0
527 0 my %p = @_;
528 0 ▶ $p{is_blocking} = 1 if not defined $p{is_blocking};
Branch: 1 branch
BranchTrueFalseTotal
unless defined $p{"is_blocking"} 0 0 0
529 0 ▶ $p{is_update_group_member_ext} = 1 if not defined $p{is_update_group_member_ext};
Branch: 1 branch
BranchTrueFalseTotal
unless defined $p{"is_update_group_member_ext"} 0 0 0
530 0 ▶ my $handle = sub{
Subroutine __ANON__: not called CC=4 SCAR=30.0
531 0 my $group_info = shift;
532 0 ▶ if(defined $group_info){
Branch: 1 branch
BranchTrueFalseTotal
if (defined $group_info) { } 0 0 0
533 0 $self->info("更新群组[ ". $group->name . " ]成员信息");
534 0 ▶ if(ref $group_info->{member} eq 'ARRAY'){
Branch: 1 branch
BranchTrueFalseTotal
if (ref $group_info->{'member'} eq 'ARRAY') { } 0 0 0
535 0 $group->update($group_info);
536 0 ▶ $self->update_group_member_ext($group,%p) if $p{is_update_group_member_ext};
Branch: 1 branch
BranchTrueFalseTotal
if $p{"is_update_group_member_ext"} 0 0 0
537 }
538 0 else{$self->debug("更新群组[ " . $group->name . " ]成员信息无效")}
539 }
540 0 else{$self->warn("更新群组[ " . $group->name . " ]成员信息失败")}
541
542 0 };
543 0 ▶ if($p{is_blocking}){
Branch: 1 branch
BranchTrueFalseTotal
if ($p{'is_blocking'}) { } 0 0 0
544 0 my $group_info = $self->_get_group_info($group->code);
545 0 $handle->($group_info);
546 }
547 else{
548 0 $self->_get_group_info($group->code,$handle);
549 }
550 }
551 0 ▶sub update_group {
Subroutine update_group: not called CC=15 SCAR=54.8
Pod undocumented
552 0 my $self = shift;
553 0 ▶ if(ref $_[0] eq "Mojo::Webqq::Group"){
Branch: 1 branch
BranchTrueFalseTotal
if (ref $_[0] eq "Mojo::Webqq::Group") 0 0 0
554 0 my $group = shift;
555 0 my %p = @_;
556 0 ▶ $p{is_blocking} = 1 if not defined $p{is_blocking};
Branch: 1 branch
BranchTrueFalseTotal
unless defined $p{"is_blocking"} 0 0 0
557 0 ▶ $p{is_update_group_member} = 1 if not defined $p{is_update_group_member} ;
Branch: 1 branch
BranchTrueFalseTotal
unless defined $p{"is_update_group_member"} 0 0 0
558 0 ▶ $p{is_update_group_ext} = $p{is_blocking} if not defined $p{is_update_group_ext} ;
Branch: 1 branch
BranchTrueFalseTotal
unless defined $p{"is_update_group_ext"} 0 0 0
559 0 ▶ $p{is_update_group_member_ext} = $p{is_update_group_ext} && $p{is_blocking} if not defined $p{is_update_group_member_ext} ;
Branch: 1 branch
BranchTrueFalseTotal
unless defined $p{"is_update_group_member_ext"} 0 0 0
Condition0%0/3
$p{'is_update_group_ext'} && $p{'is_blocking'}
!ll&&!rl&&r
000
MC/DC0%0/2
$p{'is_update_group_ext'} && $p{'is_blocking'}
$p{'is_update_group_ext'} $p{'is_blocking'}
Truth table0%0/3
A && B
A= $p{'is_update_group_ext'}B= $p{'is_blocking'}
ABresult
0X0
100
111
560 0 ▶ my $handle = sub{
Subroutine __ANON__: not called CC=4 SCAR=30.0
561 0 my $group_info = shift;
562 0 ▶ if(defined $group_info){
Branch: 1 branch
BranchTrueFalseTotal
if (defined $group_info) { } 0 0 0
563 0 ▶ if(ref $group_info->{member} eq 'ARRAY'){
Branch: 1 branch
BranchTrueFalseTotal
if (ref $group_info->{'member'} eq 'ARRAY') { } 0 0 0
564 0 $self->info("更新群组[ ". $group->name . " ]信息");
565 0 $group->update($group_info);
566 0 ▶ $self->update_group_ext($group,%p) if $p{is_update_group_ext};
Branch: 1 branch
BranchTrueFalseTotal
if $p{"is_update_group_ext"} 0 0 0
567 }
568 0 else{$self->debug("更新群组[ " . $group->name . " ]成员信息无效")}
569 }
570 0 else{$self->warn("更新群组[ " . $group->name . " ]成员信息失败")}
571  
572 0 };
573 0 ▶ if($p{is_blocking}){
Branch: 1 branch
BranchTrueFalseTotal
if ($p{'is_blocking'}) { } 0 0 0
574 0 my $group_info = $self->_get_group_info($group->code);
575 0 $handle->($group_info);
576 }
577 else{
578 0 $self->_get_group_info($group->code,$handle);
579 }
580 0 return $self;
581 }
582 0 my %p = @_;
583 0 ▶ $p{is_blocking} = 1 if not defined $p{is_blocking} ;
Branch: 1 branch
BranchTrueFalseTotal
unless defined $p{"is_blocking"} 0 0 0
584 0 ▶ $p{is_update_group_member} = 1 if not defined $p{is_update_group_member} ;
Branch: 1 branch
BranchTrueFalseTotal
unless defined $p{"is_update_group_member"} 0 0 0
585 0 ▶ $p{is_update_group_ext} = $p{is_blocking} if not defined $p{is_update_group_ext} ;
Branch: 1 branch
BranchTrueFalseTotal
unless defined $p{"is_update_group_ext"} 0 0 0
586 0 ▶ $p{is_update_group_member_ext} = $p{is_blocking} && $p{is_update_group_ext} && $p{is_update_group_member} if not defined $p{is_update_group_member_ext} ;
Branch: 1 branch
BranchTrueFalseTotal
unless defined $p{"is_update_group_member_ext"} 0 0 0
Condition0%0/6
$p{'is_blocking'} && $p{'is_update_group_ext'} && $p{'is_update_group_member'}
!ll&&!rl&&r
000
$p{"is_blocking"} and $p{"is_update_group_ext"}
!ll&&!rl&&r
000
MC/DC0%0/3
$p{'is_blocking'} && $p{'is_update_group_ext'} && $p{'is_update_group_member'}
$p{"is_blocking"} $p{"is_update_group_ext"} $p{'is_update_group_member'}
Truth table0%0/4
A and B && C
A= $p{"is_blocking"}B= $p{"is_update_group_ext"}C= $p{'is_update_group_member'}
ABCresult
0XX0
10X0
1100
1111
587 0 ▶ my $handle = sub{
Subroutine __ANON__: not called CC=13 SCAR=52.0
588 0 my @groups;
589 0 my $group_list = shift;
590 0 ▶ unless(defined $group_list){
Branch: 1 branch
BranchTrueFalseTotal
unless (defined $group_list) 0 0 0
591 0 $self->warn("更新群列表信息失败\n");
592 0 $self->emit("model_update","group",0);
593 0 return $self;
594 }
595 0 $self->info("更新群列表信息...");
596 0 for my $g (@{$group_list}){
597 0 push @groups, Mojo::Webqq::Group->new($g);
598 }
599 0 ▶ if(ref $self->group eq "ARRAY" and @{$self->group} == 0){
Branch: 1 branch
BranchTrueFalseTotal
if (ref $self->group eq 'ARRAY' and @{$self->group;} == 0) { } 0 0 0
Condition0%0/3
ref $self->group eq "ARRAY" and @{$self->group;} == 0
!ll&&!rl&&r
000
MC/DC0%0/2
ref $self->group eq "ARRAY" and @{$self->group;} == 0
ref $self->group eq "ARRAY" @{$self->group;} == 0
Truth table0%0/3
A and B
A= ref $self->group eq "ARRAY"B= @{$self->group;} == 0
ABresult
0X0
100
111
600 0 $self->group(\@groups);
601 }
602 else{
603 0 ▶ my($new_groups,$lost_groups,$sames) = $self->array_diff($self->group,\@groups,sub{$_[0]->id});
Subroutine __ANON__: not called CC=1 SCAR=6.9
604 0 for(@{$new_groups}){
605 0 $self->add_group($_);
606 0 $self->emit(new_group=>$_) ;
607 }
608 0 for(@{$lost_groups}){
609 0 $self->remove_group($_);
610 0 $self->emit(lose_group=>$_) ;
611 }
612 0 for(@{$sames}){
613 0 my($old_group,$new_group) = ($_->[0],$_->[1]);
614 0 $old_group->update($new_group);
615 }
616 }
617 0 $self->emit("model_update","group",1);
618 0 ▶ if($p{is_update_group_member}){
Branch: 1 branch
BranchTrueFalseTotal
if ($p{"is_update_group_member"}) 0 0 0
619 0 ▶ if($p{is_blocking}){
Branch: 1 branch
BranchTrueFalseTotal
if ($p{'is_blocking'}) { } 0 0 0
620 0 for(@{ $self->group }){
621 0 $self->update_group_member($_,%p);
622 }
623 }
624 else{
625 0 my $i = -3;
626 0 for my $g (@{ $self->group }){
627 0 ▶ $self->timer($i+3,sub{$self->update_group_member($g,%p)});
Subroutine __ANON__: not called CC=1 SCAR=6.9
628 0 $i++;
629 }
630 }
631 }
632 0 ▶ if($p{is_update_group_ext}){
Branch: 1 branch
BranchTrueFalseTotal
if ($p{"is_update_group_ext"}) 0 0 0
633 0 $self->update_group_ext(%p);
634 }
635 0 };
636  
637 0 ▶ if($p{is_blocking}){
Branch: 1 branch
BranchTrueFalseTotal
if ($p{'is_blocking'}) { } 0 0 0
638 0 my $group_list = $self->_get_group_list_info();
639 0 $handle->($group_list);
640 }
641 else{
642 0 $self->_get_group_list_info($handle);
643 }
644 }
645  
646 0 ▶sub search_group {
Subroutine search_group: not called CC=5 SCAR=31.7
Pod undocumented
647 1 ▶ no warnings 'uninitialized';
Subroutine BEGIN: called CC=1 SCAR=0.0
648 0 my $self = shift;
649 0 my %p = @_;
650 0 ▶ return if 0 == grep {defined $p{$_}} keys %p;
Branch: 1 branch
BranchTrueFalseTotal
if 0 == grep({defined $p{$_};} keys %p) 0 0 0
651 0 ▶ $self->update_group(is_update_group_member=>0) if @{ $self->group } == 0;
Branch: 1 branch
BranchTrueFalseTotal
if @{$self->group;} == 0 0 0 0
652 0 delete $p{member};
653 0 ▶ if(wantarray){
Branch: 1 branch
BranchTrueFalseTotal
if (wantarray) { } 0 0 0
654 0 ▶ return grep {my $g = $_;(first {$p{$_} ne $g->$_} grep {defined $p{$_}} keys %p) ? 0 : 1;} @{$self->group};
Subroutine __ANON__: not called CC=1 SCAR=6.9
Branch: 1 branch
BranchTrueFalseTotal
&first(sub { $p{$_} ne $g->$_; } , grep({defined $p{$_};} keys %p)) ? : 0 0 0
655 }
656 else{
657 0 ▶ return first {my $g = $_;(first {$p{$_} ne $g->$_} grep {defined $p{$_}} keys %p) ? 0 : 1;} @{$self->group};
Subroutine __ANON__: not called CC=2 SCAR=17.9
Subroutine __ANON__: not called CC=1 SCAR=6.9
Branch: 1 branch
BranchTrueFalseTotal
&first(sub { $p{$_} ne $g->$_; } , grep({defined $p{$_};} keys %p)) ? : 0 0 0
658 }
659 }
660  
661 0 ▶sub search_group_member {
Subroutine search_group_member: not called CC=7 SCAR=38.3
Pod undocumented
662 1 ▶ no warnings 'uninitialized';
Subroutine BEGIN: called CC=1 SCAR=0.0
663 0 my $self = shift;
664 0 my %p = @_;
665 0 ▶ return if 0 == grep {defined $p{$_}} keys %p;
Branch: 1 branch
BranchTrueFalseTotal
if 0 == grep({defined $p{$_};} keys %p) 0 0 0
666 0 ▶ if(@{$self->group} == 0){
Branch: 1 branch
BranchTrueFalseTotal
if (@{$self->group;} == 0) { } 0 0 0
667 0 $self->update_group(is_blocking=>1,is_update_group_member=>1);
668 }
669 else{
670 0 for( @{$self->group}){
671 0 ▶ $_->update_group_member(is_blocking=>1,) if $_->is_empty;
Branch: 1 branch
BranchTrueFalseTotal
if $_->is_empty 0 0 0
672 }
673 }
674 0 my @member = map {@{$_->member}} grep {ref $_->member eq "ARRAY"} @{$self->group};
675 0 ▶ if(wantarray){
Branch: 1 branch
BranchTrueFalseTotal
if (wantarray) { } 0 0 0
676 0 ▶ return grep {my $m = $_;(first {$p{$_} ne $m->$_} grep {defined $p{$_}} keys %p) ? 0 : 1;} @member;
Subroutine __ANON__: not called CC=1 SCAR=6.9
Branch: 1 branch
BranchTrueFalseTotal
&first(sub { $p{$_} ne $m->$_; } , grep({defined $p{$_};} keys %p)) ? : 0 0 0
677 }
678 else{
679 0 ▶ return first {my $m = $_;(first {$p{$_} ne $m->$_} grep {defined $p{$_}} keys %p) ? 0 : 1;} @member;
Subroutine __ANON__: not called CC=2 SCAR=17.9
Subroutine __ANON__: not called CC=1 SCAR=6.9
Branch: 1 branch
BranchTrueFalseTotal
&first(sub { $p{$_} ne $m->$_; } , grep({defined $p{$_};} keys %p)) ? : 0 0 0
680 }
681 }
682  
683 0 ▶sub add_discuss {
Subroutine add_discuss: not called CC=5 SCAR=34.0
Pod undocumented
684 0 my $self = shift;
685 0 my $discuss = shift;
686 0 my $nocheck = shift;
687 0 ▶ $self->die("不支持的数据类型") if ref $discuss ne "Mojo::Webqq::Discuss";
Branch: 1 branch
BranchTrueFalseTotal
if ref $discuss ne "Mojo::Webqq::Discuss" 0 0 0
688 0 ▶ if(@{$self->discuss} == 0){
Branch: 1 branch
BranchTrueFalseTotal
if (@{$self->discuss;} == 0) 0 0 0
689 0 push @{$self->discuss},$discuss;
690 0 return $self;
691 }
692 0 ▶ if($nocheck){
Branch: 1 branch
BranchTrueFalseTotal
if ($nocheck) 0 0 0
693 0 push @{$self->discuss},$discuss;
694 0 return $self;
695 }
696 0 my $d = $self->search_discuss(id => $discuss->id);
697 0 ▶ if(defined $d){
Branch: 1 branch
BranchTrueFalseTotal
if (defined $d) { } 0 0 0
698 0 %$d = %$discuss;
699 }
700 else{#new discuss
701 0 push @{$self->discuss},$discuss;
702 }
703 0 return $self;
704  
705 }
706 0 ▶sub remove_discuss {
Subroutine remove_discuss: not called CC=4 SCAR=30.0
Pod undocumented
707 0 my $self = shift;
708 0 my $discuss = shift;
709 0 ▶ $self->die("不支持的数据类型") if ref $discuss ne "Mojo::Webqq::Discuss";
Branch: 1 branch
BranchTrueFalseTotal
if ref $discuss ne "Mojo::Webqq::Discuss" 0 0 0
710 0 ▶ for(my $i=0;@{$self->discuss};$i++){
Branch: 1 branch
BranchTrueFalseTotal
if (@{$self->discuss;}) 0 0 0
711 0 ▶ if($discuss->id eq $self->discuss->[$i]->id){
Branch: 1 branch
BranchTrueFalseTotal
if ($discuss->id eq $self->discuss->[$i]->id) 0 0 0
712 0 splice @{$self->discuss},$i,1;
713 0 return 1;
714 }
715 }
716 0 return 0;
717 }
718  
719 0 ▶sub add_discuss_member {}
Subroutine add_discuss_member: not called CC=1 SCAR=0.0
Pod undocumented
720  
721 0 ▶sub update_discuss_member{
Subroutine update_discuss_member: not called CC=4 SCAR=30.0
Pod undocumented
722 0 my $self = shift;
723 0 my $discuss = shift;
724 0 ▶ $self->die("不支持的数据类型") if ref $discuss ne "Mojo::Webqq::Discuss";
Branch: 1 branch
BranchTrueFalseTotal
if ref $discuss ne "Mojo::Webqq::Discuss" 0 0 0
725 0 $self->info("更新讨论组[ ". $discuss->name . " ]成员信息");
726 0 my %p = @_;
727 0 ▶ $p{is_blocking} = 1 if not defined $p{is_blocking};
Branch: 1 branch
BranchTrueFalseTotal
unless defined $p{"is_blocking"} 0 0 0
728 0 ▶ my $handle = sub{
Subroutine __ANON__: not called CC=3 SCAR=24.8
729 0 my $discuss_info = shift;
730 0 ▶ if(defined $discuss_info){
Branch: 1 branch
BranchTrueFalseTotal
if (defined $discuss_info) { } 0 0 0
731 0 ▶ if(ref $discuss_info->{member} eq 'ARRAY'){
Branch: 1 branch
BranchTrueFalseTotal
if (ref $discuss_info->{'member'} eq 'ARRAY') { } 0 0 0
732 0 $discuss->update($discuss_info);
733 }
734 0 else{$self->debug("更新讨论组[ " . $discuss->name . " ]成员信息无效")}
735 }
736 0 else{$self->warn("更新讨论组[ " . $discuss->name . " ]成员信息失败")}
737 0 };
738  
739 0 ▶ if($p{is_blocking}){
Branch: 1 branch
BranchTrueFalseTotal
if ($p{'is_blocking'}) { } 0 0 0
740 0 my $discuss_info = $self->_get_discuss_info($discuss->id);
741 0 $handle->($discuss_info);
742 }
743 else{
744 0 $self->_get_discuss_info($discuss->id,$handle);
745 }
746
747 }
748 0 ▶sub update_discuss {
Subroutine update_discuss: not called CC=7 SCAR=40.3
Pod undocumented
749 0 my $self = shift;
750 0 ▶ if(ref $_[0] eq "Mojo::Webqq::Discuss"){
Branch: 1 branch
BranchTrueFalseTotal
if (ref $_[0] eq "Mojo::Webqq::Discuss") 0 0 0
751 0 my $discuss = shift;
752 0 my %p = @_;
753 0 $self->info("更新讨论组[ ". $discuss->name . " ]信息");
754 0 ▶ $p{is_blocking} = 1 if not defined $p{is_blocking};
Branch: 1 branch
BranchTrueFalseTotal
unless defined $p{"is_blocking"} 0 0 0
755 0 ▶ my $handle = sub{
Subroutine __ANON__: not called CC=3 SCAR=24.8
756 0 my $discuss_info = shift;
757 0 ▶ if(defined $discuss_info){
Branch: 1 branch
BranchTrueFalseTotal
if (defined $discuss_info) { } 0 0 0
758 0 ▶ if(ref $discuss_info->{member} eq 'ARRAY'){
Branch: 1 branch
BranchTrueFalseTotal
if (ref $discuss_info->{'member'} eq 'ARRAY') { } 0 0 0
759 0 $discuss->update($discuss_info);
760 }
761 0 else{$self->debug("更新讨论组[ " . $discuss->name . " ]成员信息无效")}
762 }
763 0 else{$self->warn("更新讨论组[ " . $discuss->name . " ]成员信息失败")}
764  
765 0 };
766 0 ▶ if($p{is_blocking}){
Branch: 1 branch
BranchTrueFalseTotal
if ($p{'is_blocking'}) { } 0 0 0
767 0 my $discuss_info = $self->_get_discuss_info($discuss->id);
768 0 $handle->($discuss_info);
769 }
770 else{
771 0 $self->_get_discuss_info($discuss->id,$handle);
772 }
773 0 return $self;
774 }
775 0 my %p = @_;
776 0 ▶ $p{is_blocking} = 1 if not defined $p{is_blocking} ;
Branch: 1 branch
BranchTrueFalseTotal
unless defined $p{"is_blocking"} 0 0 0
777 0 ▶ $p{is_update_discuss_member} = 1 if not defined $p{is_update_discuss_member} ;
Branch: 1 branch
BranchTrueFalseTotal
unless defined $p{"is_update_discuss_member"} 0 0 0
778 0 $self->info("更新讨论组列表信息...");
779 0 ▶ my $handle = sub{
Subroutine __ANON__: not called CC=10 SCAR=47.0
780 0 my @discusss;
781 0 my $discuss_list = shift;
782 0 ▶ unless(defined $discuss_list){
Branch: 1 branch
BranchTrueFalseTotal
unless (defined $discuss_list) 0 0 0
783 0 $self->warn("更新讨论列表信息失败\n");
784 0 $self->emit("model_update","discuss",0);
785 0 return $self;
786 }
787 0 for my $d (@{$discuss_list}){
788 0 push @discusss, Mojo::Webqq::Discuss->new($d);
789 }
790 0 ▶ if(ref $self->discuss eq "ARRAY" and @{$self->discuss} == 0){
Branch: 1 branch
BranchTrueFalseTotal
if (ref $self->discuss eq 'ARRAY' and @{$self->discuss;} == 0) { } 0 0 0
Condition0%0/3
ref $self->discuss eq "ARRAY" and @{$self->discuss;} == 0
!ll&&!rl&&r
000
MC/DC0%0/2
ref $self->discuss eq "ARRAY" and @{$self->discuss;} == 0
ref $self->discuss eq "ARRAY" @{$self->discuss;} == 0
Truth table0%0/3
A and B
A= ref $self->discuss eq "ARRAY"B= @{$self->discuss;} == 0
ABresult
0X0
100
111
791 0 $self->discuss(\@discusss);
792 }
793 else{
794 0 ▶ my($new_discusss,$lost_discusss,$sames) = $self->array_diff($self->discuss,\@discusss,sub{$_[0]->did});
Subroutine __ANON__: not called CC=1 SCAR=6.9
795 0 for(@{$new_discusss}){
796 0 $self->add_discuss($_);
797 0 $self->emit(new_discuss=>$_) ;
798 }
799 0 for(@{$lost_discusss}){
800 0 $self->remove_discuss($_);
801 0 $self->emit(lose_discuss=>$_) ;
802 }
803 0 for(@{$sames}){
804 0 my($old_discuss,$new_discuss) = ($_->[0],$_->[1]);
805 0 $old_discuss->update($new_discuss);
806 }
807 }
808 0 $self->emit("model_update","discuss",1);
809 0 ▶ if($p{is_update_discuss_member}){
Branch: 1 branch
BranchTrueFalseTotal
if ($p{"is_update_discuss_member"}) 0 0 0
810 0 for(@{ $self->discuss }){
811 0 $self->update_discuss_member($_,%p);
812 }
813 }
814 0 };
815 0 ▶ if($p{is_blocking}){
Branch: 1 branch
BranchTrueFalseTotal
if ($p{'is_blocking'}) { } 0 0 0
816 0 my $discuss_list = $self->_get_discuss_list_info();
817 0 $handle->($discuss_list);
818 }
819 else{
820 0 $self->_get_discuss_list_info($handle);
821 }
822 }
823  
824 0 ▶sub search_discuss {
Subroutine search_discuss: not called CC=5 SCAR=31.7
Pod undocumented
825 1 ▶ no warnings 'uninitialized';
Subroutine BEGIN: called CC=1 SCAR=0.0
826 0 my $self = shift;
827 0 my %p = @_;
828 0 ▶ return if 0 == grep {defined $p{$_}} keys %p;
Branch: 1 branch
BranchTrueFalseTotal
if 0 == grep({defined $p{$_};} keys %p) 0 0 0
829 0 ▶ $self->update_discuss(is_blocking=>1,is_update_discuss_member=>0) if @{$self->discuss} == 0;
Branch: 1 branch
BranchTrueFalseTotal
if @{$self->discuss;} == 0 0 0 0
830 0 delete $p{member};
831 0 ▶ if(wantarray){
Branch: 1 branch
BranchTrueFalseTotal
if (wantarray) { } 0 0 0
832 0 ▶ return grep {my $d = $_;(first {$p{$_} ne $d->$_} grep {defined $p{$_}} keys %p) ? 0 : 1;} @{$self->discuss};
Subroutine __ANON__: not called CC=1 SCAR=6.9
Branch: 1 branch
BranchTrueFalseTotal
&first(sub { $p{$_} ne $d->$_; } , grep({defined $p{$_};} keys %p)) ? : 0 0 0
833 }
834 else{
835 0 ▶ return first {my $d = $_;(first {$p{$_} ne $d->$_} grep {defined $p{$_}} keys %p) ? 0 : 1;} @{$self->discuss};
Subroutine __ANON__: not called CC=2 SCAR=17.9
Subroutine __ANON__: not called CC=1 SCAR=6.9
Branch: 1 branch
BranchTrueFalseTotal
&first(sub { $p{$_} ne $d->$_; } , grep({defined $p{$_};} keys %p)) ? : 0 0 0
836 }
837 }
838  
839 0 ▶sub search_discuss_member {
Subroutine search_discuss_member: not called CC=7 SCAR=38.3
Pod undocumented
840 1 ▶ no warnings 'uninitialized';
Subroutine BEGIN: called CC=1 SCAR=0.0
841 0 my $self = shift;
842 0 my %p = @_;
843 0 ▶ return if 0 == grep {defined $p{$_}} keys %p;
Branch: 1 branch
BranchTrueFalseTotal
if 0 == grep({defined $p{$_};} keys %p) 0 0 0
844 0 ▶ if(@{$self->discuss} == 0){
Branch: 1 branch
BranchTrueFalseTotal
if (@{$self->discuss;} == 0) { } 0 0 0
845 0 $self->update_discuss(is_blocking=>1,is_update_discuss_member=>1);
846 }
847 else{
848 0 for( @{$self->discuss}){
849 0 ▶ $_->update_discuss_member(is_blocking=>1,) if $_->is_empty;
Branch: 1 branch
BranchTrueFalseTotal
if $_->is_empty 0 0 0
850 }
851 }
852 0 my @member = map {@{$_->member}} grep {ref $_->member eq "ARRAY"} @{$self->discuss};
853 0 ▶ if(wantarray){
Branch: 1 branch
BranchTrueFalseTotal
if (wantarray) { } 0 0 0
854 0 ▶ return grep {my $m = $_;(first {$p{$_} ne $m->$_} grep {defined $p{$_}} keys %p) ? 0 : 1;} @member;
Subroutine __ANON__: not called CC=1 SCAR=6.9
Branch: 1 branch
BranchTrueFalseTotal
&first(sub { $p{$_} ne $m->$_; } , grep({defined $p{$_};} keys %p)) ? : 0 0 0
855 }
856 else{
857 0 ▶ return first {my $m = $_;(first {$p{$_} ne $m->$_} grep {defined $p{$_}} keys %p) ? 0 : 1;} @member;
Subroutine __ANON__: not called CC=2 SCAR=17.9
Subroutine __ANON__: not called CC=1 SCAR=6.9
Branch: 1 branch
BranchTrueFalseTotal
&first(sub { $p{$_} ne $m->$_; } , grep({defined $p{$_};} keys %p)) ? : 0 0 0
858 }
859 }
860  
861 0 ▶sub invite_friend{
Subroutine invite_friend: not called CC=8 SCAR=42.8
Pod undocumented
862 0 my $self = shift;
863 0 ▶ if ( not $self->is_support_model_ext){
Branch: 1 branch
BranchTrueFalseTotal
unless ($self->is_support_model_ext) 0 0 0
864 0 $self->warn("无法支持获取扩展信息");
865 0 return;
866 }
867 0 my $group = shift;
868 0 my @friends = @_;
869 0 ▶ if(not defined $group->uid){
Branch: 1 branch
BranchTrueFalseTotal
unless (defined $group->uid) 0 0 0
870 0 $self->error("未获取到群号码,无法邀请好友入群");
871 0 return;
872 }
873 0 ▶ if($group->role ne "manage" and $group->role ne "create"){
Branch: 1 branch
BranchTrueFalseTotal
if ($group->role ne "manage" and $group->role ne "create") 0 0 0
Condition0%0/3
$group->role ne "manage" and $group->role ne "create"
!ll&&!rl&&r
000
MC/DC0%0/2
$group->role ne "manage" and $group->role ne "create"
$group->role ne "manage" $group->role ne "create"
Truth table0%0/3
A and B
A= $group->role ne "manage"B= $group->role ne "create"
ABresult
0X0
100
111
874 0 $self->error("非群主或管理员,无法邀请好友入群");
875 0 return;
876 }
877 0 for(@friends){
878 0 ▶ $self->die("非好友对象") if not $_->is_friend;
Branch: 1 branch
BranchTrueFalseTotal
unless $_->is_friend 0 0 0
879 }
880 0 my $ret = $self->_invite_friend($group->uid,map {$_->uid} @friends);
881 0 ▶ if($ret){$self->info("邀请好友入群成功")}
Branch: 1 branch
BranchTrueFalseTotal
if ($ret) { } 0 0 0
882 0 else{$self->error("邀请好友入群失败")}
883 0 return $ret;
884 }
885 0 ▶sub kick_group_member{
Subroutine kick_group_member: not called CC=9 SCAR=45.0
Pod undocumented
886 0 my $self = shift;
887 0 ▶ if ( not $self->is_support_model_ext){
Branch: 1 branch
BranchTrueFalseTotal
unless ($self->is_support_model_ext) 0 0 0
888 0 $self->warn("无法支持获取扩展信息");
889 0 return;
890 }
891 0 my $group = shift;
892 0 my @members = @_;
893 0 ▶ if(not defined $group->uid){
Branch: 1 branch
BranchTrueFalseTotal
unless (defined $group->uid) 0 0 0
894 0 $self->error("未获取到群号码,无法踢除群成员");
895 0 return;
896 }
897 0 ▶ if($group->role ne "manage" and $group->role ne "create"){
Branch: 1 branch
BranchTrueFalseTotal
if ($group->role ne "manage" and $group->role ne "create") 0 0 0
Condition0%0/3
$group->role ne "manage" and $group->role ne "create"
!ll&&!rl&&r
000
MC/DC0%0/2
$group->role ne "manage" and $group->role ne "create"
$group->role ne "manage" $group->role ne "create"
Truth table0%0/3
A and B
A= $group->role ne "manage"B= $group->role ne "create"
ABresult
0X0
100
111
898 0 $self->error("非群主或管理员,无法踢除群成员");
899 0 return;
900 }
901 0 for(@members){
902 0 ▶ $self->die("非群成员对象") if not $_->is_group_member;
Branch: 1 branch
BranchTrueFalseTotal
unless $_->is_group_member 0 0 0
903 }
904 0 my $ret = $self->_kick_group_member($group->uid,map {$_->uid} @members);
905 0 ▶ if($ret){
Branch: 1 branch
BranchTrueFalseTotal
if ($ret) { } 0 0 0
906 0 for(@members){
907 0 $_->group->remove_group_member($_);
908 0 $self->emit(lose_group_member=>$_);
909 }
910 0 $self->info("踢除群成员成功");
911 }
912 0 else{$self->error("剔除群成员失败")}
913 0 return $ret;
914 }
915  
916 0 ▶sub shutup_group_member{
Subroutine shutup_group_member: not called CC=11 SCAR=48.8
Pod undocumented
917 0 my $self = shift;
918 0 ▶ if ( not $self->is_support_model_ext){
Branch: 1 branch
BranchTrueFalseTotal
unless ($self->is_support_model_ext) 0 0 0
919 0 $self->warn("无法支持获取扩展信息");
920 0 return;
921 }
922 0 my $group = shift;
923 0 my $time = shift;
924 0 my @members = @_;
925 0 ▶ if($time<60){
Branch: 1 branch
BranchTrueFalseTotal
if ($time < 60) 0 0 0
926 0 $self->error("禁言时间太短,至少1分钟");
927 0 return;
928 }
929 0 ▶ if(not defined $group->uid){
Branch: 1 branch
BranchTrueFalseTotal
unless (defined $group->uid) 0 0 0
930 0 $self->error("未获取到群号码,无法完成禁言操作");
931 0 return;
932 }
933 0 ▶ if($group->role ne "manage" and $group->role ne "create"){
Branch: 1 branch
BranchTrueFalseTotal
if ($group->role ne "manage" and $group->role ne "create") 0 0 0
Condition0%0/3
$group->role ne "manage" and $group->role ne "create"
!ll&&!rl&&r
000
MC/DC0%0/2
$group->role ne "manage" and $group->role ne "create"
$group->role ne "manage" $group->role ne "create"
Truth table0%0/3
A and B
A= $group->role ne "manage"B= $group->role ne "create"
ABresult
0X0
100
111
934 0 $self->error("非群主或管理员,无法完成禁言操作");
935 0 return;
936 }
937 0 for(@members){
938 0 ▶ $self->die("非群成员对象") if not $_->is_group_member;
Branch: 1 branch
BranchTrueFalseTotal
unless $_->is_group_member 0 0 0
939 0 ▶ if($_->role eq "admin" or $_->role eq "owner"){
Branch: 1 branch
BranchTrueFalseTotal
if ($_->role eq "admin" or $_->role eq "owner") 0 0 0
Condition0%0/3
$_->role eq "admin" or $_->role eq "owner"
l!l&&r!l&&!r
000
MC/DC0%0/2
$_->role eq "admin" or $_->role eq "owner"
$_->role eq "admin" $_->role eq "owner"
Truth table0%0/3
A or B
A= $_->role eq "admin"B= $_->role eq "owner"
ABresult
1X1
011
000
940 0 $self->error("无法对群主或管理员进行禁言操作");
941 0 return;
942 }
943 }
944 0 my $ret = $self->_shutup_group_member($group->uid,$time,map {$_->uid} @members);
945 0 ▶ if($ret){$self->info("禁言操作成功");}
Branch: 1 branch
BranchTrueFalseTotal
if ($ret) { } 0 0 0
946 0 else{$self->error("禁言操作失败");}
947 0 return $ret;
948 }
949 0 ▶sub speakup_group_member{
Subroutine speakup_group_member: not called CC=10 SCAR=47.0
Pod undocumented
950 0 my $self = shift;
951 0 ▶ if ( not $self->is_support_model_ext){
Branch: 1 branch
BranchTrueFalseTotal
unless ($self->is_support_model_ext) 0 0 0
952 0 $self->warn("无法支持获取扩展信息");
953 0 return;
954 }
955 0 my $group = shift;
956 0 my @members = @_;
957 0 ▶ if(not defined $group->uid){
Branch: 1 branch
BranchTrueFalseTotal
unless (defined $group->uid) 0 0 0
958 0 $self->error("未获取到群号码,无法完成禁言操作");
959 0 return;
960 }
961 0 ▶ if($group->role ne "manage" and $group->role ne "create"){
Branch: 1 branch
BranchTrueFalseTotal
if ($group->role ne "manage" and $group->role ne "create") 0 0 0
Condition0%0/3
$group->role ne "manage" and $group->role ne "create"
!ll&&!rl&&r
000
MC/DC0%0/2
$group->role ne "manage" and $group->role ne "create"
$group->role ne "manage" $group->role ne "create"
Truth table0%0/3
A and B
A= $group->role ne "manage"B= $group->role ne "create"
ABresult
0X0
100
111
962 0 $self->error("非群主或管理员,无法完成禁言操作");
963 0 return;
964 }
965 0 for(@members){
966 0 ▶ $self->die("非群成员对象") if not $_->is_group_member;
Branch: 1 branch
BranchTrueFalseTotal
unless $_->is_group_member 0 0 0
967 0 ▶ if($_->role eq "admin" or $_->role eq "owner"){
Branch: 1 branch
BranchTrueFalseTotal
if ($_->role eq "admin" or $_->role eq "owner") 0 0 0
Condition0%0/3
$_->role eq "admin" or $_->role eq "owner"
l!l&&r!l&&!r
000
MC/DC0%0/2
$_->role eq "admin" or $_->role eq "owner"
$_->role eq "admin" $_->role eq "owner"
Truth table0%0/3
A or B
A= $_->role eq "admin"B= $_->role eq "owner"
ABresult
1X1
011
000
968 0 $self->error("无法对群主或管理员进行取消禁言操作");
969 0 return;
970 }
971 }
972 0 my $ret = $self->_shutup_group_member($group->uid,0,map {$_->uid} @members);
973 0 ▶ if($ret){$self->info("取消禁言操作成功");}
Branch: 1 branch
BranchTrueFalseTotal
if ($ret) { } 0 0 0
974 0 else{$self->error("取消禁言操作失败");}
975 0 return $ret;
976 }
977 0 ▶sub set_group_admin{
Subroutine set_group_admin: not called CC=8 SCAR=42.8
Pod undocumented
978 0 my $self = shift;
979 0 ▶ if ( not $self->is_support_model_ext){
Branch: 1 branch
BranchTrueFalseTotal
unless ($self->is_support_model_ext) 0 0 0
980 0 $self->warn("无法支持获取扩展信息");
981 0 return;
982 }
983 0 my $group = shift;
984 0 my @members = @_;
985 0 ▶ if(not defined $group->uid){
Branch: 1 branch
BranchTrueFalseTotal
unless (defined $group->uid) 0 0 0
986 0 $self->error("未获取到群号码,无法设置管理员");
987 0 return;
988 }
989 0 ▶ if($group->role ne "create"){
Branch: 1 branch
BranchTrueFalseTotal
if ($group->role ne "create") 0 0 0
990 0 $self->error("非群主,无法设置管理员");
991 0 return;
992 }
993 0 for(@members){
994 0 ▶ $self->die("非群成员对象") if not $_->is_group_member;
Branch: 1 branch
BranchTrueFalseTotal
unless $_->is_group_member 0 0 0
995 }
996 0 my $ret = $self->_set_group_admin($group->uid,map {$_->uid} @members);
997 0 ▶ if($ret){
Branch: 1 branch
BranchTrueFalseTotal
if ($ret) { } 0 0 0
998 0 $_->role("admin") for(@members);
999 0 $self->info("设置管理员成功");
1000 }
1001 0 else{$self->error("设置管理员失败")}
1002 0 return $ret;
1003 }
1004 0 ▶sub remove_group_admin{
Subroutine remove_group_admin: not called CC=7 SCAR=40.3
Pod undocumented
1005 0 my $self = shift;
1006 0 my $group = shift;
1007 0 my @members = @_;
1008 0 ▶ if(not defined $group->uid){
Branch: 1 branch
BranchTrueFalseTotal
unless (defined $group->uid) 0 0 0
1009 0 $self->error("未获取到群号码,无法移除管理员");
1010 0 return;
1011 }
1012 0 ▶ if($group->role ne "create"){
Branch: 1 branch
BranchTrueFalseTotal
if ($group->role ne "create") 0 0 0
1013 0 $self->error("非群主,无法移除管理员");
1014 0 return;
1015 }
1016 0 for(@members){
1017 0 ▶ $self->die("非群成员对象") if not $_->is_group_member;
Branch: 1 branch
BranchTrueFalseTotal
unless $_->is_group_member 0 0 0
1018 }
1019 0 my $ret = $self->_remove_group_admin($group->uid,map {$_->uid} @members);
1020 0 ▶ if($ret){
Branch: 1 branch
BranchTrueFalseTotal
if ($ret) { } 0 0 0
1021 0 $_->role("member") for(@members);
1022 0 $self->info("移除管理员成功");
1023 }
1024 0 else{$self->error("移除管理员失败")}
1025 0 return $ret;
1026 }
1027 0 ▶sub set_group_member_card{
Subroutine set_group_member_card: not called CC=8 SCAR=42.8
Pod undocumented
1028 0 my $self = shift;
1029 0 my $group = shift;
1030 0 my $member = shift;
1031 0 my $card = shift;
1032 0 ▶ if(not defined $group->uid){
Branch: 1 branch
BranchTrueFalseTotal
unless (defined $group->uid) 0 0 0
1033 0 $self->error("未获取到群号码,无法设置群名片");
1034 0 return;
1035 }
1036 0 ▶ if(!$member->is_me and $group->role ne "create" and $group->role ne "manage"){
Branch: 1 branch
BranchTrueFalseTotal
if (not $member->is_me and $group->role ne "create" and $group->role ne "manage") 0 0 0
Condition0%0/6
not $member->is_me and $group->role ne "create" and $group->role ne "manage"
!ll&&!rl&&r
000
not $member->is_me and $group->role ne "create"
!ll&&!rl&&r
000
MC/DC0%0/3
not $member->is_me and $group->role ne "create" and $group->role ne "manage"
not $member->is_me $group->role ne "create" $group->role ne "manage"
Truth table0%0/4
not(A) and B and C
A= not $member->is_meB= $group->role ne "create"C= $group->role ne "manage"
ABCresult
0XX0
10X0
1100
1111
1037 0 $self->error("非群主或管理员,无法设置其他人群名片");
1038 0 return;
1039 }
1040 0 ▶ $self->die("非群成员对象") if not $member->is_group_member;
Branch: 1 branch
BranchTrueFalseTotal
unless $member->is_group_member 0 0 0
1041 0 my $ret = $self->_set_group_member_card($group->uid,$member->uid,$card);
1042 0 ▶ if($ret){
Branch: 1 branch
BranchTrueFalseTotal
if ($ret) { } 0 0 0
1043 0 $member->card($card);
1044 0 ▶ if(length $card){$self->info("设置群名片成功");}
Branch: 1 branch
BranchTrueFalseTotal
if (length $card) { } 0 0 0
1045 0 else{$self->info("取消群名片成功");}
1046 }
1047 0 else{$self->error("设置群名片失败")}
1048 0 return $ret;
1049 }
1050  
1051 0 ▶sub qiandao {
Subroutine qiandao: not called CC=5 SCAR=34.0
Pod undocumented
1052 0 my $self = shift;
1053 0 my $group = shift;
1054 0 ▶ if ( not $self->is_support_model_ext){
Branch: 1 branch
BranchTrueFalseTotal
unless ($self->is_support_model_ext) 0 0 0
1055 0 $self->warn("无法支持获取扩展信息, 无法进行签到");
1056 0 return;
1057 }
1058 0 ▶ $self->die("非群组对象") if not $group->is_group;
Branch: 1 branch
BranchTrueFalseTotal
unless $group->is_group 0 0 0
1059 0 ▶ if(not defined $group->uid){
Branch: 1 branch
BranchTrueFalseTotal
unless (defined $group->uid) 0 0 0
1060 0 $self->error("未获取到群号码,无法进行签到");
1061 0 return;
1062 }
1063 0 my $ret = $self->_qiandao($group->uid);
1064 0 ▶ if($ret){
Branch: 1 branch
BranchTrueFalseTotal
if ($ret) { } 0 0 0
1065 0 $self->info("群组[ ". $group->displayname ." ]签到成功");
1066 }
1067 0 else{$self->error("群组[ ". $group->displayname ." ]签到失败")}
1068 0 return $ret;
1069 }
1070  
1071 0 ▶sub friends{
Subroutine friends: not called CC=2 SCAR=17.9
Pod undocumented
1072 0 my $self = shift;
1073 0 ▶ $self->update_friend() if @{$self->friend} == 0;
Branch: 1 branch
BranchTrueFalseTotal
if @{$self->friend;} == 0 0 0 0
1074 0 return @{$self->friend};
1075 }
1076 0 ▶sub groups{
Subroutine groups: not called CC=2 SCAR=17.9
Pod undocumented
1077 0 my $self = shift;
1078 0 ▶ $self->update_group() if @{$self->group} == 0;
Branch: 1 branch
BranchTrueFalseTotal
if @{$self->group;} == 0 0 0 0
1079 0 return @{$self->group};
1080 }
1081 0 ▶sub discusss{
Subroutine discusss: not called CC=2 SCAR=17.9
Pod undocumented
1082 0 my $self = shift;
1083 0 ▶ $self->update_discuss() if @{$self->discuss} == 0;
Branch: 1 branch
BranchTrueFalseTotal
if @{$self->discuss;} == 0 0 0 0
1084 0 return @{$self->discuss};
1085 }
1086  
1087 1 1;
« Webqq/Log.pm ↑ Summary Webqq/Message/Base.pm »