| line |
stmt |
bran |
cond |
sub |
pod |
time |
code |
|
1
|
1
|
|
|
1
|
|
6
|
use strict; |
|
|
1
|
|
|
|
|
2
|
|
|
|
1
|
|
|
|
|
25
|
|
|
2
|
1
|
|
|
1
|
|
5
|
use Mojo::Weixin::Const (); |
|
|
1
|
|
|
|
|
2
|
|
|
|
1
|
|
|
|
|
640
|
|
|
3
|
|
|
|
|
|
|
sub Mojo::Weixin::_send_media_message { |
|
4
|
0
|
|
|
0
|
|
|
my $self = shift; |
|
5
|
0
|
|
|
|
|
|
my $msg = shift; |
|
6
|
0
|
0
|
0
|
|
|
|
if($msg->format ne "media" or (!defined $msg->media_path and !defined $msg->media_id) ){ |
|
|
|
|
0
|
|
|
|
|
|
7
|
0
|
|
|
|
|
|
$self->error("无效的 media msg"); |
|
8
|
0
|
|
|
|
|
|
return; |
|
9
|
|
|
|
|
|
|
} |
|
10
|
|
|
|
|
|
|
my $callback = sub{ |
|
11
|
0
|
|
|
0
|
|
|
my $json = shift; |
|
12
|
0
|
|
|
|
|
|
$msg->_parse_send_status_data($json); |
|
13
|
0
|
0
|
0
|
|
|
|
if(!$msg->is_success and $msg->ttl > 0){ |
|
14
|
0
|
|
|
|
|
|
$self->debug("消息[ " . $msg->id . " ]发送失败,尝试重新发送,当前TTL: " . $msg->ttl); |
|
15
|
0
|
|
|
|
|
|
$self->message_queue->put($msg); |
|
16
|
0
|
|
|
|
|
|
return; |
|
17
|
|
|
|
|
|
|
} |
|
18
|
|
|
|
|
|
|
else{ |
|
19
|
0
|
0
|
|
|
|
|
if(ref $msg->cb eq 'CODE'){ |
|
20
|
0
|
|
|
|
|
|
$msg->cb->($self, $msg); |
|
21
|
|
|
|
|
|
|
} |
|
22
|
0
|
|
|
|
|
|
$self->emit(send_media => $msg->media_path,$msg->media_data,$msg); |
|
23
|
0
|
|
|
|
|
|
$self->emit(send_message => $msg); |
|
24
|
|
|
|
|
|
|
} |
|
25
|
0
|
|
|
|
|
|
}; |
|
26
|
|
|
|
|
|
|
$self->steps( |
|
27
|
|
|
|
|
|
|
sub{ |
|
28
|
0
|
|
|
0
|
|
|
my $delay = shift; |
|
29
|
0
|
0
|
|
|
|
|
defined $msg->media_id ? $delay->begin(0)->($msg): $self->_upload_media($msg,$delay->begin(0,)); |
|
30
|
|
|
|
|
|
|
}, |
|
31
|
|
|
|
|
|
|
sub{ |
|
32
|
0
|
|
|
0
|
|
|
my($delay,$msg,$error) = @_; |
|
33
|
0
|
0
|
0
|
|
|
|
if(!defined $msg->media_id or $error){ |
|
34
|
0
|
|
|
|
|
|
$msg->send_status(code=>-1,msg=>"发送失败",info=>$error); |
|
35
|
0
|
0
|
|
|
|
|
if(ref $msg->cb eq 'CODE'){ |
|
36
|
0
|
|
|
|
|
|
$msg->cb->($self, $msg); |
|
37
|
|
|
|
|
|
|
} |
|
38
|
0
|
|
|
|
|
|
$self->emit(send_message => $msg); |
|
39
|
0
|
|
|
|
|
|
return; |
|
40
|
|
|
|
|
|
|
} |
|
41
|
0
|
|
|
|
|
|
my $api; |
|
42
|
0
|
0
|
|
|
|
|
my @query_string = ( |
|
43
|
|
|
|
|
|
|
fun => 'async', |
|
44
|
|
|
|
|
|
|
f => 'json', |
|
45
|
|
|
|
|
|
|
$self->pass_ticket?(pass_ticket => $self->url_escape($self->pass_ticket)):() |
|
46
|
|
|
|
|
|
|
); |
|
47
|
|
|
|
|
|
|
my $post = { |
|
48
|
|
|
|
|
|
|
BaseRequest => { |
|
49
|
|
|
|
|
|
|
DeviceID => $self->deviceid, |
|
50
|
|
|
|
|
|
|
Sid => $self->wxsid, |
|
51
|
|
|
|
|
|
|
Skey => $self->skey, |
|
52
|
|
|
|
|
|
|
Uin => $self->wxuin, |
|
53
|
|
|
|
|
|
|
}, |
|
54
|
|
|
|
|
|
|
Msg => { |
|
55
|
|
|
|
|
|
|
ClientMsgId => $msg->uid, |
|
56
|
|
|
|
|
|
|
FromUserName => $msg->sender_id, |
|
57
|
|
|
|
|
|
|
MediaId => (split ":",$msg->media_id)[0], |
|
58
|
|
|
|
|
|
|
LocalID => $msg->uid, |
|
59
|
|
|
|
|
|
|
ToUserName => ($msg->type eq "group_message"?$msg->group_id:$msg->receiver_id), |
|
60
|
|
|
|
|
|
|
#Type => $Mojo::Weixin::Const::KEY_MAP_MEDIA_CODE{$msg->media_type} || 6, |
|
61
|
0
|
0
|
0
|
|
|
|
Type => $msg->media_code || $Mojo::Weixin::Const::KEY_MAP_MEDIA_CODE{$msg->media_type} || 6, |
|
62
|
|
|
|
|
|
|
}, |
|
63
|
|
|
|
|
|
|
Scene => 0, |
|
64
|
|
|
|
|
|
|
}; |
|
65
|
0
|
0
|
0
|
|
|
|
if($msg->media_type eq "image"){ |
|
|
|
0
|
|
|
|
|
|
|
|
|
0
|
|
|
|
|
|
|
66
|
0
|
|
|
|
|
|
$api = 'https://' . $self->domain . '/cgi-bin/mmwebwx-bin/webwxsendmsgimg'; |
|
67
|
|
|
|
|
|
|
} |
|
68
|
|
|
|
|
|
|
elsif($msg->media_type eq "video" or $msg->media_type eq "microvideo"){ |
|
69
|
0
|
|
|
|
|
|
$api = 'https://' . $self->domain . '/cgi-bin/mmwebwx-bin/webwxsendvideomsg'; |
|
70
|
|
|
|
|
|
|
} |
|
71
|
|
|
|
|
|
|
#elsif($msg->media_type eq "voice"){ |
|
72
|
|
|
|
|
|
|
# |
|
73
|
|
|
|
|
|
|
#} |
|
74
|
|
|
|
|
|
|
elsif($msg->media_type eq "emoticon"){ |
|
75
|
0
|
|
|
|
|
|
$api = 'https://' . $self->domain . '/cgi-bin/mmwebwx-bin/webwxsendemoticon'; |
|
76
|
0
|
0
|
|
|
|
|
@query_string = ( |
|
77
|
|
|
|
|
|
|
fun=>'sys', |
|
78
|
|
|
|
|
|
|
$self->pass_ticket?(pass_ticket => $self->url_escape($self->pass_ticket)):() |
|
79
|
|
|
|
|
|
|
); |
|
80
|
0
|
|
|
|
|
|
$post->{Msg}{EmojiFlag} = 2; |
|
81
|
|
|
|
|
|
|
} |
|
82
|
|
|
|
|
|
|
else{ |
|
83
|
0
|
|
|
|
|
|
$api = 'https://' . $self->domain . '/cgi-bin/mmwebwx-bin/webwxsendappmsg'; |
|
84
|
0
|
|
|
|
|
|
my $content = |
|
85
|
|
|
|
|
|
|
"" . |
|
86
|
|
|
|
|
|
|
"" . $msg->media_name . "" . |
|
87
|
|
|
|
|
|
|
"" . |
|
88
|
|
|
|
|
|
|
"" . |
|
89
|
|
|
|
|
|
|
"6" . |
|
90
|
|
|
|
|
|
|
"" . |
|
91
|
|
|
|
|
|
|
"" . |
|
92
|
|
|
|
|
|
|
"" . |
|
93
|
|
|
|
|
|
|
"" . |
|
94
|
|
|
|
|
|
|
"" . $msg->media_size . "" . |
|
95
|
|
|
|
|
|
|
"" . (split ":",$msg->media_id)[0] . "" . |
|
96
|
|
|
|
|
|
|
"" . $msg->media_ext ."" . |
|
97
|
|
|
|
|
|
|
"" . |
|
98
|
|
|
|
|
|
|
"" . |
|
99
|
|
|
|
|
|
|
""; |
|
100
|
0
|
|
|
|
|
|
$post->{Msg}{Content} = $content; |
|
101
|
|
|
|
|
|
|
} |
|
102
|
0
|
0
|
|
|
|
|
$post->{Msg}{Content} =~ s#/#__SLASH__#g if exists $post->{Msg}{Content}; |
|
103
|
0
|
|
|
|
|
|
my $json = $self->to_json($post); |
|
104
|
0
|
|
|
|
|
|
$json =~ s#__SLASH__#/#g; |
|
105
|
0
|
|
|
|
|
|
$self->http_post( |
|
106
|
|
|
|
|
|
|
$self->gen_url($api,@query_string), |
|
107
|
|
|
|
|
|
|
{json=>1,Referer=>'https://' . $self->domain . '/','Content-Type'=>'application/json'}, |
|
108
|
|
|
|
|
|
|
$json, |
|
109
|
|
|
|
|
|
|
$callback |
|
110
|
|
|
|
|
|
|
); |
|
111
|
|
|
|
|
|
|
}, |
|
112
|
0
|
|
|
|
|
|
); |
|
113
|
|
|
|
|
|
|
} |
|
114
|
|
|
|
|
|
|
1; |