Mojo-Webqq
view release on metacpan or search on metacpan
lib/Mojo/Webqq/Plugin/Perldoc.pm view on Meta::CPAN
111213141516171819202122232425262728293031my
$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
->class eq
"send"
and
$msg
->from ne
"api"
and
$msg
->from ne
"irc"
;
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
=>8,
max_bytes
=>2000);
( run in 0.488 second using v1.01-cache-2.11-cpan-3cd7ad12f66 )