colourflood.pl: fix parsing

This commit is contained in:
wowaname 2016-11-11 10:16:12 +00:00
parent a7a0b72546
commit 5042035721

View File

@ -31,7 +31,7 @@ no strict 'subs';
my $SCRIPT_NAME = 'colourflood';
my $SCRIPT_AUTHOR = 'hzu';
my $SCRIPT_VERSION = '0.2';
my $SCRIPT_VERSION = '0.3';
my $SCRIPT_LICENCE = 'BSD';
my $SCRIPT_DESC = 'A-rab style ircing';
@ -100,21 +100,21 @@ sub colour {
}
sub parse {
my @args = ( split / +/, shift @_ );
my @args = ( split / +/, shift );
my ( %todo, $text, $body );
while ( $_ = shift @args ) {
/^-r$/ and $todo{r} = 1, next;
while ( ($_ = shift @args) ne '' ) {
/^-r$/ and next;
/^-f$/ and $todo{f} = shift @args, next;
/^-fg$/ and $todo{fg} = shift @args, next;
/^-bg$/ and $todo{bg} = shift @args, next;
/^-/ and weechat::print('', weechat::prefix('error').
'Invalid arguments (see /help cflood)'), return;
$text = ($#args < 0) ? $_ : $_ . " " . join( " ", @args );
$text = @args < 1 ? $_ : "$_ " . join ' ', @args;
last;
}
if ($todo{r} || !(defined $todo{fg}) || !(defined $todo{bg})) {
if (!(defined $todo{fg}) || !(defined $todo{bg})) {
$body = "";
my @rnd_clr = keys %clr;
foreach ( 1 .. (defined $todo{f} ? $todo{f} : 1 ) ) {
@ -136,7 +136,7 @@ sub cmd_cflood {
my (undef, $buffer, $data) = @_;
my $ret;
return weechat::WEECHAT_RC_OK unless ($data);
return weechat::WEECHAT_RC_OK if ($data eq '');
chomp( $ret = parse($data) );