| 1 | 1 | ▶ | use strict; | ||||||||||||||||||||||||||
|
Subroutine
BEGIN: called CC=1 SCAR=0.0
| |||||||||||||||||||||||||||||
| 2 | 0 | ▶ | sub Mojo::Webqq::Model::_get_group_info { | ||||||||||||||||||||||||||
|
Subroutine
_get_group_info: not called CC=3 SCAR=24.8
| |||||||||||||||||||||||||||||
| 3 | 0 | my $self = shift; | |||||||||||||||||||||||||||
| 4 | 0 | my $gcode = shift; | |||||||||||||||||||||||||||
| 5 | 0 | my $callback = shift; | |||||||||||||||||||||||||||
| 6 | 0 | my $api_url = 'https://s.web2.qq.com/api/get_group_info_ext2'; | |||||||||||||||||||||||||||
| 7 | 0 | my @query_string = ( | |||||||||||||||||||||||||||
| 8 | gcode => $gcode, | ||||||||||||||||||||||||||||
| 9 | vfwebqq => $self->vfwebqq, | ||||||||||||||||||||||||||||
| 10 | t => time(), | ||||||||||||||||||||||||||||
| 11 | ); | ||||||||||||||||||||||||||||
| 12 | |||||||||||||||||||||||||||||
| 13 | 0 | my $headers = { | |||||||||||||||||||||||||||
| 14 | Referer => 'https://s.web2.qq.com/proxy.html?v=20130916001&callback=1&id=1', | ||||||||||||||||||||||||||||
| 15 | json=>1, | ||||||||||||||||||||||||||||
| 16 | ua_request_timeout => $self->model_update_timeout, | ||||||||||||||||||||||||||||
| 17 | ua_retry_times => 3, | ||||||||||||||||||||||||||||
| 18 | }; | ||||||||||||||||||||||||||||
| 19 | 0 | ▶ | my $is_blocking = ref $callback eq "CODE"?0:1; | ||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||
| 20 | 0 | ▶ | my $handle = sub { | ||||||||||||||||||||||||||
|
Subroutine
__ANON__: not called CC=15 SCAR=54.8
| |||||||||||||||||||||||||||||
| 21 | 0 | my $json = shift; | |||||||||||||||||||||||||||
| 22 | 0 | ▶ | return unless defined $json; | ||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||
| 23 | 0 | ▶ | my $ginfo_status = exists $json->{result}{ginfo}?"[ginfo-ok]":"[ginfo-not-ok]"; | ||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||
| 24 | 0 | ▶ | my $minfo_status = ref $json->{result}{minfo} eq "ARRAY"?"[minfo-ok]":"[minfo-not-ok]"; | ||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||
| 25 | |||||||||||||||||||||||||||||
| 26 | 0 | ▶ | return undef unless exists $json->{result}{ginfo}; | ||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||
| 27 | 0 | $json->{result}{ginfo}{id} = delete $json->{result}{ginfo}{gid}; | |||||||||||||||||||||||||||
| 28 | 0 | $json->{result}{ginfo}{code} = delete $json->{result}{ginfo}{code}; | |||||||||||||||||||||||||||
| 29 | 0 | $json->{result}{ginfo}{name} = $self->xmlescape_parse($json->{result}{ginfo}{name}); | |||||||||||||||||||||||||||
| 30 | 0 | $json->{result}{ginfo}{memo} = delete $json->{result}{ginfo}{memo}; | |||||||||||||||||||||||||||
| 31 | 0 | $json->{result}{ginfo}{createtime} = delete $json->{result}{ginfo}{createtime}; | |||||||||||||||||||||||||||
| 32 | 0 | $json->{result}{ginfo}{level} = delete $json->{result}{ginfo}{level}; | |||||||||||||||||||||||||||
| 33 | 0 | $json->{result}{ginfo}{owner_id} = delete $json->{result}{ginfo}{owner}; | |||||||||||||||||||||||||||
| 34 | 0 | $json->{result}{ginfo}{markname} = $self->xmlescape_parse($json->{result}{ginfo}{markname}); | |||||||||||||||||||||||||||
| 35 | |||||||||||||||||||||||||||||
| 36 | 0 | delete $json->{result}{ginfo}{fingermemo}; | |||||||||||||||||||||||||||
| 37 | 0 | delete $json->{result}{ginfo}{face}; | |||||||||||||||||||||||||||
| 38 | 0 | delete $json->{result}{ginfo}{option}; | |||||||||||||||||||||||||||
| 39 | 0 | delete $json->{result}{ginfo}{class}; | |||||||||||||||||||||||||||
| 40 | 0 | delete $json->{result}{ginfo}{flag}; | |||||||||||||||||||||||||||
| 41 | 0 | delete $json->{result}{ginfo}{members}; | |||||||||||||||||||||||||||
| 42 | |||||||||||||||||||||||||||||
| 43 | #retcode等于0说明包含完整的ginfo和minfo | ||||||||||||||||||||||||||||
| 44 | 0 | ▶ | if(exists $json->{result}{minfo} and ref $json->{result}{minfo} eq "ARRAY"){ | ||||||||||||||||||||||||||
|
Branch: 1 branch
Condition0%0/3
exists $json->{"result"}{"minfo"} and ref $json->{"result"}{"minfo"} eq "ARRAY"
MC/DC0%0/2
exists $json->{"result"}{"minfo"} and ref $json->{"result"}{"minfo"} eq "ARRAY"
exists $json->{"result"}{"minfo"}
ref $json->{"result"}{"minfo"} eq "ARRAY"
Truth table0%0/3
A and B
A= exists $json->{"result"}{"minfo"}B= ref $json->{"result"}{"minfo"} eq "ARRAY"
| |||||||||||||||||||||||||||||
| 45 | 0 | my %cards; | |||||||||||||||||||||||||||
| 46 | 0 | ▶ | if(ref $json->{result}{cards} eq "ARRAY" and @{ $json->{result}{cards} }!=0){ | ||||||||||||||||||||||||||
|
Branch: 1 branch
Condition0%0/3
ref $json->{"result"}{"cards"} eq "ARRAY" and @{$json->{"result"}{"cards"};} != 0
MC/DC0%0/2
ref $json->{"result"}{"cards"} eq "ARRAY" and @{$json->{"result"}{"cards"};} != 0
ref $json->{"result"}{"cards"} eq "ARRAY"
@{$json->{"result"}{"cards"};} != 0
Truth table0%0/3
A and B
A= ref $json->{"result"}{"cards"} eq "ARRAY"B= @{$json->{"result"}{"cards"};} != 0
| |||||||||||||||||||||||||||||
| 47 | 0 | for (@{ $json->{result}{cards} }){ | |||||||||||||||||||||||||||
| 48 | 0 | $cards{$_->{muin}} = $_->{card}; | |||||||||||||||||||||||||||
| 49 | } | ||||||||||||||||||||||||||||
| 50 | } | ||||||||||||||||||||||||||||
| 51 | 0 | my %state; | |||||||||||||||||||||||||||
| 52 | 0 | for(@{ $json->{result}{stats} }){ | |||||||||||||||||||||||||||
| 53 | 0 | $state{$_->{uin}}{client_type} = $self->code2client($_->{client_type}); | |||||||||||||||||||||||||||
| 54 | 0 | $state{$_->{uin}}{state} = $self->code2state($_->{'stat'}); | |||||||||||||||||||||||||||
| 55 | } | ||||||||||||||||||||||||||||
| 56 | 0 | for my $m(@{ $json->{result}{minfo} }){ | |||||||||||||||||||||||||||
| 57 | 0 | ▶ | if( not $self->group_member_card_ext_only){ | ||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||
| 58 | 0 | ▶ | $m->{card} = $self->xmlescape_parse($cards{$m->{uin}}) if exists $cards{$m->{uin}}; | ||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||
| 59 | 0 | $m->{card} = $self->safe_truncate($m->{card},$self->group_member_card_cut_length); | |||||||||||||||||||||||||||
| 60 | } | ||||||||||||||||||||||||||||
| 61 | 0 | $m->{name} = $self->xmlescape_parse(delete $m->{nick}); | |||||||||||||||||||||||||||
| 62 | 0 | ▶ | if(exists $state{$m->{uin}}){ | ||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||
| 63 | 0 | $m->{state} = $state{$m->{uin}}{state}; | |||||||||||||||||||||||||||
| 64 | 0 | $m->{client_type} = $state{$m->{uin}}{client_type}; | |||||||||||||||||||||||||||
| 65 | } | ||||||||||||||||||||||||||||
| 66 | else{ | ||||||||||||||||||||||||||||
| 67 | 0 | $m->{state} = 'offline'; | |||||||||||||||||||||||||||
| 68 | 0 | $m->{client_type} = 'unknown'; | |||||||||||||||||||||||||||
| 69 | } | ||||||||||||||||||||||||||||
| 70 | 0 | $m->{_group_id} = $json->{result}{ginfo}{id}; | |||||||||||||||||||||||||||
| 71 | 0 | $m->{id} = delete $m->{uin}; | |||||||||||||||||||||||||||
| 72 | 0 | $m->{sex} = delete $m->{gender}; | |||||||||||||||||||||||||||
| 73 | } | ||||||||||||||||||||||||||||
| 74 | 0 | $json->{result}{ginfo}{member} = delete $json->{result}{minfo}; | |||||||||||||||||||||||||||
| 75 | } | ||||||||||||||||||||||||||||
| 76 | 0 | return $json->{result}{ginfo}; | |||||||||||||||||||||||||||
| 77 | 0 | }; | |||||||||||||||||||||||||||
| 78 | 0 | ▶ | if($is_blocking){ | ||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||
| 79 | 0 | return $handle->( $self->http_get($self->gen_url($api_url,@query_string),$headers,) ); | |||||||||||||||||||||||||||
| 80 | } | ||||||||||||||||||||||||||||
| 81 | else{ | ||||||||||||||||||||||||||||
| 82 | 0 | ▶ | $self->http_get($self->gen_url($api_url,@query_string),$headers,sub{ | ||||||||||||||||||||||||||
|
Subroutine
__ANON__: not called CC=1 SCAR=6.9
| |||||||||||||||||||||||||||||
| 83 | 0 | my $json = shift; | |||||||||||||||||||||||||||
| 84 | 0 | $callback->( $handle->($json) ); | |||||||||||||||||||||||||||
| 85 | 0 | }); | |||||||||||||||||||||||||||
| 86 | } | ||||||||||||||||||||||||||||
| 87 | } | ||||||||||||||||||||||||||||
| 88 | 1 | 1; | |||||||||||||||||||||||||||