Webqq/Message/Remote/_send_group_message.pm untested

filter: Statementstmt 0.0% 0 / 25 Branchbran 0.0% 0 / 10 Conditioncond 0.0% 0 / 5 MC/DCmcdc 0.0% 0 / 3 Subroutinesub 0.0% 0 / 1 Podpod 0.0% 0 / 1 totaltotal 0.0% 0 / 45 CC 6 SCAR 37.4
CC
6
Cov
0%
Mojo::Webqq::_send_group_message
42.0
CRAP 42.0
1 sub Mojo::Webqq::_send_group_message{
2 my($self,$msg) = @_;
3 my $callback = sub{
4 my $json = shift;
5 $msg->parse_send_status_msg( $json );
6 if( !$msg->is_success and $msg->ttl > 0){
7 $self->debug("消息[ " .$msg->id . " ]发送失败,尝试重新发送,当前TTL: " . $msg->ttl);
8 $self->message_queue->put($msg);
9 #$self->send_group_message($msg);
10 return;
11 }
12 else{
13 if(ref $msg->cb eq 'CODE'){
14 $msg->cb->(
15 $self,
16 $msg,
17 );
18 }
19 $self->emit(send_message =>
20 $msg,
21 );
22 }
23 };
24
25 my $api_url = ($self->security?'https':'http') . '://d1.web2.qq.com/channel/send_qun_msg2';
26 my $headers = {
27 Referer => 'http://d1.web2.qq.com/proxy.html?v=20151105001&callback=1&id=2',
28 json => 1,
29 };
30 my @content = map {
31 if($_->{type} eq "txt"){$_->{content}}
32 elsif($_->{type} eq "face"){["face",0+$_->{id}]}
33 } @{$msg->raw_content};
34 #for(my $i=0;$i<@content;$i++){
35 # if(ref $content[$i] eq "ARRAY"){
36 # if(ref $content[$i] eq "ARRAY"){
37 # splice @content,$i+1,0," ";
38 # }
39 # else{
40 # $content[$i+1] = " " . $content[$i+1];
41 # }
42 # }
43 #}
44 my $content = [@content,["font",{name=>"宋体",size=>10,style=>[0,0,0],color=>"000000"}]];
45 my %s = (
46 group_uin => $msg->group_id,
47 face => $self->user->face || 591,
48 content => $self->to_json($content),
49 msg_id => $msg->id,
50 clientid => $self->clientid,
51 psessionid => $self->psessionid,
52 );
53 $self->http_post(
54 $api_url,
55 $headers,
56 form=>{r=>$self->to_json(\%s)},
57 $callback,
58 );
59 }
60 1;