line |
stmt |
bran |
cond |
sub |
pod |
time |
code |
1
|
|
|
|
|
|
|
sub Mojo::Webqq::_send_sess_message{ |
2
|
0
|
|
|
0
|
|
|
my($self,$msg) = @_; |
3
|
0
|
0
|
|
|
|
|
if(not defined $msg->sess_sig){ |
4
|
0
|
|
|
|
|
|
$msg->send_status(code=>-5,msg=>"发送失败",info=>'无法获取到sess_sig'); |
5
|
0
|
0
|
|
|
|
|
if(ref $msg->cb eq 'CODE'){ |
6
|
0
|
|
|
|
|
|
$msg->cb->( |
7
|
|
|
|
|
|
|
$self, |
8
|
|
|
|
|
|
|
$msg, |
9
|
|
|
|
|
|
|
); |
10
|
|
|
|
|
|
|
} |
11
|
0
|
|
|
|
|
|
$self->emit(send_message => |
12
|
|
|
|
|
|
|
$msg, |
13
|
|
|
|
|
|
|
); |
14
|
0
|
|
|
|
|
|
return; |
15
|
|
|
|
|
|
|
} |
16
|
|
|
|
|
|
|
my $callback = sub{ |
17
|
0
|
|
|
0
|
|
|
my $json = shift; |
18
|
0
|
|
|
|
|
|
$msg->parse_send_status_msg( $json ); |
19
|
0
|
0
|
0
|
|
|
|
if(!$msg->is_success and $msg->ttl > 0){ |
20
|
0
|
|
|
|
|
|
$self->debug("消息[ " .$msg->id . " ]发送失败,尝试重新发送,当前TTL: " . $msg->ttl); |
21
|
0
|
|
|
|
|
|
$self->message_queue->put($msg); |
22
|
0
|
|
|
|
|
|
return; |
23
|
|
|
|
|
|
|
} |
24
|
|
|
|
|
|
|
else{ |
25
|
0
|
0
|
|
|
|
|
if(ref $msg->cb eq 'CODE'){ |
26
|
0
|
|
|
|
|
|
$msg->cb->( |
27
|
|
|
|
|
|
|
$self, |
28
|
|
|
|
|
|
|
$msg, |
29
|
|
|
|
|
|
|
); |
30
|
|
|
|
|
|
|
} |
31
|
0
|
|
|
|
|
|
$self->emit(send_message => |
32
|
|
|
|
|
|
|
$msg, |
33
|
|
|
|
|
|
|
); |
34
|
|
|
|
|
|
|
} |
35
|
0
|
|
|
|
|
|
}; |
36
|
|
|
|
|
|
|
|
37
|
0
|
0
|
|
|
|
|
my $api_url = ($self->security?'https':'http') . '://d1.web2.qq.com/channel/send_sess_msg2'; |
38
|
0
|
|
|
|
|
|
my $headers = { |
39
|
|
|
|
|
|
|
Referer => 'http://d1.web2.qq.com/proxy.html?v=20151105001&callback=1&id=2', |
40
|
|
|
|
|
|
|
json => 1, |
41
|
|
|
|
|
|
|
}; |
42
|
|
|
|
|
|
|
my @content = map { |
43
|
0
|
0
|
|
|
|
|
if($_->{type} eq "txt"){$_->{content}} |
|
0
|
0
|
|
|
|
|
|
44
|
0
|
|
|
|
|
|
elsif($_->{type} eq "face"){["face",0+$_->{id}]} |
45
|
0
|
|
|
|
|
|
} @{$msg->raw_content}; |
|
0
|
|
|
|
|
|
|
46
|
|
|
|
|
|
|
#for(my $i=0;$i<@content;$i++){ |
47
|
|
|
|
|
|
|
# if(ref $content[$i] eq "ARRAY"){ |
48
|
|
|
|
|
|
|
# if(ref $content[$i] eq "ARRAY"){ |
49
|
|
|
|
|
|
|
# splice @content,$i+1,0," "; |
50
|
|
|
|
|
|
|
# } |
51
|
|
|
|
|
|
|
# else{ |
52
|
|
|
|
|
|
|
# $content[$i+1] = " " . $content[$i+1]; |
53
|
|
|
|
|
|
|
# } |
54
|
|
|
|
|
|
|
# } |
55
|
|
|
|
|
|
|
#} |
56
|
0
|
|
|
|
|
|
my $content = [@content,["font",{name=>"宋体",size=>10,style=>[0,0,0],color=>"000000"}]]; |
57
|
0
|
0
|
0
|
|
|
|
my %s = ( |
58
|
|
|
|
|
|
|
to => $msg->receiver_id , |
59
|
|
|
|
|
|
|
group_sig => $msg->sess_sig , |
60
|
|
|
|
|
|
|
face => $self->user->face || 591, |
61
|
|
|
|
|
|
|
content => $self->to_json($content), |
62
|
|
|
|
|
|
|
msg_id => $msg->id, |
63
|
|
|
|
|
|
|
service_type => $msg->via eq "group"?0:1, |
64
|
|
|
|
|
|
|
clientid => $self->clientid, |
65
|
|
|
|
|
|
|
psessionid => $self->psessionid, |
66
|
|
|
|
|
|
|
); |
67
|
0
|
|
|
|
|
|
$self->http_post( |
68
|
|
|
|
|
|
|
$api_url, |
69
|
|
|
|
|
|
|
$headers, |
70
|
|
|
|
|
|
|
form=>{r=>$self->to_json(\%s)}, |
71
|
|
|
|
|
|
|
$callback, |
72
|
|
|
|
|
|
|
); |
73
|
|
|
|
|
|
|
} |
74
|
|
|
|
|
|
|
1; |