« Webqq/Model/Remote/_get_group_list_info.pm
↑ Summary
Webqq/Model/Remote/_set_group_member_card.pm »
| 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; |