| line |
stmt |
bran |
cond |
sub |
pod |
time |
code |
|
1
|
|
|
|
|
|
|
package Webqq::Qun::Operate; |
|
2
|
1
|
|
|
1
|
|
4
|
use strict; |
|
|
1
|
|
|
|
|
1
|
|
|
|
1
|
|
|
|
|
25
|
|
|
3
|
1
|
|
|
1
|
|
3
|
use JSON; |
|
|
1
|
|
|
|
|
2
|
|
|
|
1
|
|
|
|
|
4
|
|
|
4
|
1
|
|
|
1
|
|
530
|
use Encode; |
|
|
1
|
|
|
|
|
7071
|
|
|
|
1
|
|
|
|
|
60
|
|
|
5
|
1
|
|
|
1
|
|
6
|
use Webqq::Util qw(gen_url gen_url2); |
|
|
1
|
|
|
|
|
1
|
|
|
|
1
|
|
|
|
|
1597
|
|
|
6
|
|
|
|
|
|
|
my %levelname; |
|
7
|
|
|
|
|
|
|
sub get_token{ |
|
8
|
0
|
|
|
0
|
0
|
|
my $self = shift; |
|
9
|
0
|
|
|
|
|
|
my $t = $self->search_cookie("skey"); |
|
10
|
0
|
|
|
|
|
|
my $n = 0; |
|
11
|
0
|
|
|
|
|
|
my $o=length($t); |
|
12
|
0
|
|
|
|
|
|
my $r; |
|
13
|
0
|
0
|
|
|
|
|
if($t){ |
|
14
|
0
|
|
|
|
|
|
for($r=5381;$o>$n;$n++){ |
|
15
|
0
|
|
|
|
|
|
$r += ($r<<5) + ord(substr($t,$n,1)); |
|
16
|
|
|
|
|
|
|
} |
|
17
|
0
|
|
|
|
|
|
$self->{token} = 2147483647 & $r; |
|
18
|
0
|
|
|
|
|
|
return $self->{token}; |
|
19
|
|
|
|
|
|
|
} |
|
20
|
|
|
|
|
|
|
} |
|
21
|
|
|
|
|
|
|
|
|
22
|
|
|
|
|
|
|
|
|
23
|
|
|
|
|
|
|
sub get_self { |
|
24
|
0
|
|
|
0
|
0
|
|
my $self = shift; |
|
25
|
0
|
|
|
|
|
|
my $api = 'http://cgi.find.qq.com/qqfind/myinfo'; |
|
26
|
0
|
|
|
|
|
|
my $ua = $self->{ua}; |
|
27
|
0
|
|
|
|
|
|
my @headers = (Referer => $self->{referer}); |
|
28
|
0
|
|
0
|
|
|
|
my @query_string = ( |
|
29
|
|
|
|
|
|
|
callback => "jQuery18302889768735039979_1427194882987", |
|
30
|
|
|
|
|
|
|
ldw => $self->{token} || $self->get_token(), |
|
31
|
|
|
|
|
|
|
_ => time(), |
|
32
|
|
|
|
|
|
|
); |
|
33
|
0
|
|
|
|
|
|
my $res = $ua->get(gen_url($api,@query_string)); |
|
34
|
0
|
0
|
|
|
|
|
if($res->is_success){ |
|
35
|
0
|
0
|
|
|
|
|
print $res->content,"\n" if $self->{debug}; |
|
36
|
0
|
|
|
|
|
|
my ($data) =$res->content=~ m/^jQuery18302889768735039979_1427194882987\((.*?)\);/; |
|
37
|
0
|
|
|
|
|
|
my $json = JSON->new->utf8->decode($data); |
|
38
|
0
|
0
|
|
|
|
|
return if $json->{retcode}!=0; |
|
39
|
|
|
|
|
|
|
} |
|
40
|
0
|
|
|
|
|
|
return; |
|
41
|
|
|
|
|
|
|
|
|
42
|
|
|
|
|
|
|
} |
|
43
|
|
|
|
|
|
|
sub get_qun { |
|
44
|
0
|
|
|
0
|
0
|
|
my $self = shift; |
|
45
|
0
|
0
|
|
|
|
|
return if $self->{is_load_data}; |
|
46
|
0
|
|
|
|
|
|
my $api = 'http://qun.qq.com/cgi-bin/qun_mgr/get_group_list'; |
|
47
|
0
|
|
|
|
|
|
my $ua = $self->{ua}; |
|
48
|
0
|
|
|
|
|
|
my @headers = (Referer => $self->{referer}); |
|
49
|
0
|
|
0
|
|
|
|
my $res = $ua->post($api,[ bkn => $self->{token} || $self->get_token() ]); |
|
50
|
0
|
0
|
|
|
|
|
if($res->is_success){ |
|
51
|
|
|
|
|
|
|
#{"ec":0,"join":[{"gc":1299322,"gn":"perl技术","owner":4866832},{"gc":144539789,"gn":"PERL学习交流","owner":419902730},{"gc":213925424,"gn":"PERL","owner":913166583}],"manage":[{"gc":390179723,"gn":"IT狂人","owner":308165330}]} |
|
52
|
0
|
|
|
|
|
|
my $json = JSON->new->utf8->decode($res->content); |
|
53
|
0
|
0
|
|
|
|
|
return if $json->{ec}!=0; |
|
54
|
0
|
|
|
|
|
|
$self->{data} = []; |
|
55
|
0
|
|
|
|
|
|
for my $t (qw(join manage create)){ |
|
56
|
0
|
|
|
|
|
|
for(@{$json->{$t}}){ |
|
|
0
|
|
|
|
|
|
|
|
57
|
0
|
|
|
|
|
|
$_->{qun_name} = encode("utf8",$_->{gn}); |
|
58
|
0
|
|
|
|
|
|
$_->{qun_number} = $_->{gc}; |
|
59
|
0
|
0
|
|
|
|
|
$_->{qun_type} = $t eq "join"?"attend":$t; |
|
60
|
0
|
|
|
|
|
|
delete $_->{gn}; |
|
61
|
0
|
|
|
|
|
|
delete $_->{gc}; |
|
62
|
0
|
|
|
|
|
|
push @{$self->{data}},$_; |
|
|
0
|
|
|
|
|
|
|
|
63
|
0
|
|
|
|
|
|
$self->get_member($_->{qun_number}); |
|
64
|
|
|
|
|
|
|
} |
|
65
|
|
|
|
|
|
|
} |
|
66
|
0
|
|
|
|
|
|
$self->{is_load_data} = 1; |
|
67
|
0
|
|
|
|
|
|
return $self; |
|
68
|
|
|
|
|
|
|
} |
|
69
|
0
|
|
|
|
|
|
return; |
|
70
|
|
|
|
|
|
|
} |
|
71
|
|
|
|
|
|
|
sub get_friend { |
|
72
|
0
|
|
|
0
|
0
|
|
my $self = shift; |
|
73
|
0
|
0
|
|
|
|
|
return if $self->{is_load_data}; |
|
74
|
0
|
|
|
|
|
|
my $api = 'http://qun.qq.com/cgi-bin/qun_mgr/get_friend_list'; |
|
75
|
0
|
|
|
|
|
|
my $ua = $self->{ua}; |
|
76
|
0
|
|
|
|
|
|
my @headers = (Referer => $self->{referer}); |
|
77
|
0
|
|
0
|
|
|
|
my $res = $ua->post($api,[bkn => $self->{token}||$self->get_token()]); |
|
78
|
0
|
0
|
|
|
|
|
if($res->is_success){ |
|
79
|
0
|
|
|
|
|
|
my $json = JSON->new->utf8->decode($res->content); |
|
80
|
|
|
|
|
|
|
#{"ec":0,"result":{"0":{"mems":[{"name":"卖茶叶和眼镜per","uin":744891290}]},"1":{"gname":"朋友"},"2":{"gname":"家人"},"3":{"gname":"同学"}}} |
|
81
|
0
|
0
|
|
|
|
|
return if $json->{ec}!=0; |
|
82
|
0
|
|
|
|
|
|
for my $group_index (keys %{$json->{result}}){ |
|
|
0
|
|
|
|
|
|
|
|
83
|
0
|
0
|
|
|
|
|
my $category = $group_index==0?"我的好友":encode("utf8",$json->{result}{$group_index}{gname}); |
|
84
|
0
|
|
|
|
|
|
for my $f (@{ $json->{result}{$group_index}{mems} }){ |
|
|
0
|
|
|
|
|
|
|
|
85
|
0
|
|
|
|
|
|
push @{ $self->{friend} },{ |
|
|
0
|
|
|
|
|
|
|
|
86
|
|
|
|
|
|
|
category => $category, |
|
87
|
|
|
|
|
|
|
nick => encode("utf8",$f->{name}), |
|
88
|
|
|
|
|
|
|
qq => $f->{uin}, |
|
89
|
|
|
|
|
|
|
} |
|
90
|
|
|
|
|
|
|
|
|
91
|
|
|
|
|
|
|
} |
|
92
|
|
|
|
|
|
|
} |
|
93
|
0
|
|
|
|
|
|
return $self; |
|
94
|
|
|
|
|
|
|
} |
|
95
|
0
|
|
|
|
|
|
return; |
|
96
|
|
|
|
|
|
|
} |
|
97
|
|
|
|
|
|
|
sub get_member { |
|
98
|
0
|
|
|
0
|
0
|
|
my $self = shift; |
|
99
|
0
|
|
|
|
|
|
my $qun_number = shift; |
|
100
|
0
|
|
|
|
|
|
my $api = "http://qun.qq.com/cgi-bin/qun_mgr/search_group_members"; |
|
101
|
0
|
|
|
|
|
|
my $ua = $self->{ua}; |
|
102
|
0
|
|
|
|
|
|
my @headers = (Referer => $self->{referer}); |
|
103
|
0
|
|
0
|
|
|
|
my $res = $ua->post($api,[ gc => $qun_number, st => 0, end => 2000,sort => 0,bkn => $self->{token}|| $self->get_token(),]); |
|
104
|
0
|
0
|
|
|
|
|
if($res->is_success){ |
|
105
|
|
|
|
|
|
|
#{"adm_max":10,"adm_num":1,"count":4,"ec":0,"levelname":{"1":"潜水","2":"冒泡","3":"吐槽","4":"活跃","5":"话唠","6":"传说"},"max_count":500,"mems":[{"card":"","flag":0,"g":0,"join_time":1410241477,"last_speak_time":1427191050,"lv":{"level":2,"point":404},"nick":"灰灰","qage":10,"role":0,"tags":"-1","uin":308165330},{"card":"","flag":0,"g":0,"join_time":1423016758,"last_speak_time":1427210847,"lv":{"level":2,"point":275},"nick":"小灰","qage":0,"role":1,"tags":"-1","uin":3072574066},{"card":"","flag":0,"g":0,"join_time":1427210502,"last_speak_time":1427210858,"lv":{"level":2,"point":1},"nick":"王鹏飞","qage":8,"role":2,"tags":"-1","uin":470869063},{"card":"小灰2号","flag":0,"g":0,"join_time":1422946743,"last_speak_time":1424144472,"lv":{"level":1,"point":0},"nick":"小灰2号","qage":0,"role":2,"tags":"-1","uin":1876225186}],"search_count":4,"svr_time":1427291710,"vecsize":1} |
|
106
|
0
|
|
|
|
|
|
my $json = JSON->new->utf8->decode($res->content); |
|
107
|
0
|
0
|
|
|
|
|
return if $json->{ec}!=0; |
|
108
|
0
|
|
|
|
|
|
my %role = ( |
|
109
|
|
|
|
|
|
|
0 => "owner", |
|
110
|
|
|
|
|
|
|
1 => "admin", |
|
111
|
|
|
|
|
|
|
2 => "member", |
|
112
|
|
|
|
|
|
|
); |
|
113
|
0
|
|
|
|
|
|
for(keys %{$json->{levelname}}){ |
|
|
0
|
|
|
|
|
|
|
|
114
|
0
|
|
|
|
|
|
$levelname{$_} = encode("utf8",$json->{levelname}{$_}); |
|
115
|
|
|
|
|
|
|
} |
|
116
|
0
|
|
|
|
|
|
delete $json->{levelname}; |
|
117
|
0
|
|
|
|
|
|
delete $json->{ec}; |
|
118
|
0
|
|
|
|
|
|
for(@{$json->{mems}}){ |
|
|
0
|
|
|
|
|
|
|
|
119
|
0
|
|
|
|
|
|
delete $_->{tags}; |
|
120
|
0
|
|
|
|
|
|
my $level = $levelname{$_->{lv}{level}}; |
|
121
|
0
|
|
|
|
|
|
$_->{level} = $level; |
|
122
|
0
|
|
|
|
|
|
$_->{bad_record} = $_->{flag}; |
|
123
|
0
|
0
|
|
|
|
|
$_->{sex} = $_->{g}?"female":"male"; |
|
124
|
0
|
|
|
|
|
|
$_->{qq} = $_->{uin}; |
|
125
|
0
|
|
|
|
|
|
delete $_->{flag}; |
|
126
|
0
|
|
|
|
|
|
delete $_->{g}; |
|
127
|
0
|
|
|
|
|
|
delete $_->{lv}; |
|
128
|
0
|
|
|
|
|
|
delete $_->{uin}; |
|
129
|
|
|
|
|
|
|
|
|
130
|
0
|
|
|
|
|
|
$_->{role} = $role{$_->{role}}; |
|
131
|
0
|
|
|
|
|
|
$_->{card} = encode("utf8",$_->{card}); |
|
132
|
0
|
|
|
|
|
|
$_->{nick} = encode("utf8",$_->{nick}); |
|
133
|
|
|
|
|
|
|
} |
|
134
|
0
|
|
|
|
|
|
$json->{members} = $json->{mems}; |
|
135
|
0
|
|
|
|
|
|
delete $json->{mems}; |
|
136
|
0
|
|
|
|
|
|
for (@{$self->{data}}){ |
|
|
0
|
|
|
|
|
|
|
|
137
|
0
|
0
|
|
|
|
|
if($_->{qun_number} eq $qun_number){ |
|
138
|
0
|
|
|
|
|
|
for my $m(@{$json->{members}}){ |
|
|
0
|
|
|
|
|
|
|
|
139
|
0
|
|
|
|
|
|
$m->{qun_number} = $_->{qun_number}; |
|
140
|
0
|
|
|
|
|
|
$m->{qun_name} = $_->{qun_name}; |
|
141
|
|
|
|
|
|
|
} |
|
142
|
0
|
|
|
|
|
|
@$_{keys %$json} = @$json{keys %$json}; |
|
143
|
0
|
|
|
|
|
|
return $self; |
|
144
|
|
|
|
|
|
|
} |
|
145
|
|
|
|
|
|
|
} |
|
146
|
0
|
|
|
|
|
|
return; |
|
147
|
|
|
|
|
|
|
} |
|
148
|
0
|
|
|
|
|
|
return; |
|
149
|
|
|
|
|
|
|
} |
|
150
|
|
|
|
|
|
|
sub add_member { |
|
151
|
0
|
|
|
0
|
0
|
|
my $self = shift; |
|
152
|
0
|
|
|
|
|
|
my($qun_number,@member) = @_; |
|
153
|
0
|
|
|
|
|
|
my $api = "http://qun.qq.com/cgi-bin/qun_mgr/add_group_member"; |
|
154
|
0
|
|
|
|
|
|
my $ua = $self->{ua}; |
|
155
|
0
|
|
|
|
|
|
my @headers = (Referer => $self->{referer}); |
|
156
|
0
|
|
0
|
|
|
|
my $res = $ua->post($api,[ gc => $qun_number, ul => join("|",@member), bkn => $self->{token} || $self->get_token(),],@headers); |
|
157
|
0
|
0
|
|
|
|
|
if($res->is_success){ |
|
158
|
0
|
0
|
|
|
|
|
print $res->content if $self->{debug}; |
|
159
|
0
|
|
|
|
|
|
my $json = JSON->new->utf8->decode($res->content); |
|
160
|
0
|
0
|
|
|
|
|
return if $json->{ec}!=0; |
|
161
|
0
|
|
|
|
|
|
return $self; |
|
162
|
|
|
|
|
|
|
} |
|
163
|
0
|
|
|
|
|
|
return; |
|
164
|
|
|
|
|
|
|
} |
|
165
|
|
|
|
|
|
|
sub del_member { |
|
166
|
0
|
|
|
0
|
0
|
|
my $self = shift; |
|
167
|
0
|
|
|
|
|
|
my($qun_number,@member) = @_; |
|
168
|
0
|
|
|
|
|
|
my $api = "http://qun.qq.com/cgi-bin/qun_mgr/delete_group_member"; |
|
169
|
0
|
|
|
|
|
|
my $ua = $self->{ua}; |
|
170
|
0
|
|
|
|
|
|
my @headers = (Referer => $self->{referer}); |
|
171
|
0
|
|
0
|
|
|
|
my $res = $ua->post($api,[ gc => $qun_number, ul => join("|",@member), flag => 0, bkn => $self->{token}|| $self->get_token(),],@headers); |
|
172
|
0
|
0
|
|
|
|
|
if($res->is_success){ |
|
173
|
0
|
0
|
|
|
|
|
print $res->content if $self->{debug}; |
|
174
|
0
|
|
|
|
|
|
my $json = JSON->new->utf8->decode($res->content); |
|
175
|
0
|
0
|
|
|
|
|
return if $json->{ec}!=0; |
|
176
|
0
|
|
|
|
|
|
return $self; |
|
177
|
|
|
|
|
|
|
} |
|
178
|
0
|
|
|
|
|
|
return; |
|
179
|
|
|
|
|
|
|
} |
|
180
|
|
|
|
|
|
|
sub set_admin { |
|
181
|
0
|
|
|
0
|
0
|
|
my $self = shift; |
|
182
|
0
|
|
|
|
|
|
my($qun_number,@member) = @_; |
|
183
|
0
|
|
|
|
|
|
my $api = "http://qun.qq.com/cgi-bin/qun_mgr/set_group_admin"; |
|
184
|
0
|
|
|
|
|
|
my $ua = $self->{ua}; |
|
185
|
0
|
|
|
|
|
|
my @headers = (Referer => $self->{referer}); |
|
186
|
0
|
|
0
|
|
|
|
my $res = $ua->post($api,[ gc => $qun_number, ul => join("|",@member), op => 1, bkn => $self->{token} || $self->get_token(),],@headers); |
|
187
|
0
|
0
|
|
|
|
|
if($res->is_success){ |
|
188
|
0
|
0
|
|
|
|
|
print $res->content,"\n" if $self->{debug}; |
|
189
|
0
|
|
|
|
|
|
my $json = JSON->new->utf8->decode($res->content); |
|
190
|
0
|
0
|
|
|
|
|
return if $json->{ec}!=0; |
|
191
|
0
|
|
|
|
|
|
return $self; |
|
192
|
|
|
|
|
|
|
} |
|
193
|
0
|
|
|
|
|
|
return; |
|
194
|
|
|
|
|
|
|
} |
|
195
|
|
|
|
|
|
|
|
|
196
|
|
|
|
|
|
|
sub del_admin { |
|
197
|
0
|
|
|
0
|
0
|
|
my $self = shift; |
|
198
|
0
|
|
|
|
|
|
my($qun_number,$member) = @_; |
|
199
|
0
|
|
|
|
|
|
my $api = "http://qun.qq.com/cgi-bin/qun_mgr/set_group_admin"; |
|
200
|
0
|
|
|
|
|
|
my $ua = $self->{ua}; |
|
201
|
0
|
|
|
|
|
|
my @headers = (Referer => $self->{referer}); |
|
202
|
0
|
|
0
|
|
|
|
my $res = $ua->post($api,[ gc => $qun_number, ul => $member, op => 0, bkn => $self->{token} || $self->get_token(),],@headers); |
|
203
|
0
|
0
|
|
|
|
|
if($res->is_success){ |
|
204
|
0
|
0
|
|
|
|
|
print $res->content,"\n" if $self->{debug}; |
|
205
|
0
|
|
|
|
|
|
my $json = JSON->new->utf8->decode($res->content); |
|
206
|
0
|
0
|
|
|
|
|
return if $json->{ec}!=0; |
|
207
|
0
|
|
|
|
|
|
return $self; |
|
208
|
|
|
|
|
|
|
} |
|
209
|
0
|
|
|
|
|
|
return; |
|
210
|
|
|
|
|
|
|
} |
|
211
|
|
|
|
|
|
|
|
|
212
|
|
|
|
|
|
|
sub _report1{ |
|
213
|
0
|
|
|
0
|
|
|
my $self = shift; |
|
214
|
0
|
|
|
|
|
|
my $qq = shift; |
|
215
|
0
|
|
|
|
|
|
my $qun_number = shift; |
|
216
|
0
|
|
|
|
|
|
my $api = 'http://cgi.connect.qq.com/report/tdw/report'; |
|
217
|
0
|
|
|
|
|
|
my $ua = $self->{ua}; |
|
218
|
0
|
|
|
|
|
|
my @headers = (Referer => $self->{referer}); |
|
219
|
0
|
|
|
|
|
|
my $ts = time() . "000"; |
|
220
|
0
|
|
|
|
|
|
my @query_string = ( |
|
221
|
|
|
|
|
|
|
table => "dc00141", |
|
222
|
|
|
|
|
|
|
fields => qq{["uin","ts","opername","module","action","obj1"]}, |
|
223
|
|
|
|
|
|
|
datas => qq{[["$qq",$ts,"Grp_website","mana_mber","Clk_set","$qun_number"]]}, |
|
224
|
|
|
|
|
|
|
t => time(), |
|
225
|
|
|
|
|
|
|
); |
|
226
|
0
|
|
|
|
|
|
my $res = $ua->get(gen_url2($api,@query_string),@headers); |
|
227
|
0
|
0
|
|
|
|
|
if($res->is_success){ |
|
228
|
0
|
0
|
|
|
|
|
print $res->content,"\n" if $self->{debug}; |
|
229
|
|
|
|
|
|
|
} |
|
230
|
|
|
|
|
|
|
} |
|
231
|
|
|
|
|
|
|
|
|
232
|
|
|
|
|
|
|
sub _report2 { |
|
233
|
0
|
|
|
0
|
|
|
my $self = shift; |
|
234
|
0
|
|
|
|
|
|
my $ua = $self->{ua}; |
|
235
|
0
|
|
|
|
|
|
my $api = "http://cgi.connect.qq.com/report/report"; |
|
236
|
0
|
|
|
|
|
|
my @headers = (Referer => $self->{referer}); |
|
237
|
0
|
|
|
|
|
|
my $res = $ua->get($api."?tag=0&strValue=0&nValue=12094&t=".time(),@headers); |
|
238
|
0
|
0
|
|
|
|
|
if($res->is_success){ |
|
239
|
0
|
0
|
|
|
|
|
print $res->content,"\n" if $self->{debug}; |
|
240
|
|
|
|
|
|
|
} |
|
241
|
|
|
|
|
|
|
} |
|
242
|
|
|
|
|
|
|
sub set_card { |
|
243
|
0
|
|
|
0
|
0
|
|
my $self = shift; |
|
244
|
0
|
|
|
|
|
|
my($qun_number,$member,$card) = @_; |
|
245
|
0
|
|
|
|
|
|
my $api = "http://qun.qq.com/cgi-bin/qun_mgr/set_group_card"; |
|
246
|
0
|
|
|
|
|
|
my $ua = $self->{ua}; |
|
247
|
0
|
|
|
|
|
|
my @headers = (Referer => $self->{referer}); |
|
248
|
0
|
|
0
|
|
|
|
my $res = $ua->post($api,[ gc => $qun_number, u => $member, name => $card, bkn => $self->{token}|| $self->get_token(),],@headers); |
|
249
|
0
|
0
|
|
|
|
|
if($res->is_success){ |
|
250
|
0
|
0
|
|
|
|
|
print $res->content if $self->{debug}; |
|
251
|
0
|
|
|
|
|
|
my $json = JSON->new->utf8->decode($res->content); |
|
252
|
0
|
0
|
|
|
|
|
return if $json->{ec}!=0; |
|
253
|
0
|
|
|
|
|
|
return $self; |
|
254
|
|
|
|
|
|
|
} |
|
255
|
0
|
|
|
|
|
|
return; |
|
256
|
|
|
|
|
|
|
} |
|
257
|
|
|
|
|
|
|
|
|
258
|
0
|
|
|
0
|
0
|
|
sub create {} |
|
259
|
0
|
|
|
0
|
0
|
|
sub dismiss {} |
|
260
|
0
|
|
|
0
|
0
|
|
sub upgrate{} |
|
261
|
0
|
|
|
0
|
0
|
|
sub transfer {} |
|
262
|
0
|
|
|
0
|
0
|
|
sub recover {} |
|
263
|
|
|
|
|
|
|
1; |