line |
stmt |
bran |
cond |
sub |
pod |
time |
code |
1
|
|
|
|
|
|
|
package Mojo::Webqq::Group; |
2
|
1
|
|
|
1
|
|
8
|
use strict; |
|
1
|
|
|
|
|
2
|
|
|
1
|
|
|
|
|
35
|
|
3
|
1
|
|
|
1
|
|
4
|
use List::Util qw(first); |
|
1
|
|
|
|
|
2
|
|
|
1
|
|
|
|
|
66
|
|
4
|
1
|
|
|
1
|
|
433
|
use Mojo::Webqq::Group::Member; |
|
1
|
|
|
|
|
2
|
|
|
1
|
|
|
|
|
9
|
|
5
|
1
|
|
|
1
|
|
7
|
use Mojo::Webqq::Base 'Mojo::Webqq::Model::Base'; |
|
1
|
|
|
|
|
2
|
|
|
1
|
|
|
|
|
4
|
|
6
|
|
|
|
|
|
|
has [qw( |
7
|
|
|
|
|
|
|
id |
8
|
|
|
|
|
|
|
uid |
9
|
|
|
|
|
|
|
code |
10
|
|
|
|
|
|
|
role |
11
|
|
|
|
|
|
|
name |
12
|
|
|
|
|
|
|
memo |
13
|
|
|
|
|
|
|
createtime |
14
|
|
|
|
|
|
|
level |
15
|
|
|
|
|
|
|
owner_id |
16
|
|
|
|
|
|
|
owner_uid |
17
|
|
|
|
|
|
|
markname |
18
|
|
|
|
|
|
|
max_member |
19
|
|
|
|
|
|
|
max_admin |
20
|
|
|
|
|
|
|
)]; |
21
|
|
|
|
|
|
|
has member => sub{[]}; |
22
|
|
|
|
|
|
|
has _is_hold_member_ext => 0; |
23
|
0
|
|
|
0
|
0
|
|
sub member_count {0+@{$_[0]->member}} |
|
0
|
|
|
|
|
|
|
24
|
0
|
|
|
0
|
0
|
|
sub number {$_[0]->uid} |
25
|
|
|
|
|
|
|
sub AUTOLOAD { |
26
|
0
|
|
|
0
|
|
|
my $self = shift; |
27
|
0
|
0
|
|
|
|
|
if($Mojo::Webqq::Group::AUTOLOAD =~ /.*::gnumber/){ |
|
|
0
|
|
|
|
|
|
|
|
0
|
|
|
|
|
|
28
|
0
|
|
|
|
|
|
$self->uid(@_); |
29
|
|
|
|
|
|
|
} |
30
|
|
|
|
|
|
|
elsif($Mojo::Webqq::Group::AUTOLOAD =~ /.*::gtype/){ |
31
|
0
|
|
|
|
|
|
$self->role(@_); |
32
|
|
|
|
|
|
|
} |
33
|
|
|
|
|
|
|
elsif($Mojo::Webqq::Group::AUTOLOAD =~ /.*::g(.*)/){ |
34
|
0
|
|
|
|
|
|
my $attr = $1; |
35
|
0
|
|
|
|
|
|
$self->$attr(@_); |
36
|
|
|
|
|
|
|
} |
37
|
0
|
|
|
|
|
|
else{die("undefined subroutine $Mojo::Webqq::Group::AUTOLOAD");} |
38
|
|
|
|
|
|
|
} |
39
|
|
|
|
|
|
|
sub displayname { |
40
|
0
|
|
|
0
|
0
|
|
my $self = shift; |
41
|
0
|
0
|
|
|
|
|
return defined $self->markname?$self->markname:$self->name; |
42
|
|
|
|
|
|
|
} |
43
|
|
|
|
|
|
|
sub new { |
44
|
0
|
|
|
0
|
0
|
|
my $class = shift; |
45
|
0
|
|
|
|
|
|
my $self ; |
46
|
0
|
0
|
0
|
|
|
|
bless $self=@_ ? @_ > 1 ? {@_} : {%{$_[0]}} : {}, ref $class || $class; |
|
0
|
0
|
|
|
|
|
|
47
|
0
|
0
|
0
|
|
|
|
if(exists $self->{member} and ref $self->{member} eq "ARRAY"){ |
48
|
0
|
|
|
|
|
|
for( @{ $self->{member} } ){ |
|
0
|
|
|
|
|
|
|
49
|
0
|
0
|
|
|
|
|
$_->{_group_id} = $self->id if not defined $_->{_group_id}; |
50
|
0
|
0
|
|
|
|
|
$_ = Mojo::Webqq::Group::Member->new($_) if ref $_ ne "Mojo::Webqq::Group::Member"; |
51
|
|
|
|
|
|
|
} |
52
|
|
|
|
|
|
|
} |
53
|
0
|
|
|
|
|
|
$self; |
54
|
|
|
|
|
|
|
} |
55
|
|
|
|
|
|
|
|
56
|
|
|
|
|
|
|
sub each_group_member{ |
57
|
0
|
|
|
0
|
0
|
|
my $self = shift; |
58
|
0
|
|
|
|
|
|
my $callback = shift; |
59
|
0
|
0
|
|
|
|
|
$self->client->die("参数必须是函数引用") if ref $callback ne "CODE"; |
60
|
0
|
0
|
|
|
|
|
return if ref $self->member ne "ARRAY"; |
61
|
0
|
0
|
|
|
|
|
$self->client->update_group($self) if $self->is_empty; |
62
|
0
|
|
|
|
|
|
for(@{$self->member}){ |
|
0
|
|
|
|
|
|
|
63
|
0
|
|
|
|
|
|
$callback->($self->client,$_); |
64
|
|
|
|
|
|
|
} |
65
|
|
|
|
|
|
|
} |
66
|
|
|
|
|
|
|
sub members { |
67
|
0
|
|
|
0
|
0
|
|
my $self = shift; |
68
|
0
|
0
|
|
|
|
|
$self->client->update_group($self) if $self->is_empty; |
69
|
0
|
|
|
|
|
|
return @{$self->member}; |
|
0
|
|
|
|
|
|
|
70
|
|
|
|
|
|
|
} |
71
|
|
|
|
|
|
|
sub search_group_member{ |
72
|
1
|
|
|
1
|
|
9
|
no warnings 'uninitialized'; |
|
1
|
|
|
|
|
2
|
|
|
1
|
|
|
|
|
1728
|
|
73
|
0
|
|
|
0
|
0
|
|
my $self = shift; |
74
|
0
|
|
|
|
|
|
my %p = @_; |
75
|
0
|
0
|
|
|
|
|
return if 0 == grep {defined $p{$_}} keys %p; |
|
0
|
|
|
|
|
|
|
76
|
0
|
0
|
|
|
|
|
$self->client->update_group($self) if $self->is_empty; |
77
|
0
|
0
|
|
|
|
|
if(wantarray){ |
78
|
0
|
0
|
|
0
|
|
|
return grep {my $m = $_;(first {$p{$_} ne $m->$_} grep {defined $p{$_}} keys %p) ? 0 : 1;} @{$self->member}; |
|
0
|
|
|
|
|
|
|
|
0
|
|
|
|
|
|
|
|
0
|
|
|
|
|
|
|
|
0
|
|
|
|
|
|
|
|
0
|
|
|
|
|
|
|
79
|
|
|
|
|
|
|
} |
80
|
|
|
|
|
|
|
else{ |
81
|
0
|
0
|
|
0
|
|
|
return first {my $m = $_;(first {$p{$_} ne $m->$_} grep {defined $p{$_}} keys %p) ? 0 : 1;} @{$self->member}; |
|
0
|
|
|
|
|
|
|
|
0
|
|
|
|
|
|
|
|
0
|
|
|
|
|
|
|
|
0
|
|
|
|
|
|
|
|
0
|
|
|
|
|
|
|
82
|
|
|
|
|
|
|
} |
83
|
|
|
|
|
|
|
} |
84
|
|
|
|
|
|
|
|
85
|
|
|
|
|
|
|
sub add_group_member{ |
86
|
0
|
|
|
0
|
0
|
|
my $self = shift; |
87
|
0
|
|
|
|
|
|
my $member = shift; |
88
|
0
|
|
|
|
|
|
my $nocheck = shift; |
89
|
0
|
0
|
|
|
|
|
$self->client->die("不支持的数据类型") if ref $member ne "Mojo::Webqq::Group::Member"; |
90
|
0
|
0
|
|
|
|
|
if($nocheck){ |
91
|
0
|
|
|
|
|
|
push @{$self->member},$member; |
|
0
|
|
|
|
|
|
|
92
|
0
|
|
|
|
|
|
return $self; |
93
|
|
|
|
|
|
|
} |
94
|
0
|
|
|
|
|
|
my $m = $self->search_group_member(id=>$member->id); |
95
|
0
|
0
|
|
|
|
|
if(defined $m){ |
96
|
0
|
|
|
|
|
|
%$m = %$member; |
97
|
|
|
|
|
|
|
} |
98
|
|
|
|
|
|
|
else{ |
99
|
0
|
|
|
|
|
|
push @{$self->member},$member; |
|
0
|
|
|
|
|
|
|
100
|
|
|
|
|
|
|
} |
101
|
0
|
|
|
|
|
|
return $self; |
102
|
|
|
|
|
|
|
} |
103
|
|
|
|
|
|
|
|
104
|
|
|
|
|
|
|
sub remove_group_member{ |
105
|
0
|
|
|
0
|
0
|
|
my $self = shift; |
106
|
0
|
|
|
|
|
|
my $member = shift; |
107
|
0
|
0
|
|
|
|
|
$self->client->die("不支持的数据类型") if ref $member ne "Mojo::Webqq::Group::Member"; |
108
|
0
|
|
|
|
|
|
for(my $i=0;$i<@{$self->member};$i++){ |
|
0
|
|
|
|
|
|
|
109
|
0
|
0
|
|
|
|
|
if($self->member->[$i]->id eq $member->id){ |
110
|
0
|
|
|
|
|
|
splice @{$self->member},$i,1; |
|
0
|
|
|
|
|
|
|
111
|
0
|
|
|
|
|
|
return 1; |
112
|
|
|
|
|
|
|
} |
113
|
|
|
|
|
|
|
} |
114
|
0
|
|
|
|
|
|
return; |
115
|
|
|
|
|
|
|
} |
116
|
|
|
|
|
|
|
|
117
|
|
|
|
|
|
|
sub is_empty{ |
118
|
0
|
|
|
0
|
0
|
|
my $self = shift; |
119
|
0
|
0
|
|
|
|
|
return !(ref($self->member) eq "ARRAY"?0+@{$self->member}:0); |
|
0
|
|
|
|
|
|
|
120
|
|
|
|
|
|
|
} |
121
|
|
|
|
|
|
|
|
122
|
|
|
|
|
|
|
sub update_group_member_ext { |
123
|
0
|
|
|
0
|
0
|
|
my $self = shift; |
124
|
0
|
|
|
|
|
|
$self->client->update_group_member_ext($self,@_); |
125
|
|
|
|
|
|
|
} |
126
|
|
|
|
|
|
|
sub update_group_member { |
127
|
0
|
|
|
0
|
0
|
|
my $self = shift; |
128
|
0
|
|
|
|
|
|
$self->client->update_group_member($self,@_); |
129
|
|
|
|
|
|
|
} |
130
|
|
|
|
|
|
|
sub update{ |
131
|
0
|
|
|
0
|
0
|
|
my $self = shift; |
132
|
0
|
|
|
|
|
|
my $hash = shift; |
133
|
0
|
|
|
|
|
|
for(grep {substr($_,0,1) ne "_"} keys %$hash){ |
|
0
|
|
|
|
|
|
|
134
|
0
|
0
|
0
|
|
|
|
if($_ eq "member" and ref $hash->{member} eq "ARRAY"){ |
135
|
0
|
0
|
|
|
|
|
next if not @{$hash->{member}}; |
|
0
|
|
|
|
|
|
|
136
|
0
|
0
|
|
|
|
|
my @member = map {ref $_ eq "Mojo::Webqq::Group::Member"?$_:Mojo::Webqq::Group::Member->new($_)} @{$hash->{member}}; |
|
0
|
|
|
|
|
|
|
|
0
|
|
|
|
|
|
|
137
|
0
|
0
|
|
|
|
|
if( $self->is_empty() ){ |
138
|
0
|
|
|
|
|
|
$self->member(\@member); |
139
|
|
|
|
|
|
|
} |
140
|
|
|
|
|
|
|
else{ |
141
|
0
|
|
|
0
|
|
|
my($new_members,$lost_members,$sames)=$self->client->array_diff($self->member, \@member,sub{$_[0]->id}); |
|
0
|
|
|
|
|
|
|
142
|
0
|
|
|
|
|
|
for(@{$new_members}){ |
|
0
|
|
|
|
|
|
|
143
|
0
|
|
|
|
|
|
$self->add_group_member($_); |
144
|
0
|
|
|
|
|
|
$self->client->emit(new_group_member=>$_,$self); |
145
|
|
|
|
|
|
|
} |
146
|
0
|
|
|
|
|
|
for(@{$lost_members}){ |
|
0
|
|
|
|
|
|
|
147
|
0
|
|
|
|
|
|
$self->remove_group_member($_); |
148
|
0
|
|
|
|
|
|
$self->client->emit(lose_group_member=>$_,$self); |
149
|
|
|
|
|
|
|
} |
150
|
0
|
|
|
|
|
|
for(@{$sames}){ |
|
0
|
|
|
|
|
|
|
151
|
0
|
|
|
|
|
|
my($old_member,$new_member) = ($_->[0],$_->[1]); |
152
|
0
|
|
|
|
|
|
$old_member->update($new_member); |
153
|
|
|
|
|
|
|
} |
154
|
|
|
|
|
|
|
#$self->member(\@member); |
155
|
|
|
|
|
|
|
} |
156
|
|
|
|
|
|
|
} |
157
|
|
|
|
|
|
|
else{ |
158
|
0
|
0
|
|
|
|
|
if(exists $hash->{$_}){ |
159
|
0
|
0
|
0
|
|
|
|
if(defined $hash->{$_} and defined $self->{$_}){ |
|
|
0
|
0
|
|
|
|
|
160
|
0
|
0
|
|
|
|
|
if($hash->{$_} ne $self->{$_}){ |
161
|
0
|
|
|
|
|
|
my $old_property = $self->{$_}; |
162
|
0
|
|
|
|
|
|
my $new_property = $hash->{$_}; |
163
|
0
|
|
|
|
|
|
$self->{$_} = $hash->{$_}; |
164
|
0
|
|
|
|
|
|
$self->client->emit("group_property_change"=>$self,$_,$old_property,$new_property); |
165
|
|
|
|
|
|
|
} |
166
|
|
|
|
|
|
|
} |
167
|
|
|
|
|
|
|
elsif( ! (!defined $hash->{$_} and !defined $self->{$_}) ){ |
168
|
0
|
|
|
|
|
|
my $old_property = $self->{$_}; |
169
|
0
|
|
|
|
|
|
my $new_property = $hash->{$_}; |
170
|
0
|
|
|
|
|
|
$self->{$_} = $hash->{$_}; |
171
|
0
|
|
|
|
|
|
$self->client->emit("group_property_change"=>$self,$_,$old_property,$new_property); |
172
|
|
|
|
|
|
|
} |
173
|
|
|
|
|
|
|
} |
174
|
|
|
|
|
|
|
} |
175
|
|
|
|
|
|
|
} |
176
|
0
|
|
|
|
|
|
$self; |
177
|
|
|
|
|
|
|
} |
178
|
|
|
|
|
|
|
|
179
|
|
|
|
|
|
|
sub send { |
180
|
0
|
|
|
0
|
0
|
|
my $self = shift; |
181
|
0
|
|
|
|
|
|
$self->client->send_group_message($self,@_); |
182
|
|
|
|
|
|
|
} |
183
|
|
|
|
|
|
|
sub me { |
184
|
0
|
|
|
0
|
0
|
|
my $self = shift; |
185
|
0
|
|
|
|
|
|
$self->search_group_member(id=>$self->client->user->id); |
186
|
|
|
|
|
|
|
} |
187
|
|
|
|
|
|
|
sub invite_friend{ |
188
|
0
|
|
|
0
|
0
|
|
my $self = shift; |
189
|
0
|
|
|
|
|
|
my @friends = @_; |
190
|
0
|
|
|
|
|
|
return $self->client->invite_friend($self,@friends); |
191
|
|
|
|
|
|
|
} |
192
|
|
|
|
|
|
|
sub shutup_group_member{ |
193
|
0
|
|
|
0
|
0
|
|
my $self = shift; |
194
|
0
|
|
|
|
|
|
my $time = shift; |
195
|
0
|
|
|
|
|
|
my @members = @_; |
196
|
0
|
|
|
|
|
|
return $self->client->shutup_group_member($self,$time,@members); |
197
|
|
|
|
|
|
|
} |
198
|
|
|
|
|
|
|
sub speakup_group_member{ |
199
|
0
|
|
|
0
|
0
|
|
my $self = shift; |
200
|
0
|
|
|
|
|
|
my @members = @_; |
201
|
0
|
|
|
|
|
|
return $self->client->speakup_group_member($self,@members); |
202
|
|
|
|
|
|
|
} |
203
|
|
|
|
|
|
|
sub kick_group_member{ |
204
|
0
|
|
|
0
|
0
|
|
my $self = shift; |
205
|
0
|
|
|
|
|
|
my @members = @_; |
206
|
0
|
|
|
|
|
|
return $self->client->kick_group_member($self,@members); |
207
|
|
|
|
|
|
|
} |
208
|
|
|
|
|
|
|
sub set_group_admin{ |
209
|
0
|
|
|
0
|
0
|
|
my $self = shift; |
210
|
0
|
|
|
|
|
|
my @members = @_; |
211
|
0
|
|
|
|
|
|
return $self->client->set_group_admin($self,@members); |
212
|
|
|
|
|
|
|
} |
213
|
|
|
|
|
|
|
sub remove_group_admin{ |
214
|
0
|
|
|
0
|
0
|
|
my $self = shift; |
215
|
0
|
|
|
|
|
|
my @members = @_; |
216
|
0
|
|
|
|
|
|
return $self->client->remove_group_admin($self,@members); |
217
|
|
|
|
|
|
|
} |
218
|
|
|
|
|
|
|
sub set_group_member_card{ |
219
|
0
|
|
|
0
|
0
|
|
my $self = shift; |
220
|
0
|
|
|
|
|
|
my $member = shift; |
221
|
0
|
|
|
|
|
|
my $card = shift; |
222
|
0
|
|
|
|
|
|
return $self->client->set_group_member_card($self,$member,$card); |
223
|
|
|
|
|
|
|
} |
224
|
|
|
|
|
|
|
sub qiandao { |
225
|
0
|
|
|
0
|
0
|
|
my $self = shift; |
226
|
0
|
|
|
|
|
|
return $self->client->qiandao($self); |
227
|
|
|
|
|
|
|
} |
228
|
|
|
|
|
|
|
1; |