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