Webqq/Client/Plugin/HelloGirl.pm untested

filter: Statementstmt 0.0% 0 / 26 Branchbran 0.0% 0 / 12 Conditioncond 0.0% 0 / 6 MC/DCmcdc 0.0% 0 / 4 Subroutinesub 0.0% 0 / 2 Podpod 0.0% 0 / 1 totaltotal 0.0% 0 / 51 CC 7 SCAR 39.0
CC
7
Cov
0%
call
56.0
BEGIN
2.0
CRAP 49.2
1 package Webqq::Client::Plugin::HelloGirl;
2 use AE;
3 my @hello = (
4 "希望你在群里开心愉快",
5 "有问题尽管问哦,谁敢欺负你找管理员",
6 "\@全体成员 请注意,女王发话了",
7 "妹子一枚,鉴定完毕,大家欢迎呀",
8 "打劫!打劫!请把你身上所有不懂的问题全部交出来",
9 );
10 my %last;
11 sub call{
12 my ($client,$msg) = @_;
13 if($msg->{type} eq 'group_message'){
14 my $member = $client->search_member_in_group($msg->{group_code},$msg->{send_uin});
15 my $gender = $member->{gender} if defined $member;
16 if($gender eq 'female'){
17 my $is_question = $msg->{content}=~/问|帮|怎么/;
18 my $from_nick;
19 if($msg->{type} eq 'group_message'){
20 $from_nick = $msg->{card} || $msg->from_nick;
21 }
22 else{
23 $from_nick = $msg->from_nick;
24 }
25
26 my $from_qq = $msg->from_qq;
27 if(exists $last{$from_qq} and time - $last{$from_qq} < 3600){
28 return 1;
29 }
30 $client->reply_message($msg,"\@$from_nick " . $hello[int rand($#hello+1)]);
31 my $watcher = rand();
32 $client->{watchers}{$watcher} = AE::timer 600,0,sub{
33 delete $client->{watchers}{$watcher};
34 $client->reply_message($msg,"\@$from_nick " . "还需要什么帮助吗");
35 } if $is_question;
36 $last{$from_qq} = time;
37 return 1;
38 }
39 };
40  
41 return 1;
42 }
43 1;