line |
stmt |
bran |
cond |
sub |
pod |
time |
code |
1
|
1
|
|
|
1
|
|
4
|
use JSON; |
|
1
|
|
|
|
|
1
|
|
|
1
|
|
|
|
|
5
|
|
2
|
1
|
|
|
1
|
|
80
|
use Webqq::Client::Util qw(console code2state code2client); |
|
1
|
|
|
|
|
2
|
|
|
1
|
|
|
|
|
495
|
|
3
|
|
|
|
|
|
|
sub Webqq::Client::_get_group_info { |
4
|
0
|
|
|
0
|
|
|
my $self = shift; |
5
|
0
|
|
|
|
|
|
my $gcode = shift; |
6
|
0
|
|
|
|
|
|
my $ua = $self->{ua}; |
7
|
0
|
|
|
|
|
|
my $api_url = 'http://s.web2.qq.com/api/get_group_info_ext2'; |
8
|
0
|
|
|
|
|
|
my @query_string = ( |
9
|
|
|
|
|
|
|
gcode => $gcode, |
10
|
|
|
|
|
|
|
vfwebqq => $self->{qq_param}{vfwebqq}, |
11
|
|
|
|
|
|
|
t => time(), |
12
|
|
|
|
|
|
|
); |
13
|
|
|
|
|
|
|
|
14
|
0
|
0
|
|
|
|
|
if($self->{type} eq 'webqq'){ |
15
|
0
|
|
|
|
|
|
splice @query_string,2,0,(cb => "undefined"); |
16
|
|
|
|
|
|
|
} |
17
|
|
|
|
|
|
|
|
18
|
0
|
|
|
|
|
|
my @query_string_pairs; |
19
|
0
|
|
|
|
|
|
push @query_string_pairs , shift(@query_string) . "=" . shift(@query_string) while(@query_string); |
20
|
0
|
0
|
|
|
|
|
my @headers = $self->{type} eq 'webqq'? (Referer => 'http://s.web2.qq.com/proxy.html?v=20110412001&callback=1&id=3') |
21
|
|
|
|
|
|
|
: (Referer => 'http://s.web2.qq.com/proxy.html?v=20130916001&callback=1&id=1') |
22
|
|
|
|
|
|
|
; |
23
|
0
|
|
|
|
|
|
my $response = $ua->get($api_url.'?'.join("&",@query_string_pairs),@headers); |
24
|
0
|
0
|
|
|
|
|
if($response->is_success){ |
|
0
|
|
|
|
|
|
|
25
|
0
|
|
|
|
|
|
my $json; |
26
|
0
|
|
|
|
|
|
eval{ |
27
|
0
|
|
|
|
|
|
$json = JSON->new->utf8->decode($response->content()) ; |
28
|
|
|
|
|
|
|
}; |
29
|
0
|
0
|
|
|
|
|
$json = {} unless defined $json; |
30
|
0
|
0
|
|
|
|
|
my $ginfo_status = exists $json->{result}{ginfo}?"[ginfo-ok]":"[ginfo-not-ok]"; |
31
|
0
|
0
|
|
|
|
|
my $minfo_status = exists $json->{result}{minfo}?"[minfo-ok]":"[minfo-not-ok]"; |
32
|
|
|
|
|
|
|
|
33
|
0
|
0
|
|
|
|
|
if($self->{debug}){ |
34
|
0
|
|
|
|
|
|
print substr($response->content(),0,80),"${ginfo_status}${minfo_status}...\n"; |
35
|
0
|
0
|
|
|
|
|
console $@."\n" if $@; |
36
|
|
|
|
|
|
|
} |
37
|
|
|
|
|
|
|
|
38
|
0
|
0
|
|
|
|
|
return undef unless exists $json->{result}{ginfo}; |
39
|
|
|
|
|
|
|
#return undef unless exists $json->{result}{minfo}; |
40
|
0
|
|
|
|
|
|
delete $json->{result}{ginfo}{members}; |
41
|
0
|
|
|
|
|
|
for(keys %{$json->{result}{ginfo}}){ |
|
0
|
|
|
|
|
|
|
42
|
0
|
|
|
|
|
|
$json->{result}{ginfo}{$_} = encode("utf8",$json->{result}{ginfo}{$_}); |
43
|
|
|
|
|
|
|
} |
44
|
|
|
|
|
|
|
#retcode等于0说明包含完整的ginfo和minfo |
45
|
0
|
0
|
|
|
|
|
if($json->{retcode}==0){ |
46
|
0
|
0
|
|
|
|
|
return undef unless exists $json->{result}{minfo}; |
47
|
0
|
|
|
|
|
|
my %cards; |
48
|
0
|
|
|
|
|
|
for (@{ $json->{result}{cards} }){ |
|
0
|
|
|
|
|
|
|
49
|
0
|
|
|
|
|
|
$cards{$_->{muin}} = $_->{card}; |
50
|
|
|
|
|
|
|
} |
51
|
0
|
|
|
|
|
|
my %state; |
52
|
0
|
|
|
|
|
|
for(@{ $json->{result}{stats} }){ |
|
0
|
|
|
|
|
|
|
53
|
0
|
|
|
|
|
|
$state{$_->{uin}}{client_type} = $_->{client_type}; |
54
|
0
|
|
|
|
|
|
$state{$_->{uin}}{state} = code2state($_->{'stat'}); |
55
|
|
|
|
|
|
|
} |
56
|
0
|
|
|
|
|
|
for my $m(@{ $json->{result}{minfo} }){ |
|
0
|
|
|
|
|
|
|
57
|
0
|
0
|
|
|
|
|
$m->{card} = $cards{$m->{uin}} if exists $cards{$m->{uin}} ; |
58
|
0
|
0
|
|
|
|
|
if(exists $state{$m->{uin}}){ |
59
|
0
|
|
|
|
|
|
$m->{state} = $state{$m->{uin}}{state}; |
60
|
0
|
|
|
|
|
|
$m->{client_type} = code2client($state{$m->{uin}}{client_type}); |
61
|
|
|
|
|
|
|
} |
62
|
|
|
|
|
|
|
else{ |
63
|
0
|
|
|
|
|
|
$m->{state} = 'offline'; |
64
|
0
|
|
|
|
|
|
$m->{client_type} = 'unknown'; |
65
|
|
|
|
|
|
|
} |
66
|
0
|
|
|
|
|
|
for(keys %$m){ |
67
|
0
|
|
|
|
|
|
$m->{$_} = encode("utf8",$m->{$_}); |
68
|
|
|
|
|
|
|
} |
69
|
|
|
|
|
|
|
} |
70
|
0
|
|
|
|
|
|
my $group_info = { |
71
|
|
|
|
|
|
|
ginfo => $json->{result}{ginfo}, |
72
|
|
|
|
|
|
|
minfo => $json->{result}{minfo}, |
73
|
|
|
|
|
|
|
}; |
74
|
|
|
|
|
|
|
#查询结果同时进行缓存,以优化查询速度 |
75
|
|
|
|
|
|
|
#$self->{cache_for_group}->store($gcode,$group_info); |
76
|
0
|
|
|
|
|
|
return $group_info; |
77
|
|
|
|
|
|
|
} |
78
|
|
|
|
|
|
|
#只存在ginfo |
79
|
|
|
|
|
|
|
else{ |
80
|
0
|
|
|
|
|
|
my $group_info = { |
81
|
|
|
|
|
|
|
ginfo => $json->{result}{ginfo}, |
82
|
|
|
|
|
|
|
}; |
83
|
0
|
|
|
|
|
|
return $group_info; |
84
|
|
|
|
|
|
|
} |
85
|
|
|
|
|
|
|
} |
86
|
|
|
|
|
|
|
else{return undef;} |
87
|
|
|
|
|
|
|
} |
88
|
|
|
|
|
|
|
1; |