line |
stmt |
bran |
cond |
sub |
pod |
time |
code |
1
|
|
|
|
|
|
|
package Mojo::Webqq::Model::Base; |
2
|
1
|
|
|
1
|
|
9
|
use Mojo::Webqq::Base -base; |
|
1
|
|
|
|
|
2
|
|
|
1
|
|
|
|
|
10
|
|
3
|
1
|
|
|
1
|
|
7
|
use Scalar::Util qw(blessed); |
|
1
|
|
|
|
|
2
|
|
|
1
|
|
|
|
|
65
|
|
4
|
1
|
|
|
1
|
|
10
|
use Data::Dumper; |
|
1
|
|
|
|
|
2
|
|
|
1
|
|
|
|
|
894
|
|
5
|
|
|
|
|
|
|
sub client { |
6
|
0
|
|
|
0
|
0
|
|
return $Mojo::Webqq::_CLIENT; |
7
|
|
|
|
|
|
|
} |
8
|
|
|
|
|
|
|
sub to_json_hash{ |
9
|
0
|
|
|
0
|
0
|
|
my $self = shift; |
10
|
0
|
|
|
|
|
|
my $hash = {}; |
11
|
0
|
|
|
|
|
|
for(keys %$self){ |
12
|
0
|
0
|
|
|
|
|
next if substr($_,0,1) eq "_"; |
13
|
0
|
0
|
|
|
|
|
next if $_ eq "member"; |
14
|
0
|
|
|
|
|
|
$hash->{$_} = $self->{$_}; |
15
|
|
|
|
|
|
|
} |
16
|
0
|
0
|
|
|
|
|
if(exists $self->{member}){ |
17
|
0
|
|
|
|
|
|
$hash->{member} = []; |
18
|
0
|
0
|
|
|
|
|
if(ref $self->{member} eq "ARRAY"){ |
19
|
0
|
|
|
|
|
|
for my $m(@{$self->{member}}){ |
|
0
|
|
|
|
|
|
|
20
|
0
|
|
|
|
|
|
my $member_hash = $m->to_json_hash(); |
21
|
0
|
|
|
|
|
|
push @{$hash->{member}},$member_hash; |
|
0
|
|
|
|
|
|
|
22
|
|
|
|
|
|
|
} |
23
|
|
|
|
|
|
|
} |
24
|
|
|
|
|
|
|
} |
25
|
|
|
|
|
|
|
|
26
|
0
|
|
|
|
|
|
return $hash; |
27
|
|
|
|
|
|
|
} |
28
|
|
|
|
|
|
|
sub dump{ |
29
|
0
|
|
|
0
|
0
|
|
my $self = shift; |
30
|
0
|
|
|
|
|
|
my $clone = {}; |
31
|
0
|
|
|
|
|
|
my $obj_name = blessed($self); |
32
|
0
|
|
|
|
|
|
for(grep {substr($_,0,1) ne '_' } keys %$self){ |
|
0
|
|
|
|
|
|
|
33
|
0
|
0
|
0
|
|
|
|
if(my $n=blessed($self->{$_})){ |
|
|
0
|
|
|
|
|
|
34
|
0
|
|
|
|
|
|
$clone->{$_} = "Object($n)"; |
35
|
|
|
|
|
|
|
} |
36
|
|
|
|
|
|
|
elsif($_ eq "member" and ref($self->{$_}) eq "ARRAY"){ |
37
|
0
|
|
|
|
|
|
my $member_count = @{$self->{$_}}; |
|
0
|
|
|
|
|
|
|
38
|
0
|
|
|
|
|
|
$clone->{$_} = [ "$member_count of Object(${obj_name}::Member)" ]; |
39
|
|
|
|
|
|
|
} |
40
|
|
|
|
|
|
|
else{ |
41
|
0
|
|
|
|
|
|
$clone->{$_} = $self->{$_}; |
42
|
|
|
|
|
|
|
} |
43
|
|
|
|
|
|
|
} |
44
|
0
|
|
|
|
|
|
local $Data::Dumper::Indent = 1; |
45
|
0
|
|
|
|
|
|
local $Data::Dumper::Terse = 1; |
46
|
0
|
|
|
|
|
|
$self->client->print("Object($obj_name) " . Data::Dumper::Dumper($clone)); |
47
|
0
|
|
|
|
|
|
return $self; |
48
|
|
|
|
|
|
|
} |
49
|
|
|
|
|
|
|
|
50
|
|
|
|
|
|
|
sub type{ |
51
|
0
|
|
|
0
|
0
|
|
my $self = shift; |
52
|
0
|
|
|
|
|
|
my %map = ( |
53
|
|
|
|
|
|
|
"Mojo::Webqq::Friend" => "friend", |
54
|
|
|
|
|
|
|
"Mojo::Webqq::Group" => "group", |
55
|
|
|
|
|
|
|
"Mojo::Webqq::Group::Member" => "group_member", |
56
|
|
|
|
|
|
|
"Mojo::Webqq::Discuss" => "discuss", |
57
|
|
|
|
|
|
|
"Mojo::Webqq::Disucc::Member" => "discuss_member", |
58
|
|
|
|
|
|
|
"Mojo::Webqq::User" => "user", |
59
|
|
|
|
|
|
|
"Mojo::Webqq::Recent::Friend" => "recent_friend", |
60
|
|
|
|
|
|
|
"Mojo::Webqq::Recent::Group" => "recent_group", |
61
|
|
|
|
|
|
|
"Mojo::Webqq::Recent::Discuss" => "recent_discuss", |
62
|
|
|
|
|
|
|
); |
63
|
0
|
|
|
|
|
|
return $map{ref($self)}; |
64
|
|
|
|
|
|
|
} |
65
|
|
|
|
|
|
|
|
66
|
|
|
|
|
|
|
sub is_friend{ |
67
|
0
|
|
|
0
|
0
|
|
my $self = shift; |
68
|
0
|
0
|
|
|
|
|
ref $self eq "Mojo::Webqq::Friend"?1:0; |
69
|
|
|
|
|
|
|
} |
70
|
|
|
|
|
|
|
sub is_group{ |
71
|
0
|
|
|
0
|
0
|
|
my $self = shift; |
72
|
0
|
0
|
|
|
|
|
ref $self eq "Mojo::Webqq::Group"?1:0; |
73
|
|
|
|
|
|
|
} |
74
|
|
|
|
|
|
|
sub is_group_member{ |
75
|
0
|
|
|
0
|
0
|
|
my $self = shift; |
76
|
0
|
0
|
|
|
|
|
ref $self eq "Mojo::Webqq::Group::Member"?1:0; |
77
|
|
|
|
|
|
|
} |
78
|
|
|
|
|
|
|
sub is_discuss{ |
79
|
0
|
|
|
0
|
0
|
|
my $self = shift; |
80
|
0
|
0
|
|
|
|
|
ref $self eq "Mojo::Webqq::Discuss"?1:0; |
81
|
|
|
|
|
|
|
} |
82
|
|
|
|
|
|
|
sub is_discuss_member{ |
83
|
0
|
|
|
0
|
0
|
|
my $self = shift; |
84
|
0
|
0
|
|
|
|
|
ref $self eq "Mojo::Webqq::Discuss::Member"?1:0; |
85
|
|
|
|
|
|
|
} |
86
|
|
|
|
|
|
|
sub is_me{ |
87
|
0
|
|
|
0
|
0
|
|
my $self = shift; |
88
|
0
|
0
|
|
|
|
|
return 1 if ref $self eq "Mojo::Webqq::User"; |
89
|
0
|
0
|
0
|
|
|
|
if($self->is_group_member or $self->is_discuss_member){ |
90
|
0
|
0
|
|
|
|
|
return 1 if $self->id eq $self->client->user->id; |
91
|
|
|
|
|
|
|
} |
92
|
0
|
|
|
|
|
|
return 0; |
93
|
|
|
|
|
|
|
} |
94
|
|
|
|
|
|
|
|
95
|
|
|
|
|
|
|
1; |