line |
stmt |
bran |
cond |
sub |
pod |
time |
code |
1
|
1
|
|
|
1
|
|
7
|
use File::Temp qw/:seekable/; |
|
1
|
|
|
|
|
3
|
|
|
1
|
|
|
|
|
126
|
|
2
|
1
|
|
|
1
|
|
7
|
use Mojo::Util qw/url_escape/; |
|
1
|
|
|
|
|
2
|
|
|
1
|
|
|
|
|
611
|
|
3
|
|
|
|
|
|
|
sub Mojo::Webqq::Client::_get_group_pic { |
4
|
0
|
|
|
0
|
|
|
my $self = shift; |
5
|
0
|
|
|
|
|
|
my $fid = shift; |
6
|
0
|
|
|
|
|
|
my $pic_name = shift; |
7
|
0
|
|
|
|
|
|
my $rip = shift; |
8
|
0
|
|
|
|
|
|
my $rport = shift; |
9
|
0
|
|
|
|
|
|
my $sender = shift; |
10
|
0
|
|
|
|
|
|
my $cb = pop; |
11
|
|
|
|
|
|
|
|
12
|
0
|
0
|
|
|
|
|
return if $sender->is_discuss_member; |
13
|
0
|
|
|
|
|
|
my $api = 'http://web2.qq.com/cgi-bin/get_group_pic'; |
14
|
0
|
|
|
|
|
|
my @query_string ; |
15
|
0
|
0
|
|
|
|
|
if($sender->is_group_member){ |
|
|
0
|
|
|
|
|
|
16
|
0
|
|
|
|
|
|
@query_string= ( |
17
|
|
|
|
|
|
|
type => 0, |
18
|
|
|
|
|
|
|
fid => $fid, |
19
|
|
|
|
|
|
|
gid => $sender->gcode, |
20
|
|
|
|
|
|
|
pic => url_escape($pic_name), |
21
|
|
|
|
|
|
|
rip => $rip, |
22
|
|
|
|
|
|
|
rport => $rport, |
23
|
|
|
|
|
|
|
uin => $sender->id, |
24
|
|
|
|
|
|
|
vfwebqq => $self->vfwebqq, |
25
|
|
|
|
|
|
|
t => rand(), |
26
|
|
|
|
|
|
|
); |
27
|
|
|
|
|
|
|
} |
28
|
|
|
|
|
|
|
elsif($sender->is_discuss_member){ |
29
|
0
|
|
|
|
|
|
@query_string= ( |
30
|
|
|
|
|
|
|
type => 0, |
31
|
|
|
|
|
|
|
fid => $fid, |
32
|
|
|
|
|
|
|
did => $sender->did, |
33
|
|
|
|
|
|
|
pic => url_escape($pic_name), |
34
|
|
|
|
|
|
|
rip => $rip, |
35
|
|
|
|
|
|
|
rport => $rport, |
36
|
|
|
|
|
|
|
uin => $sender->id, |
37
|
|
|
|
|
|
|
vfwebqq => $self->vfwebqq, |
38
|
|
|
|
|
|
|
t => rand(), |
39
|
|
|
|
|
|
|
); |
40
|
|
|
|
|
|
|
} |
41
|
|
|
|
|
|
|
my $callback = sub{ |
42
|
0
|
|
|
0
|
|
|
my ($data,$ua,$tx) = @_; |
43
|
0
|
0
|
|
|
|
|
unless(defined $data){ |
44
|
0
|
|
|
|
|
|
$self->warn("群图片下载失败: " . $tx->error->{message}); |
45
|
0
|
|
|
|
|
|
return; |
46
|
|
|
|
|
|
|
} |
47
|
0
|
0
|
|
|
|
|
return unless $tx->res->headers->content_type =~/^image\/(.*)/; |
48
|
0
|
0
|
|
|
|
|
my $type = $1=~/jpe?g/i ? ".jpg" |
|
|
0
|
|
|
|
|
|
|
|
0
|
|
|
|
|
|
|
|
0
|
|
|
|
|
|
49
|
|
|
|
|
|
|
: $1=~/png/i ? ".png" |
50
|
|
|
|
|
|
|
: $1=~/bmp/i ? ".bmp" |
51
|
|
|
|
|
|
|
: $1=~/gif/i ? ".gif" |
52
|
|
|
|
|
|
|
: undef |
53
|
|
|
|
|
|
|
; |
54
|
0
|
0
|
|
|
|
|
return unless defined $type; |
55
|
0
|
0
|
0
|
|
|
|
if(defined $self->pic_dir and not -d $self->pic_dir){ |
56
|
0
|
|
|
|
|
|
$self->error("无效的 pic_dir: " . $self->pic_dir); |
57
|
0
|
|
|
|
|
|
return; |
58
|
|
|
|
|
|
|
} |
59
|
0
|
|
|
|
|
|
my @opt = ( |
60
|
|
|
|
|
|
|
TEMPLATE => "mojo_webqq_cface_XXXX", |
61
|
|
|
|
|
|
|
SUFFIX => $type, |
62
|
|
|
|
|
|
|
UNLINK => 0, |
63
|
|
|
|
|
|
|
); |
64
|
0
|
0
|
|
|
|
|
defined $self->pic_dir?(push @opt,(DIR=>$self->pic_dir)):(push @opt,(TMPDIR=>1)); |
65
|
0
|
|
|
|
|
|
eval{ |
66
|
0
|
|
|
|
|
|
my $tmp = File::Temp->new(@opt); |
67
|
0
|
|
|
|
|
|
binmode $tmp; |
68
|
0
|
|
|
|
|
|
print $tmp $tx->res->body(); |
69
|
0
|
|
|
|
|
|
close $tmp; |
70
|
0
|
|
|
|
|
|
$self->emit(receive_pic => $tmp->filename,$sender); |
71
|
0
|
0
|
|
|
|
|
if($sender->is_group_member){ |
72
|
0
|
|
|
|
|
|
$self->emit(receive_group_pic => $tmp->filename,$sender); |
73
|
|
|
|
|
|
|
} |
74
|
|
|
|
|
|
|
else{ |
75
|
0
|
|
|
|
|
|
$self->emit(receive_disucss_pic => $tmp->filename,$sender); |
76
|
|
|
|
|
|
|
} |
77
|
0
|
0
|
|
|
|
|
$cb->($self,$tmp->filename,$sender) if ref $cb eq "CODE"; |
78
|
|
|
|
|
|
|
}; |
79
|
0
|
0
|
|
|
|
|
$self->error("[Mojo::Webqq::Client::_get_group_pic] $@") if $@; |
80
|
0
|
|
|
|
|
|
}; |
81
|
0
|
|
|
|
|
|
$self->http_get($self->gen_url($api,@query_string),{Referer=>'http://'. $self->domain . '/'},$callback); |
82
|
|
|
|
|
|
|
}; |
83
|
|
|
|
|
|
|
1; |