Webqq/Client/Plugin/SmartReply2.pm untested

filter: Statementstmt 0.0% 0 / 17 Branchbran 0.0% 0 / 6 Conditioncond 0.0% 0 / 3 MC/DCmcdc 0.0% 0 / 2 Subroutinesub 0.0% 0 / 1 Podpod 0.0% 0 / 1 totaltotal 0.0% 0 / 30 CC 4 SCAR 30.0
CC
4
Cov
0%
call
20.0
CRAP 20.0
1 package Webqq::Client::Plugin::SmartReply2;
2 my $API = 'http://www.xiaodoubi.com/bot/api.php?chat=';
3 sub call{
4 my $client = shift;
5 my $msg = shift;
6 my $res;
7 eval{
8 local $SIG{ALRM} = sub{die "timout\n"};
9 alarm 5;
10 $res = $client->{ua}->get($API . $msg->{content});
11 alarm 0;
12 };
13 print "Webqq::Client::App::SmartReply请求超时\n" if $@ and $client->{debug};
14 if($res->is_success){
15 my $data = $res->content;
16 $data=~s/小逗比/小灰/g;
17 if($data){
18 $client->reply_message($msg,$data);
19 }
20 }
21 else{return undef}
22
23 }
24 1;