line |
stmt |
bran |
cond |
sub |
pod |
time |
code |
1
|
|
|
|
|
|
|
package Mojo::Weixin::Message; |
2
|
1
|
|
|
1
|
|
7
|
use Mojo::Weixin::Base 'Mojo::Weixin::Message::Base'; |
|
1
|
|
|
|
|
1
|
|
|
1
|
|
|
|
|
19
|
|
3
|
1
|
|
|
1
|
|
410
|
use Mojo::Weixin::Friend; |
|
1
|
|
|
|
|
3
|
|
|
1
|
|
|
|
|
9
|
|
4
|
1
|
|
|
1
|
|
7
|
use Mojo::Weixin::Group; |
|
1
|
|
|
|
|
2
|
|
|
1
|
|
|
|
|
5
|
|
5
|
1
|
|
|
1
|
|
5
|
use Mojo::Weixin::Group::Member; |
|
1
|
|
|
|
|
49
|
|
|
1
|
|
|
|
|
8
|
|
6
|
1
|
|
|
1
|
|
6
|
use Mojo::Weixin::Const qw(%FACE_MAP_QQ %FACE_MAP_EMOJI); |
|
1
|
|
|
|
|
2
|
|
|
1
|
|
|
|
|
1222
|
|
7
|
|
|
|
|
|
|
|
8
|
|
|
|
|
|
|
has time => sub{time}; |
9
|
|
|
|
|
|
|
has ttl => 5; |
10
|
|
|
|
|
|
|
has source => 'local'; |
11
|
|
|
|
|
|
|
has 'cb'; |
12
|
|
|
|
|
|
|
has from => 'none'; |
13
|
|
|
|
|
|
|
has allow_plugin => 1; |
14
|
|
|
|
|
|
|
has 'id'; #发送消息成功后,服务端返回的id,可以用于撤回消息的标识 |
15
|
|
|
|
|
|
|
has 'uid';#消息的本地唯一标识,客户端创建消息时生成,失败多次重试时,服务端对相同uid的消息会避免对方收到多条重复 |
16
|
|
|
|
|
|
|
has [qw( sender_id receiver_id group_id content type class format)]; |
17
|
|
|
|
|
|
|
has [qw( media_id media_type media_code media_mime media_name media_size media_data media_mtime media_ext media_path)]; |
18
|
|
|
|
|
|
|
has [qw( app_id app_title app_url app_name app_desc)]; |
19
|
|
|
|
|
|
|
has [qw( card_id card_name card_province card_city card_account card_avatar card_sex)]; |
20
|
|
|
|
|
|
|
has [qw( revoke_id )]; |
21
|
|
|
|
|
|
|
has [qw(code msg info)]; |
22
|
|
|
|
|
|
|
has media_chunks => undef; #分片上传数量,只有1片的情况下不会采用分片上传,会直接上传 |
23
|
|
|
|
|
|
|
has media_chunk => 0; #当前已经上传的分片数量 |
24
|
|
|
|
|
|
|
has media_clientid => undef; |
25
|
|
|
|
|
|
|
has 'media_md5'; |
26
|
|
|
|
|
|
|
has data => undef; |
27
|
|
|
|
|
|
|
|
28
|
|
|
|
|
|
|
sub new { |
29
|
0
|
|
|
0
|
1
|
|
my $s = shift; |
30
|
0
|
|
|
|
|
|
$s = $s->Mojo::Weixin::Base::new(@_); |
31
|
0
|
|
|
|
|
|
$s->client->emoji_convert($s->{content},$s->client->emoji_to_text); |
32
|
0
|
0
|
|
|
|
|
if(defined $s->{content}){ |
33
|
0
|
|
|
|
|
|
$s->client->emoji_convert(\$s->{content},$s->client->emoji_to_text); |
34
|
0
|
|
|
|
|
|
$s->{content}=~s/ /\n/g; |
35
|
0
|
|
|
|
|
|
$s->{content}=~s/(\@.*?)\xe2\x80\x85/$1 /g; |
36
|
|
|
|
|
|
|
} |
37
|
0
|
|
|
|
|
|
$s; |
38
|
|
|
|
|
|
|
} |
39
|
|
|
|
|
|
|
|
40
|
0
|
|
|
0
|
|
|
sub _default_friend{Mojo::Weixin::Friend->new(@_);} |
41
|
0
|
|
|
0
|
|
|
sub _defaut_group{Mojo::Weixin::Group->new(@_)} |
42
|
0
|
|
|
0
|
|
|
sub _default_group_member{Mojo::Weixin::Group::Member->new(@_)} |
43
|
|
|
|
|
|
|
|
44
|
|
|
|
|
|
|
sub sender{ |
45
|
0
|
|
|
0
|
0
|
|
my $s = shift; |
46
|
0
|
0
|
|
|
|
|
return if not defined $s->sender_id; |
47
|
0
|
0
|
|
|
|
|
if($s->type eq "friend_message"){ |
|
|
0
|
|
|
|
|
|
|
|
0
|
|
|
|
|
|
48
|
0
|
0
|
|
|
|
|
return $s->client->user if $s->class eq "send"; |
49
|
0
|
|
0
|
|
|
|
return $s->client->search_friend(id=>$s->sender_id,_check_remote=>1) || _default_friend(id=>$s->sender_id) ; |
50
|
|
|
|
|
|
|
} |
51
|
|
|
|
|
|
|
elsif($s->type eq "group_message"){ |
52
|
0
|
|
|
|
|
|
my $group = $s->client->search_group(id=>$s->group_id,_check_remote=>1); |
53
|
0
|
0
|
|
|
|
|
return _default_group_member(id=>$s->sender_id) if not defined $group; |
54
|
0
|
0
|
|
|
|
|
return $group->me if $s->class eq "send"; |
55
|
0
|
|
0
|
|
|
|
return $group->search_group_member(id=>$s->sender_id,_check_remote=>1) || _default_group_member(id=>$s->sender_id); |
56
|
|
|
|
|
|
|
} |
57
|
|
|
|
|
|
|
elsif($s->type eq "group_notice"){ |
58
|
0
|
0
|
|
|
|
|
my $s->client->search_group(id=>$s->group_id,_check_remote=>1) || _defaut_group(id=>$s->group_id); |
59
|
|
|
|
|
|
|
} |
60
|
0
|
|
|
|
|
|
return; |
61
|
|
|
|
|
|
|
} |
62
|
|
|
|
|
|
|
sub receiver { |
63
|
0
|
|
|
0
|
0
|
|
my $s = shift; |
64
|
0
|
0
|
|
|
|
|
return if not defined $s->receiver_id; |
65
|
0
|
0
|
|
|
|
|
if($s->type eq "friend_message"){ |
|
|
0
|
|
|
|
|
|
|
|
0
|
|
|
|
|
|
66
|
0
|
0
|
|
|
|
|
return $s->client->user if $s->class eq "recv"; |
67
|
0
|
|
0
|
|
|
|
return $s->client->search_friend(id=>$s->receiver_id,_check_remote=>1) || _default_friend(id=>$s->receiver_id); |
68
|
|
|
|
|
|
|
} |
69
|
|
|
|
|
|
|
elsif($s->type eq "group_message"){ |
70
|
0
|
|
|
|
|
|
my $group = $s->client->search_group(id=>$s->group_id,_check_remote=>1); |
71
|
0
|
0
|
|
|
|
|
return _default_group_member(id=>$s->receiver_id) if not defined $group; |
72
|
0
|
0
|
|
|
|
|
return $group->me if $s->class eq "recv"; |
73
|
0
|
|
0
|
|
|
|
return $group->search_group_member(id=>$s->receiver_id,_check_remote=>1) || _default_group_member(id=>$s->receiver_id); |
74
|
|
|
|
|
|
|
} |
75
|
|
|
|
|
|
|
elsif($s->type eq "group_notice"){ |
76
|
0
|
|
|
|
|
|
my $group = $s->client->search_group(id=>$s->group_id,_check_remote=>1); |
77
|
0
|
0
|
|
|
|
|
return _default_group_member(id=>$s->receiver_id) if not defined $group; |
78
|
0
|
0
|
|
|
|
|
return $group->me if $s->class eq "recv"; |
79
|
0
|
|
0
|
|
|
|
return $group->search_group_member(id=>$s->receiver_id,_check_remote=>1) || _default_group_member(id=>$s->receiver_id); |
80
|
|
|
|
|
|
|
} |
81
|
0
|
|
|
|
|
|
return; |
82
|
|
|
|
|
|
|
} |
83
|
|
|
|
|
|
|
sub group{ |
84
|
0
|
|
|
0
|
0
|
|
my $s = shift; |
85
|
0
|
0
|
|
|
|
|
return if not defined $s->group_id; |
86
|
0
|
0
|
0
|
|
|
|
return if ($s->type ne "group_message" and $s->type ne "group_notice"); |
87
|
0
|
|
0
|
|
|
|
return $s->client->search_group(id=>$s->group_id,_check_remote=>1) || _defaut_group(id=>$s->group_id); |
88
|
|
|
|
|
|
|
} |
89
|
|
|
|
|
|
|
|
90
|
|
|
|
|
|
|
sub reply{ |
91
|
0
|
|
|
0
|
0
|
|
my $s = shift; |
92
|
0
|
0
|
|
|
|
|
return if $s->type eq "group_notice"; |
93
|
0
|
|
|
|
|
|
$s->client->reply_message($s,@_); |
94
|
|
|
|
|
|
|
} |
95
|
|
|
|
|
|
|
|
96
|
|
|
|
|
|
|
sub reply_media { |
97
|
0
|
|
|
0
|
0
|
|
my $s = shift; |
98
|
0
|
0
|
|
|
|
|
return if $s->type eq "group_notice"; |
99
|
0
|
|
|
|
|
|
$s->client->reply_media_message($s,@_); |
100
|
|
|
|
|
|
|
} |
101
|
|
|
|
|
|
|
|
102
|
|
|
|
|
|
|
1; |