Webqq/Plugin/Pu.pm untested

filter: Statementstmt 0.0% 0 / 22 Branchbran 0.0% 0 / 10 Conditioncond n/a MC/DCmcdc n/a Subroutinesub 0.0% 0 / 4 Podpod 0.0% 0 / 2 totaltotal 0.0% 0 / 38 CC 6 SCAR 29.1
CC
6
Cov
0%
call
30.0
BEGIN
6.0
BEGIN
2.0
CRAP 18.4
1 package Mojo::Webqq::Plugin::Pu;
2 $Mojo::Webqq::Plugin::Pu::PRIORITY = 1;
3 BEGIN{
4 eval{require ZHOUYI::ZhanPu};
5 our $is_hold_module = 1 unless $@;
6 }
7 use Mojo::Util qw();
8 sub call {
9 my $client = shift;
10 $client->die(__PACKAGE__ . '依赖ZHOUYI::ZhanPu模块,请先通过命令"cpanm ZHOUYI::ZhanPu"安装') if !$is_hold_module;
11 $client->on(receive_message=>sub{
12 my($client,$msg)=@_;
13 return if not $msg->allow_plugin;
14 return if $msg->content !~ /(周\s*易|占\s*卜|八\s*卦|算\s*命)/;
15 $msg->allow_plugin(0);
16 my $reply;
17 eval{$reply = Mojo::Util::encode("utf8",ZHOUYI::ZhanPu::pu()); };
18 $client->error( __PACKAGE__ . $@);
19 $msg->reply($reply,sub{$_[1]->from("bot")}) if $reply;
20 });
21 }
22 1;