Mojo-Weixin

 view release on metacpan or  search on metacpan

lib/Mojo/Weixin/Plugin/Perldoc.pm  view on Meta::CPAN

    my $data = shift;
    my $callback = sub{
        my($client,$msg)=@_;
        return if not $msg->allow_plugin;
        if($msg->content =~ /perldoc\s+-(v|f)\s+([^ ]+)/){
            $msg->allow_plugin(0);
            return if $msg->from eq "bot";
            my($p,$v) = ("-$1",$2);
            $client->spawn(
                cmd  =>sub{
                    local @ARGV=($p,$v);
                    require 5;
                    exit(Pod::Perldoc->run());
                },
                exec_timeout => 5,
                exit_cb => sub {
                    my($pid,$res)=@_;
                    my $reply;
                    if($res->{exit_status}==0){
                        $reply = $client->truncate($res->{stdout},max_lines=>10,max_bytes=>2000); 
                        $reply .= "\n查看更多内容: http://perldoc.perl.org/functions/$v.html" if $p eq "-f";

 view all matches for this distribution
 view release on metacpan -  search on metacpan

( run in 0.877 second using v1.00-cache-2.02-grep-82fe00e-cpan-c9a218a2bbc )