Webqq/Client/Method/_send_message.pm

filter: Statementstmt 25.0% 10 / 40 Branchbran 0.0% 0 / 20 Conditioncond 0.0% 0 / 7 MC/DCmcdc 0.0% 0 / 4 Subroutinesub 60.0% 3 / 5 Podpod n/a totaltotal 17.1% 13 / 76 CC 14 SCAR 39.9
CC
14
Cov
15%
_send_message
72.0
__ANON__
56.0
BEGIN
1.0
CRAP 53.9
« Webqq/Client/Plugin/CpanRecentModule.pm ↑ Summary Webqq/Client/Plugin/PicLimit.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_message{
Subroutine _send_message: not called CC=8 SCAR=42.8
5 0 my($self,$msg) = @_;
6 #将整个hash从UTF8还原为unicode
7 0 my $ua = $self->{asyn_ua};
8 0 ▶ my $callback = sub{
Subroutine __ANON__: not called CC=7 SCAR=40.3
9 0 my $response = shift;
10 0 ▶ print $response->content() if $self->{debug};
Branch: 1 branch
BranchTrueFalseTotal
if $self->{"debug"} 0 0 0
11 0 my $status = $self->parse_send_status_msg( $response->content() );
12 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
13 0 $self->send_message($msg);
14 0 return;
15 }
16 elsif(defined $status){
17 0 ▶ if(ref $msg->{cb} eq 'CODE'){
Branch: 1 branch
BranchTrueFalseTotal
if (ref $msg->{"cb"} eq "CODE") 0 0 0
18 $msg->{cb}->(
19 $msg, #msg
20 $status->{is_success}, #is_success
21 $status->{status} #status
22 0 );
23 }
24 0 ▶ if(ref $self->{on_send_message} eq 'CODE'){
Branch: 1 branch
BranchTrueFalseTotal
if (ref $self->{"on_send_message"} eq "CODE") 0 0 0
25 $self->{on_send_message}->(
26 $msg, #msg
27 $status->{is_success}, #is_success
28 $status->{status} #status
29 0 );
30 }
31 }
32 0 };
33 0 ▶ my $api_url = ($self->{qq_param}{is_https}?'https':'http') . '://d.web2.qq.com/channel/send_buddy_msg2';
Branch: 1 branch
BranchTrueFalseTotal
$self->{'qq_param'}{'is_https'} ? : 0 0 0
34 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
35 : (Referer=>'http://d.web2.qq.com/proxy.html?v=20130916001&callback=1&id=2')
36 ;
37 0 my $content = [decode("utf8",$msg->{content}),"",[]];
38 my %s = (
39 to => $msg->{to_uin},
40 face => $self->{qq_database}{user}{face} || 570,
41 content => JSON->new->utf8->encode($content),
42 msg_id => $msg->{msg_id},
43 clientid => $self->{qq_param}{clientid},
44 psessionid => $self->{qq_param}{psessionid},
45 0 ▶ );
Condition0%0/2
$self->{'qq_database'}{'user'}{'face'} || 570
l!l
00
MC/DC0%0/1
$self->{'qq_database'}{'user'}{'face'} || 570
$self->{'qq_database'}{'user'}{'face'}
Truth table0%0/2
A
A= $self->{'qq_database'}{'user'}{'face'}
Aresult
11
00
46 0 $s{content} = decode("utf8",$s{content});
47
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 $ua->post(
68 0 $api_url,
69 $post_content,
70 @headers,
71 $callback,
72 );
73 }
74 1 1;
« Webqq/Client/Plugin/CpanRecentModule.pm ↑ Summary Webqq/Client/Plugin/PicLimit.pm »