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