play.pl: minor

This commit is contained in:
wowaname 2016-12-19 05:00:27 +00:00
parent efc9356b14
commit efff17d8de
1 changed files with 12 additions and 5 deletions

View File

@ -13,7 +13,8 @@ our (%queue, %timer);
if (weechat::register($SCRIPT_NAME, $SCRIPT_AUTHOR, $SCRIPT_VERSION,
$SCRIPT_LICENCE, $SCRIPT_DESC, '', '')) {
weechat::hook_command('play', 'Play ASCII art',
qq([-delay ms] [-find] [-pipe "command"] [-fmt "list"] filename\n-stop),
'[-delay ms] [-repeat times] [-pipe "command"] [-fmt "list"] filename'.
"\n-find pattern\n-stop\n",
"-delay: delay in milliseconds between lines\n".
"-find: list matching files, don't play\n".
"-pipe: pipe output into command\n".
@ -22,7 +23,10 @@ if (weechat::register($SCRIPT_NAME, $SCRIPT_AUTHOR, $SCRIPT_VERSION,
"filename: file to play. Supports wildcards. By default, searches\n".
" subdirectories as well unless '/' is found in the filename\n".
"-stop: stop currently playing file in buffer",
'', 'cmd_play', '');
'-delay|-pipe|-fmt|-repeat|%*'.
' || -find'.
' || -stop',
'cmd_play', '');
my %OPTIONS = (
delay => ['Default delay between lines', 0],
@ -39,7 +43,8 @@ if (weechat::register($SCRIPT_NAME, $SCRIPT_AUTHOR, $SCRIPT_VERSION,
}
}
sub parse {
sub parse
{
my ($input, $delay, $pipe, $find, $repeat, $fmt) =
(shift, weechat::config_get_plugin('delay'), '/msg *', 0, 1, '');
@ -69,7 +74,8 @@ sub parse {
return ($delay, $pipe, $find, $repeat, $fmt, $input =~ s/^ +| +$//r);
}
sub play {
sub play
{
my $buffer = shift;
weechat::command($buffer, shift @{ $queue{$buffer} });
@ -78,7 +84,8 @@ sub play {
return weechat::WEECHAT_RC_OK;
}
sub cmd_play {
sub cmd_play
{
my $buffer = $_[1];
if ($_[2] eq '-stop') {