3
0
mirror of https://github.com/pragma-/pbot.git synced 2024-11-26 22:09:26 +01:00

Change split / / to split /\s+/ throughout

This commit is contained in:
Pragmatic Software 2017-09-02 00:39:29 -07:00
parent 793303fcde
commit 1b70de807b
11 changed files with 38 additions and 38 deletions

View File

@ -130,7 +130,7 @@ sub whitelist {
my ($self, $from, $nick, $user, $host, $arguments) = @_; my ($self, $from, $nick, $user, $host, $arguments) = @_;
$arguments = lc $arguments; $arguments = lc $arguments;
my ($command, $args) = split / /, $arguments, 2; my ($command, $args) = split /\s+/, $arguments, 2;
return "Usage: whitelist <command>, where commands are: list/show, add, remove, set, unset" if not defined $command; return "Usage: whitelist <command>, where commands are: list/show, add, remove, set, unset" if not defined $command;
@ -154,7 +154,7 @@ sub whitelist {
return $text; return $text;
} }
when ("set") { when ("set") {
my ($channel, $mask, $flag, $value) = split / /, $args, 4; my ($channel, $mask, $flag, $value) = split /\s+/, $args, 4;
return "Usage: whitelist set <channel> <mask> [flag] [value]" if not defined $channel or not defined $mask; return "Usage: whitelist set <channel> <mask> [flag] [value]" if not defined $channel or not defined $mask;
if (not exists $self->{whitelist}->hash->{$channel}) { if (not exists $self->{whitelist}->hash->{$channel}) {
@ -195,7 +195,7 @@ sub whitelist {
return "Flag set."; return "Flag set.";
} }
when ("unset") { when ("unset") {
my ($channel, $mask, $flag) = split / /, $args, 3; my ($channel, $mask, $flag) = split /\s+/, $args, 3;
return "Usage: whitelist unset <channel> <mask> <flag>" if not defined $channel or not defined $mask or not defined $flag; return "Usage: whitelist unset <channel> <mask> <flag>" if not defined $channel or not defined $mask or not defined $flag;
if (not exists $self->{whitelist}->hash->{$channel}) { if (not exists $self->{whitelist}->hash->{$channel}) {
@ -215,7 +215,7 @@ sub whitelist {
return "Flag unset."; return "Flag unset.";
} }
when ("add") { when ("add") {
my ($channel, $mask, $mode) = split / /, $args, 3; my ($channel, $mask, $mode) = split /\s+/, $args, 3;
return "Usage: whitelist add <channel> <mask> [mode (user or ban, default: user)]" if not defined $channel or not defined $mask; return "Usage: whitelist add <channel> <mask> [mode (user or ban, default: user)]" if not defined $channel or not defined $mask;
$mode = 'user' if not defined $mode; $mode = 'user' if not defined $mode;
@ -232,7 +232,7 @@ sub whitelist {
return "/say $mask whitelisted in channel $channel"; return "/say $mask whitelisted in channel $channel";
} }
when ("remove") { when ("remove") {
my ($channel, $mask) = split / /, $args, 2; my ($channel, $mask) = split /\s+/, $args, 2;
return "Usage: whitelist remove <channel> <mask>" if not defined $channel or not defined $mask; return "Usage: whitelist remove <channel> <mask>" if not defined $channel or not defined $mask;
if(not defined $self->{whitelist}->hash->{$channel}) { if(not defined $self->{whitelist}->hash->{$channel}) {

View File

@ -173,7 +173,7 @@ sub blacklist {
my ($self, $from, $nick, $user, $host, $arguments) = @_; my ($self, $from, $nick, $user, $host, $arguments) = @_;
$arguments = lc $arguments; $arguments = lc $arguments;
my ($command, $args) = split / /, $arguments, 2; my ($command, $args) = split /\s+/, $arguments, 2;
return "Usage: blacklist <command>, where commands are: list/show, add, remove" if not defined $command; return "Usage: blacklist <command>, where commands are: list/show, add, remove" if not defined $command;
@ -196,7 +196,7 @@ sub blacklist {
return $text; return $text;
} }
when("add") { when("add") {
my ($mask, $channel) = split / /, $args, 2; my ($mask, $channel) = split /\s+/, $args, 2;
return "Usage: blacklist add <hostmask regex> [channel]" if not defined $mask; return "Usage: blacklist add <hostmask regex> [channel]" if not defined $mask;
$channel = '.*' if not defined $channel; $channel = '.*' if not defined $channel;
@ -206,7 +206,7 @@ sub blacklist {
return "/say $mask blacklisted in channel $channel"; return "/say $mask blacklisted in channel $channel";
} }
when("remove") { when("remove") {
my ($mask, $channel) = split / /, $args, 2; my ($mask, $channel) = split /\s+/, $args, 2;
return "Usage: blacklist remove <hostmask regex> [channel]" if not defined $mask; return "Usage: blacklist remove <hostmask regex> [channel]" if not defined $mask;
$channel = '.*' if not defined $channel; $channel = '.*' if not defined $channel;

View File

@ -86,7 +86,7 @@ sub adminadd {
my $self = shift; my $self = shift;
my ($from, $nick, $user, $host, $arguments) = @_; my ($from, $nick, $user, $host, $arguments) = @_;
my ($name, $channel, $hostmask, $level, $password) = split / /, $arguments, 5; my ($name, $channel, $hostmask, $level, $password) = split /\s+/, $arguments, 5;
if(not defined $name or not defined $channel or not defined $hostmask or not defined $level if(not defined $name or not defined $channel or not defined $hostmask or not defined $level
or not defined $password) { or not defined $password) {
@ -103,7 +103,7 @@ sub adminrem {
my $self = shift; my $self = shift;
my ($from, $nick, $user, $host, $arguments) = @_; my ($from, $nick, $user, $host, $arguments) = @_;
my ($channel, $hostmask) = split / /, $arguments, 2; my ($channel, $hostmask) = split /\s+/, $arguments, 2;
if(not defined $channel or not defined $hostmask) { if(not defined $channel or not defined $hostmask) {
return "/msg $nick Usage: adminrem <channel> <hostmask/name>"; return "/msg $nick Usage: adminrem <channel> <hostmask/name>";
@ -135,7 +135,7 @@ sub adminrem {
sub adminset { sub adminset {
my $self = shift; my $self = shift;
my ($from, $nick, $user, $host, $arguments) = @_; my ($from, $nick, $user, $host, $arguments) = @_;
my ($channel, $hostmask, $key, $value) = split / /, $arguments, 4 if defined $arguments; my ($channel, $hostmask, $key, $value) = split /\s+/, $arguments, 4 if defined $arguments;
if(not defined $channel or not defined $hostmask) { if(not defined $channel or not defined $hostmask) {
return "Usage: adminset <channel> <hostmask/name> [key] [value]"; return "Usage: adminset <channel> <hostmask/name> [key] [value]";
@ -163,7 +163,7 @@ sub adminset {
sub adminunset { sub adminunset {
my $self = shift; my $self = shift;
my ($from, $nick, $user, $host, $arguments) = @_; my ($from, $nick, $user, $host, $arguments) = @_;
my ($channel, $hostmask, $key) = split / /, $arguments, 3 if defined $arguments; my ($channel, $hostmask, $key) = split /\s+/, $arguments, 3 if defined $arguments;
if(not defined $channel or not defined $hostmask) { if(not defined $channel or not defined $hostmask) {
return "Usage: adminunset <channel> <hostmask/name> <key>"; return "Usage: adminunset <channel> <hostmask/name> <key>";

View File

@ -102,7 +102,7 @@ sub unban_user {
return ""; return "";
} }
my ($target, $channel) = split / /, $arguments; my ($target, $channel) = split /\s+/, $arguments;
if(not defined $target) { if(not defined $target) {
return "/msg $nick Usage: unban <mask> [channel]"; return "/msg $nick Usage: unban <mask> [channel]";
@ -177,7 +177,7 @@ sub unmute_user {
return ""; return "";
} }
my ($target, $channel) = split / /, $arguments; my ($target, $channel) = split /\s+/, $arguments;
if(not defined $target) { if(not defined $target) {
return "/msg $nick Usage: unmute <mask> [channel]"; return "/msg $nick Usage: unmute <mask> [channel]";

View File

@ -44,7 +44,7 @@ sub initialize {
sub set { sub set {
my ($self, $from, $nick, $user, $host, $arguments) = @_; my ($self, $from, $nick, $user, $host, $arguments) = @_;
my ($channel, $key, $value) = split / /, $arguments, 3; my ($channel, $key, $value) = split /\s+/, $arguments, 3;
if(not defined $channel) { if(not defined $channel) {
return "Usage: chanset <channel> [key [value]]"; return "Usage: chanset <channel> [key [value]]";
@ -55,7 +55,7 @@ sub set {
sub unset { sub unset {
my ($self, $from, $nick, $user, $host, $arguments) = @_; my ($self, $from, $nick, $user, $host, $arguments) = @_;
my ($channel, $key) = split / /, $arguments; my ($channel, $key) = split /\s+/, $arguments;
if(not defined $channel or not defined $key) { if(not defined $channel or not defined $key) {
return "Usage: chanunset <channel> <key>"; return "Usage: chanunset <channel> <key>";

View File

@ -96,7 +96,7 @@ sub initialize {
sub call_factoid { sub call_factoid {
my $self = shift; my $self = shift;
my ($from, $nick, $user, $host, $arguments) = @_; my ($from, $nick, $user, $host, $arguments) = @_;
my ($chan, $keyword, $args) = split / /, $arguments, 3; my ($chan, $keyword, $args) = split /\s+/, $arguments, 3;
if(not defined $chan or not defined $keyword) { if(not defined $chan or not defined $keyword) {
return "Usage: fact <channel> <keyword> [arguments]"; return "Usage: fact <channel> <keyword> [arguments]";
@ -157,7 +157,7 @@ sub log_factoid {
sub find_factoid_with_optional_channel { sub find_factoid_with_optional_channel {
my ($self, $from, $arguments, $command, $usage, $explicit) = @_; my ($self, $from, $arguments, $command, $usage, $explicit) = @_;
my ($from_chan, $from_trigger, $remaining_args) = split / /, $arguments, 3; my ($from_chan, $from_trigger, $remaining_args) = split /\s+/, $arguments, 3;
if (not defined $from_chan or (not defined $from_chan and not defined $from_trigger)) { if (not defined $from_chan or (not defined $from_chan and not defined $from_trigger)) {
return "Usage: $command [channel] <keyword>" if not $usage; return "Usage: $command [channel] <keyword>" if not $usage;
@ -333,7 +333,7 @@ sub factset {
my ($channel, $trigger, $arguments) = $self->find_factoid_with_optional_channel($from, $args, 'factset', 'Usage: factset [channel] <factoid> [key [value]]', 1); my ($channel, $trigger, $arguments) = $self->find_factoid_with_optional_channel($from, $args, 'factset', 'Usage: factset [channel] <factoid> [key [value]]', 1);
return $channel if not defined $trigger; # if $trigger is not defined, $channel is an error message return $channel if not defined $trigger; # if $trigger is not defined, $channel is an error message
my ($key, $value) = split / /, $arguments, 2; my ($key, $value) = split /\s+/, $arguments, 2;
$channel = '.*' if $channel !~ /^#/; $channel = '.*' if $channel !~ /^#/;
@ -541,7 +541,7 @@ sub list {
sub factmove { sub factmove {
my $self = shift; my $self = shift;
my ($from, $nick, $user, $host, $arguments) = @_; my ($from, $nick, $user, $host, $arguments) = @_;
my ($src_channel, $source, $target_channel, $target) = split / /, $arguments, 4 if $arguments; my ($src_channel, $source, $target_channel, $target) = split /\s+/, $arguments, 4 if $arguments;
my $usage = "Usage: factmove <source channel> <source factoid> <target channel/factoid> [target factoid]"; my $usage = "Usage: factmove <source channel> <source factoid> <target channel/factoid> [target factoid]";
@ -612,7 +612,7 @@ sub factmove {
sub factalias { sub factalias {
my $self = shift; my $self = shift;
my ($from, $nick, $user, $host, $arguments) = @_; my ($from, $nick, $user, $host, $arguments) = @_;
my ($chan, $alias, $command) = split / /, $arguments, 3 if defined $arguments; my ($chan, $alias, $command) = split /\s+/, $arguments, 3 if defined $arguments;
if(not defined $command) { if(not defined $command) {
return "Usage: factalias <channel> <keyword> <command>"; return "Usage: factalias <channel> <keyword> <command>";
@ -717,7 +717,7 @@ sub factrem {
my ($from, $nick, $user, $host, $arguments) = @_; my ($from, $nick, $user, $host, $arguments) = @_;
my $factoids = $self->{pbot}->{factoids}->{factoids}->hash; my $factoids = $self->{pbot}->{factoids}->{factoids}->hash;
my ($from_chan, $from_trig) = split / /, $arguments; my ($from_chan, $from_trig) = split /\s+/, $arguments;
if (not defined $from_trig) { if (not defined $from_trig) {
$from_trig = $from_chan; $from_trig = $from_chan;
@ -790,7 +790,7 @@ sub factshow {
my ($from, $nick, $user, $host, $arguments) = @_; my ($from, $nick, $user, $host, $arguments) = @_;
my $factoids = $self->{pbot}->{factoids}->{factoids}->hash; my $factoids = $self->{pbot}->{factoids}->{factoids}->hash;
my ($chan, $trig) = split / /, $arguments; my ($chan, $trig) = split /\s+/, $arguments;
if (not defined $trig) { if (not defined $trig) {
$trig = $chan; $trig = $chan;
@ -852,7 +852,7 @@ sub factlog {
my @entries; my @entries;
while (my $line = <$fh>) { while (my $line = <$fh>) {
my ($timestamp, $hostmask, $msg) = split / /, $line, 3; my ($timestamp, $hostmask, $msg) = split /\s+/, $line, 3;
if (not $show_hostmask) { if (not $show_hostmask) {
$hostmask =~ s/!.*$//; $hostmask =~ s/!.*$//;
@ -877,7 +877,7 @@ sub factinfo {
my ($from, $nick, $user, $host, $arguments) = @_; my ($from, $nick, $user, $host, $arguments) = @_;
my $factoids = $self->{pbot}->{factoids}->{factoids}->hash; my $factoids = $self->{pbot}->{factoids}->{factoids}->hash;
my ($chan, $trig) = split / /, $arguments; my ($chan, $trig) = split /\s+/, $arguments;
if (not defined $trig) { if (not defined $trig) {
$trig = $chan; $trig = $chan;
@ -920,7 +920,7 @@ sub top20 {
my $text = ""; my $text = "";
my $i = 0; my $i = 0;
my ($channel, $args) = split / /, $arguments, 2 if defined $arguments; my ($channel, $args) = split /\s+/, $arguments, 2 if defined $arguments;
if(not defined $channel) { if(not defined $channel) {
return "Usage: top20 <channel> [nick or 'recent']"; return "Usage: top20 <channel> [nick or 'recent']";

View File

@ -195,7 +195,7 @@ sub execute_module {
sub module_pipe_reader { sub module_pipe_reader {
my ($self, $buf) = @_; my ($self, $buf) = @_;
my ($channel, $text) = split / /, $buf, 2; my ($channel, $text) = split /\s+/, $buf, 2;
return if not defined $text or not length $text; return if not defined $text or not length $text;
$text = $self->{pbot}->{interpreter}->truncate_result($channel, $self->{pbot}->{registry}->get_value('irc', 'botnick'), 'undef', $text, $text, 0); $text = $self->{pbot}->{interpreter}->truncate_result($channel, $self->{pbot}->{registry}->get_value('irc', 'botnick'), 'undef', $text, $text, 0);
$self->{pbot}->{antiflood}->check_flood($channel, $self->{pbot}->{registry}->get_value('irc', 'botnick'), $self->{pbot}->{registry}->get_value('irc', 'username'), 'localhost', $text, 0, 0, 0); $self->{pbot}->{antiflood}->check_flood($channel, $self->{pbot}->{registry}->get_value('irc', 'botnick'), $self->{pbot}->{registry}->get_value('irc', 'username'), 'localhost', $text, 0, 0, 0);

View File

@ -304,7 +304,7 @@ sub find_factoid {
} else { } else {
$command = $1; $command = $1;
} }
($keyword, $arguments) = split / /, $command, 2; ($keyword, $arguments) = split /\s+/, $command, 2;
goto NEXT_DEPTH; goto NEXT_DEPTH;
} }
@ -332,7 +332,7 @@ sub find_factoid {
if($find_alias) { if($find_alias) {
my $command = $self->{factoids}->hash->{$channel}->{$trigger}->{action}; my $command = $self->{factoids}->hash->{$channel}->{$trigger}->{action};
($keyword, $arguments) = split / /, $command, 2; ($keyword, $arguments) = split /\s+/, $command, 2;
$string = $keyword . (length $arguments ? " $arguments" : ""); $string = $keyword . (length $arguments ? " $arguments" : "");
goto NEXT_DEPTH; goto NEXT_DEPTH;
} }
@ -415,7 +415,7 @@ sub expand_factoid_vars {
if ($self->{factoids}->hash->{$var_chan}->{$var}->{type} eq 'text') { if ($self->{factoids}->hash->{$var_chan}->{$var}->{type} eq 'text') {
my $change = $self->{factoids}->hash->{$var_chan}->{$var}->{action}; my $change = $self->{factoids}->hash->{$var_chan}->{$var}->{action};
my @list = split(/\s|(".*?")/, $change); my @list = split(/\s+|(".*?")/, $change);
my @mylist; my @mylist;
for (my $i = 0; $i <= $#list; $i++) { for (my $i = 0; $i <= $#list; $i++) {
push @mylist, $list[$i] if defined $list[$i]; push @mylist, $list[$i] if defined $list[$i];

View File

@ -417,7 +417,7 @@ sub on_cap {
if ($event->{event}->{args}->[0] eq 'ACK') { if ($event->{event}->{args}->[0] eq 'ACK') {
$self->{pbot}->{logger}->log("Client capabilities granted: " . $event->{event}->{args}->[1] . "\n"); $self->{pbot}->{logger}->log("Client capabilities granted: " . $event->{event}->{args}->[1] . "\n");
my @caps = split / /, $event->{event}->{args}->[1]; my @caps = split /\s+/, $event->{event}->{args}->[1];
foreach my $cap (@caps) { foreach my $cap (@caps) {
$self->{pbot}->{capabilities}->{$cap} = 1; $self->{pbot}->{capabilities}->{$cap} = 1;
} }

View File

@ -277,7 +277,7 @@ sub handle_result {
my $use_output_queue = 0; my $use_output_queue = 0;
if (defined $command) { if (defined $command) {
my ($cmd, $args) = split / /, $command, 2; my ($cmd, $args) = split /\s+/, $command, 2;
if (not $self->{pbot}->{commands}->exists($cmd)) { if (not $self->{pbot}->{commands}->exists($cmd)) {
my ($chan, $trigger) = $self->{pbot}->{factoids}->find_factoid($from, $cmd, $args, 1, 0, 1); my ($chan, $trigger) = $self->{pbot}->{factoids}->find_factoid($from, $cmd, $args, 1, 0, 1);
if(defined $trigger) { if(defined $trigger) {
@ -376,7 +376,7 @@ sub output_result {
} }
} elsif($line =~ s/^\/$self->{pbot}->{secretstuff}kick\s+//) { } elsif($line =~ s/^\/$self->{pbot}->{secretstuff}kick\s+//) {
$pbot->{antiflood}->check_flood($from, $botnick, $pbot->{registry}->get_value('irc', 'username'), 'localhost', '/kick ' . $line, 0, 0, 0) if $checkflood; $pbot->{antiflood}->check_flood($from, $botnick, $pbot->{registry}->get_value('irc', 'username'), 'localhost', '/kick ' . $line, 0, 0, 0) if $checkflood;
my ($victim, $reason) = split / /, $line, 2; my ($victim, $reason) = split /\s+/, $line, 2;
if (not defined $reason) { if (not defined $reason) {
if (open my $fh, '<', $self->{pbot}->{registry}->get_value('general', 'module_dir') . '/insults.txt') { if (open my $fh, '<', $self->{pbot}->{registry}->get_value('general', 'module_dir') . '/insults.txt') {

View File

@ -43,7 +43,7 @@ sub initialize {
sub regset { sub regset {
my $self = shift; my $self = shift;
my ($from, $nick, $user, $host, $arguments) = @_; my ($from, $nick, $user, $host, $arguments) = @_;
my ($section, $item, $key, $value) = split / /, $arguments, 4 if defined $arguments; my ($section, $item, $key, $value) = split /\s+/, $arguments, 4 if defined $arguments;
if(not defined $section or not defined $item) { if(not defined $section or not defined $item) {
return "Usage: regset <section> <item> [key [value]]"; return "Usage: regset <section> <item> [key [value]]";
@ -58,7 +58,7 @@ sub regset {
sub regunset { sub regunset {
my $self = shift; my $self = shift;
my ($from, $nick, $user, $host, $arguments) = @_; my ($from, $nick, $user, $host, $arguments) = @_;
my ($section, $item, $key) = split / /, $arguments, 3 if defined $arguments; my ($section, $item, $key) = split /\s+/, $arguments, 3 if defined $arguments;
if(not defined $section or not defined $item or not defined $key) { if(not defined $section or not defined $item or not defined $key) {
return "Usage: regunset <section> <item> <key>" return "Usage: regunset <section> <item> <key>"
@ -70,7 +70,7 @@ sub regunset {
sub regadd { sub regadd {
my $self = shift; my $self = shift;
my ($from, $nick, $user, $host, $arguments) = @_; my ($from, $nick, $user, $host, $arguments) = @_;
my ($section, $item, $value) = split / /, $arguments, 3 if defined $arguments; my ($section, $item, $value) = split /\s+/, $arguments, 3 if defined $arguments;
if(not defined $section or not defined $item or not defined $value) { if(not defined $section or not defined $item or not defined $value) {
return "Usage: regadd <section> <item> <value>"; return "Usage: regadd <section> <item> <value>";
@ -85,7 +85,7 @@ sub regadd {
sub regrem { sub regrem {
my $self = shift; my $self = shift;
my ($from, $nick, $user, $host, $arguments) = @_; my ($from, $nick, $user, $host, $arguments) = @_;
my ($section, $item) = split / /, $arguments if defined $arguments; my ($section, $item) = split /\s+/, $arguments if defined $arguments;
if(not defined $section or not defined $item) { if(not defined $section or not defined $item) {
return "Usage: regrem <section> <item>"; return "Usage: regrem <section> <item>";
@ -109,7 +109,7 @@ sub regshow {
my ($from, $nick, $user, $host, $arguments) = @_; my ($from, $nick, $user, $host, $arguments) = @_;
my $registry = $self->{pbot}->{registry}->{registry}->hash; my $registry = $self->{pbot}->{registry}->{registry}->hash;
my ($section, $item) = split / /, $arguments if defined $arguments; my ($section, $item) = split /\s+/, $arguments if defined $arguments;
if(not defined $section or not defined $item) { if(not defined $section or not defined $item) {
return "Usage: regshow <section> <item>"; return "Usage: regshow <section> <item>";