Webqq/Client/Method/_send_group_message.pm

filter: Statementstmt 25.0% 10 / 40 Branchbran 0.0% 0 / 20 Conditioncond 0.0% 0 / 5 MC/DCmcdc 0.0% 0 / 3 Subroutinesub 60.0% 3 / 5 Podpod n/a totaltotal 17.8% 13 / 73 CC 13 SCAR 38.4
CC
13
Cov
15%
_send_group_message
56.0
__ANON__
56.0
BEGIN
1.0
CRAP 46.3
« Webqq/Client/Method/_send_sess_message.pm ↑ Summary Webqq/Client/Method/_get_stranger_info.pm »
1 1 ▶use JSON;
Subroutine BEGIN: called CC=1 SCAR=0.0
2 1 ▶use Encode;
Subroutine BEGIN: called CC=1 SCAR=0.0
3 1 ▶use Storable qw(dclone);
Subroutine BEGIN: called CC=1 SCAR=0.0
4 0 ▶sub Webqq::Client::_send_group_message{
Subroutine _send_group_message: not called CC=7 SCAR=40.3
5 0 my($self,$msg) = @_;
6 #将整个hash从UTF8还原回uincode编码
7 0 my $ua = $self->{asyn_ua};
8  
9 0 ▶ my $callback = sub{
Subroutine __ANON__: not called CC=7 SCAR=40.3
10 0 my $response = shift;
11 0 ▶ print $response->content() if $self->{debug};
Branch: 1 branch
BranchTrueFalseTotal
if $self->{"debug"} 0 0 0
12 0 my $status = $self->parse_send_status_msg( $response->content() );
13 0 ▶ if(defined $status and $status->{is_success} ==0){
Branch: 2 branches
BranchTrueFalseTotal
if (defined $status and $status->{'is_success'} == 0) { } 0 0 0
elsif (defined $status) { } 0 0 0
Condition0%0/3
defined $status and $status->{"is_success"} == 0
!ll&&!rl&&r
000
MC/DC0%0/2
defined $status and $status->{"is_success"} == 0
defined $status $status->{"is_success"} == 0
Truth table0%0/3
A and B
A= defined $statusB= $status->{"is_success"} == 0
ABresult
0X0
100
111
14 0 $self->send_group_message($msg);
15 0 return;
16 }
17 elsif(defined $status){
18 0 ▶ if(ref $msg->{cb} eq 'CODE'){
Branch: 1 branch
BranchTrueFalseTotal
if (ref $msg->{"cb"} eq "CODE") 0 0 0
19 $msg->{cb}->(
20 $msg, #msg
21 $status->{is_success}, #is_success
22 $status->{status} #status
23 0 );
24 }
25 0 ▶ if(ref $self->{on_send_message} eq 'CODE'){
Branch: 1 branch
BranchTrueFalseTotal
if (ref $self->{"on_send_message"} eq "CODE") 0 0 0
26 $self->{on_send_message}->(
27 $msg, #msg
28 $status->{is_success}, #is_success
29 $status->{status} #status
30 0 );
31 }
32 }
33 0 };
34
35 0 ▶ my $api_url = ($self->{qq_param}{is_https}?'https':'http') . '://d.web2.qq.com/channel/send_qun_msg2';
Branch: 1 branch
BranchTrueFalseTotal
$self->{'qq_param'}{'is_https'} ? : 0 0 0
36 0 ▶ my @headers = $self->{type} eq 'webqq'? (Referer =>'http://d.web2.qq.com/proxy.html?v=20110331002&callback=1&id=3')
Branch: 1 branch
BranchTrueFalseTotal
$self->{'type'} eq 'webqq' ? : 0 0 0
37 : (Referer =>'http://d.web2.qq.com/proxy.html?v=20130916001&callback=1&id=2')
38 ;
39 0 my $content = [decode("utf8",$msg->{content}),[]];
40 my %s = (
41 group_uin => $msg->{to_uin},
42 content => JSON->new->utf8->encode($content),
43 msg_id => $msg->{msg_id},
44 clientid => $self->{qq_param}{clientid},
45 psessionid => $self->{qq_param}{psessionid},
46 0 );
47 0 $s{content} = decode("utf8",$s{content});
48 0 ▶ if($self->{type} eq 'smartqq'){
Branch: 1 branch
BranchTrueFalseTotal
if ($self->{"type"} eq "smartqq") 0 0 0
49 0 ▶ $s{face} = $self->{qq_database}{user}{face} || "591";
Condition0%0/2
$self->{'qq_database'}{'user'}{'face'} || '591'
l!l
00
MC/DC0%0/1
$self->{'qq_database'}{'user'}{'face'} || '591'
$self->{'qq_database'}{'user'}{'face'}
Truth table0%0/2
A
A= $self->{'qq_database'}{'user'}{'face'}
Aresult
11
00
50 }
51 0 my $post_content = [
52 r => JSON->new->utf8->encode(\%s),
53 ];
54 0 ▶ if($self->{type} eq 'webqq'){
Branch: 1 branch
BranchTrueFalseTotal
if ($self->{"type"} eq "webqq") 0 0 0
55 push @$post_content,(
56 clientid => $self->{qq_param}{clientid},
57 psessionid => $self->{qq_param}{psessionid}
58 0 );
59 }
60 0 ▶ if($self->{debug}){
Branch: 1 branch
BranchTrueFalseTotal
if ($self->{"debug"}) 0 0 0
61 0 require URI;
62 0 my $uri = URI->new('http:');
63 0 $uri->query_form($post_content);
64 0 print $api_url,"\n";
65 0 print $uri->query(),"\n";
66 }
67  
68 $ua->post(
69 0 $api_url,
70 $post_content,
71 @headers,
72 $callback,
73 );
74 }
75 1 1;
« Webqq/Client/Method/_send_sess_message.pm ↑ Summary Webqq/Client/Method/_get_stranger_info.pm »