| line |
stmt |
bran |
cond |
sub |
pod |
time |
code |
|
1
|
|
|
|
|
|
|
package Webqq::Qun; |
|
2
|
1
|
|
|
1
|
|
260
|
use strict; |
|
|
1
|
|
|
|
|
1
|
|
|
|
1
|
|
|
|
|
24
|
|
|
3
|
1
|
|
|
1
|
|
549
|
use JSON; |
|
|
1
|
|
|
|
|
9550
|
|
|
|
1
|
|
|
|
|
5
|
|
|
4
|
1
|
|
|
1
|
|
674
|
use Storable qw(dclone); |
|
|
1
|
|
|
|
|
2069
|
|
|
|
1
|
|
|
|
|
54
|
|
|
5
|
1
|
|
|
1
|
|
5
|
use Scalar::Util qw(blessed reftype); |
|
|
1
|
|
|
|
|
1
|
|
|
|
1
|
|
|
|
|
65
|
|
|
6
|
1
|
|
|
1
|
|
3
|
use base qw(Webqq::Qun::Authorize Webqq::Qun::Operate Webqq::Qun::Base); |
|
|
1
|
|
|
|
|
1
|
|
|
|
1
|
|
|
|
|
363
|
|
|
7
|
1
|
|
|
1
|
|
480
|
use HTTP::Cookies; |
|
|
1
|
|
|
|
|
1195566
|
|
|
|
1
|
|
|
|
|
32
|
|
|
8
|
1
|
|
|
1
|
|
224972
|
use LWP::UserAgent; |
|
|
1
|
|
|
|
|
4258323
|
|
|
|
1
|
|
|
|
|
48
|
|
|
9
|
1
|
|
|
1
|
|
649
|
use LWP::Protocol::https; |
|
|
1
|
|
|
|
|
71896
|
|
|
|
1
|
|
|
|
|
36
|
|
|
10
|
1
|
|
|
1
|
|
428
|
use Webqq::Qun::One; |
|
|
1
|
|
|
|
|
2
|
|
|
|
1
|
|
|
|
|
24
|
|
|
11
|
1
|
|
|
1
|
|
370
|
use Webqq::Qun::Member; |
|
|
1
|
|
|
|
|
3
|
|
|
|
1
|
|
|
|
|
981
|
|
|
12
|
|
|
|
|
|
|
|
|
13
|
|
|
|
|
|
|
our $VERSION = "1.2"; |
|
14
|
|
|
|
|
|
|
sub new { |
|
15
|
0
|
|
|
0
|
1
|
|
my $class = shift; |
|
16
|
0
|
|
|
|
|
|
my %p = @_; |
|
17
|
0
|
|
|
|
|
|
my $agent = 'Mozilla/5.0 (Windows NT 6.1) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/37.0.2062'; |
|
18
|
0
|
|
0
|
|
|
|
my $self = { |
|
19
|
|
|
|
|
|
|
cookie_jar => HTTP::Cookies->new(hide_cookie2=>1), |
|
20
|
|
|
|
|
|
|
debug => $p{debug} || 0, |
|
21
|
|
|
|
|
|
|
qq => $p{qq}, |
|
22
|
|
|
|
|
|
|
pwd => $p{pwd}, |
|
23
|
|
|
|
|
|
|
referer => "http://qun.qq.com/member.html", |
|
24
|
|
|
|
|
|
|
token => undef, |
|
25
|
|
|
|
|
|
|
_authorize => {}, |
|
26
|
|
|
|
|
|
|
data => [], |
|
27
|
|
|
|
|
|
|
self => {}, |
|
28
|
|
|
|
|
|
|
friend => [], |
|
29
|
|
|
|
|
|
|
is_load_data => 0, |
|
30
|
|
|
|
|
|
|
is_authorize => 0, |
|
31
|
|
|
|
|
|
|
|
|
32
|
|
|
|
|
|
|
}; |
|
33
|
0
|
|
|
|
|
|
$self->{ua} = LWP::UserAgent->new( |
|
34
|
|
|
|
|
|
|
cookie_jar => $self->{cookie_jar}, |
|
35
|
|
|
|
|
|
|
agent => $agent, |
|
36
|
|
|
|
|
|
|
timeout => 300, |
|
37
|
|
|
|
|
|
|
ssl_opts => {verify_hostname => 0}, |
|
38
|
|
|
|
|
|
|
); |
|
39
|
0
|
0
|
|
|
|
|
if($self->{debug}){ |
|
40
|
|
|
|
|
|
|
$self->{ua}->add_handler(request_send => sub { |
|
41
|
0
|
|
|
0
|
|
|
my($request, $ua, $h) = @_; |
|
42
|
0
|
|
|
|
|
|
print $request->as_string; |
|
43
|
0
|
|
|
|
|
|
return; |
|
44
|
0
|
|
|
|
|
|
}); |
|
45
|
|
|
|
|
|
|
$self->{ua}->add_handler( |
|
46
|
0
|
|
|
0
|
|
|
response_header => sub { my($response, $ua, $h) = @_; |
|
47
|
0
|
|
|
|
|
|
print $response->as_string; |
|
48
|
0
|
|
|
|
|
|
return; |
|
49
|
0
|
|
|
|
|
|
}); |
|
50
|
|
|
|
|
|
|
} |
|
51
|
0
|
|
|
|
|
|
bless $self,$class; |
|
52
|
|
|
|
|
|
|
} |
|
53
|
|
|
|
|
|
|
|
|
54
|
|
|
|
|
|
|
sub each_qun { |
|
55
|
0
|
|
|
0
|
1
|
|
my $self = shift; |
|
56
|
0
|
|
|
|
|
|
$self->get_qun(); |
|
57
|
0
|
|
|
|
|
|
my $callback = shift; |
|
58
|
|
|
|
|
|
|
$self->SUPER::each($self->{data},sub{ |
|
59
|
0
|
|
|
0
|
|
|
my $q = shift; |
|
60
|
0
|
|
|
|
|
|
$callback->(bless $q,__PACKAGE__."::One"); |
|
61
|
0
|
|
|
|
|
|
}); |
|
62
|
|
|
|
|
|
|
} |
|
63
|
|
|
|
|
|
|
sub find_qun{ |
|
64
|
0
|
|
|
0
|
1
|
|
my $self = shift; |
|
65
|
0
|
|
|
|
|
|
$self->get_qun(); |
|
66
|
0
|
|
|
|
|
|
my %p = @_; |
|
67
|
0
|
|
|
|
|
|
my ($qun_type,$qun_number,$qun_name) = @p{qw(qun_type qun_number qun_name)}; |
|
68
|
0
|
|
|
|
|
|
my @qun; |
|
69
|
|
|
|
|
|
|
$self->SUPER::each($self->{data},sub{ |
|
70
|
0
|
|
|
0
|
|
|
my $q = shift; |
|
71
|
0
|
0
|
0
|
|
|
|
return if defined $qun_type and $q->{qun_type} ne $qun_type; |
|
72
|
0
|
0
|
0
|
|
|
|
return if defined $qun_number and $q->{qun_number} ne $qun_number; |
|
73
|
0
|
0
|
0
|
|
|
|
return if defined $qun_name and $q->{qun_name} ne $qun_name; |
|
74
|
0
|
|
|
|
|
|
push @qun,bless dclone($q),__PACKAGE__ ."::One"; |
|
75
|
0
|
|
|
|
|
|
}); |
|
76
|
0
|
0
|
|
|
|
|
return wantarray?@qun:$qun[0]; |
|
77
|
|
|
|
|
|
|
} |
|
78
|
|
|
|
|
|
|
|
|
79
|
|
|
|
|
|
|
sub find_member { |
|
80
|
0
|
|
|
0
|
1
|
|
my $self = shift; |
|
81
|
0
|
|
|
|
|
|
$self->get_qun(); |
|
82
|
0
|
|
|
|
|
|
my %p = @_; |
|
83
|
0
|
|
|
|
|
|
my @member; |
|
84
|
0
|
|
|
|
|
|
my %filter = ( |
|
85
|
|
|
|
|
|
|
sex => 1, |
|
86
|
|
|
|
|
|
|
card => 1, |
|
87
|
|
|
|
|
|
|
qq => 1, |
|
88
|
|
|
|
|
|
|
nick => 1, |
|
89
|
|
|
|
|
|
|
role => 1, |
|
90
|
|
|
|
|
|
|
bad_record => 1, |
|
91
|
|
|
|
|
|
|
qun_name => 1, |
|
92
|
|
|
|
|
|
|
qun_number => 1, |
|
93
|
|
|
|
|
|
|
); |
|
94
|
0
|
|
|
|
|
|
for my $k (keys %p){ |
|
95
|
0
|
0
|
|
|
|
|
unless(exists $filter{$k}){ |
|
96
|
0
|
|
|
|
|
|
delete $p{$k} ; |
|
97
|
0
|
|
|
|
|
|
next; |
|
98
|
|
|
|
|
|
|
} |
|
99
|
0
|
0
|
|
|
|
|
delete $p{$k} unless defined $p{$k}; |
|
100
|
|
|
|
|
|
|
} |
|
101
|
0
|
|
|
|
|
|
my @tmp; |
|
102
|
0
|
|
|
|
|
|
push @tmp,@{$_->{members}} for @{$self->{data}}; |
|
|
0
|
|
|
|
|
|
|
|
|
0
|
|
|
|
|
|
|
|
103
|
|
|
|
|
|
|
$self->SUPER::each(@tmp,sub{ |
|
104
|
0
|
|
|
0
|
|
|
my $m = shift; |
|
105
|
0
|
|
|
|
|
|
for my $k (keys %p){ |
|
106
|
0
|
0
|
|
|
|
|
return if $m->{$k} ne $p{$k}; |
|
107
|
|
|
|
|
|
|
} |
|
108
|
0
|
|
|
|
|
|
push @member,bless dclone($m),"Webqq::Qun::Member"; |
|
109
|
0
|
|
|
|
|
|
}); |
|
110
|
|
|
|
|
|
|
|
|
111
|
0
|
0
|
|
|
|
|
return wantarray?@member:$member[0]; |
|
112
|
|
|
|
|
|
|
} |
|
113
|
|
|
|
|
|
|
|
|
114
|
|
|
|
|
|
|
sub each_member { |
|
115
|
0
|
|
|
0
|
1
|
|
my $self = shift; |
|
116
|
0
|
|
|
|
|
|
$self->get_qun(); |
|
117
|
0
|
|
|
|
|
|
my $callback = shift; |
|
118
|
|
|
|
|
|
|
$self->SUPER::each($self->{data},sub{ |
|
119
|
0
|
|
|
0
|
|
|
my $q = shift; |
|
120
|
0
|
|
|
|
|
|
for (@{$q->{members}}){ |
|
|
0
|
|
|
|
|
|
|
|
121
|
0
|
|
|
|
|
|
my $m = dclone($_); |
|
122
|
0
|
|
|
|
|
|
bless $m,"Webqq::Qun::Member"; |
|
123
|
0
|
|
|
|
|
|
$callback->($m); |
|
124
|
|
|
|
|
|
|
} |
|
125
|
0
|
|
|
|
|
|
}); |
|
126
|
|
|
|
|
|
|
} |
|
127
|
|
|
|
|
|
|
|
|
128
|
|
|
|
|
|
|
sub del_member { |
|
129
|
0
|
|
|
0
|
0
|
|
my $self = shift; |
|
130
|
0
|
|
|
|
|
|
my %opt; |
|
131
|
0
|
|
|
|
|
|
for my $p (@_){ |
|
132
|
0
|
|
|
|
|
|
my ($qq,$qun_number); |
|
133
|
0
|
0
|
|
|
|
|
if(blessed($p) eq "Webqq::Qun::Member"){ |
|
134
|
0
|
|
|
|
|
|
$qq = $p->{qq}; |
|
135
|
0
|
|
|
|
|
|
$qun_number = $p->{qun_number}; |
|
136
|
0
|
|
|
|
|
|
push @{ $opt{$qun_number} },$qq; |
|
|
0
|
|
|
|
|
|
|
|
137
|
|
|
|
|
|
|
} |
|
138
|
|
|
|
|
|
|
} |
|
139
|
0
|
|
|
|
|
|
for my $qun_number (keys %opt){ |
|
140
|
0
|
|
|
|
|
|
$self->SUPER::del_member($qun_number,@{$opt{$qun_number}}); |
|
|
0
|
|
|
|
|
|
|
|
141
|
|
|
|
|
|
|
} |
|
142
|
|
|
|
|
|
|
} |
|
143
|
|
|
|
|
|
|
|
|
144
|
|
|
|
|
|
|
sub add_member { |
|
145
|
0
|
|
|
0
|
0
|
|
my $self = shift; |
|
146
|
0
|
|
|
|
|
|
my %opt; |
|
147
|
0
|
|
|
|
|
|
for my $p (@_){ |
|
148
|
0
|
|
|
|
|
|
my ($qq,$qun_number); |
|
149
|
0
|
0
|
|
|
|
|
if(blessed($p) eq "Webqq::Qun::Member"){ |
|
150
|
0
|
|
|
|
|
|
$qq = $p->{qq}; |
|
151
|
0
|
|
|
|
|
|
$qun_number = $p->{qun_number}; |
|
152
|
0
|
|
|
|
|
|
push @{ $opt{$qun_number} },$qq; |
|
|
0
|
|
|
|
|
|
|
|
153
|
|
|
|
|
|
|
} |
|
154
|
|
|
|
|
|
|
} |
|
155
|
0
|
|
|
|
|
|
for my $qun_number (keys %opt){ |
|
156
|
0
|
|
|
|
|
|
$self->SUPER::add_member($qun_number,@{$opt{$qun_number}}); |
|
|
0
|
|
|
|
|
|
|
|
157
|
|
|
|
|
|
|
} |
|
158
|
|
|
|
|
|
|
} |
|
159
|
|
|
|
|
|
|
|
|
160
|
|
|
|
|
|
|
|
|
161
|
|
|
|
|
|
|
sub set_admin { |
|
162
|
0
|
|
|
0
|
0
|
|
my $self = shift; |
|
163
|
0
|
|
|
|
|
|
my %opt; |
|
164
|
0
|
|
|
|
|
|
for my $p (@_){ |
|
165
|
0
|
|
|
|
|
|
my ($qq,$qun_number); |
|
166
|
0
|
0
|
|
|
|
|
if(blessed($p) eq "Webqq::Qun::Member"){ |
|
167
|
0
|
|
|
|
|
|
$qq = $p->{qq}; |
|
168
|
0
|
|
|
|
|
|
$qun_number = $p->{qun_number}; |
|
169
|
0
|
|
|
|
|
|
push @{ $opt{$qun_number} },$qq; |
|
|
0
|
|
|
|
|
|
|
|
170
|
|
|
|
|
|
|
} |
|
171
|
|
|
|
|
|
|
} |
|
172
|
0
|
|
|
|
|
|
for my $qun_number (keys %opt){ |
|
173
|
0
|
|
|
|
|
|
$self->SUPER::set_admin($qun_number,@{$opt{$qun_number}}); |
|
|
0
|
|
|
|
|
|
|
|
174
|
|
|
|
|
|
|
} |
|
175
|
|
|
|
|
|
|
} |
|
176
|
|
|
|
|
|
|
|
|
177
|
|
|
|
|
|
|
sub del_admin { |
|
178
|
0
|
|
|
0
|
0
|
|
my $self = shift; |
|
179
|
0
|
|
|
|
|
|
for my $p (@_){ |
|
180
|
0
|
|
|
|
|
|
my ($qq,$qun_number); |
|
181
|
0
|
0
|
|
|
|
|
if(blessed($p) eq "Webqq::Qun::Member"){ |
|
182
|
0
|
|
|
|
|
|
$qq = $p->{qq}; |
|
183
|
0
|
|
|
|
|
|
$qun_number = $p->{qun_number}; |
|
184
|
|
|
|
|
|
|
} |
|
185
|
0
|
|
|
|
|
|
$self->SUPER::del_admin($qun_number,$qq); |
|
186
|
|
|
|
|
|
|
} |
|
187
|
|
|
|
|
|
|
} |
|
188
|
|
|
|
|
|
|
|
|
189
|
|
|
|
|
|
|
|
|
190
|
|
|
|
|
|
|
sub set_card{ |
|
191
|
0
|
|
|
0
|
0
|
|
my $self = shift; |
|
192
|
0
|
|
|
|
|
|
my $m = shift; |
|
193
|
0
|
|
|
|
|
|
my $card = shift; |
|
194
|
0
|
|
|
|
|
|
my %opt; |
|
195
|
0
|
|
|
|
|
|
my ($qq,$qun_number); |
|
196
|
0
|
0
|
|
|
|
|
if(blessed($m) eq "Webqq::Qun::Member"){ |
|
197
|
0
|
|
|
|
|
|
$qq = $m->{qq}; |
|
198
|
0
|
|
|
|
|
|
$qun_number = $m->{qun_number}; |
|
199
|
0
|
|
|
|
|
|
push @{ $opt{$qun_number} },$qq; |
|
|
0
|
|
|
|
|
|
|
|
200
|
|
|
|
|
|
|
} |
|
201
|
0
|
|
|
|
|
|
for my $qun_number (keys %opt){ |
|
202
|
0
|
|
|
|
|
|
$self->SUPER::set_card($qun_number,$qq,$card); |
|
203
|
|
|
|
|
|
|
} |
|
204
|
|
|
|
|
|
|
} |
|
205
|
|
|
|
|
|
|
1; |