if ($message =~ /^tellme(\s+(.*))?$/i) {
my $args = $2;
if ($args =~ /^\s*$/) {
- &help("tellme");
+ &help('tellme');
return;
}
# 4op.
if ($message =~ /^4op(\s+($mask{chan}))?$/i) {
- return unless (&hasFlag("o"));
+ return unless (&hasFlag('o'));
my $chan = $2;
- if ($chan eq "") {
- &help("4op");
+ if ($chan eq '') {
+ &help('4op');
return;
}
# opme.
if ($message =~ /^opme(\s+($mask{chan}))?$/i) {
- return unless (&hasFlag("o"));
- return unless (&hasFlag("A"));
+ return unless (&hasFlag('o'));
+ return unless (&hasFlag('A'));
my $chan = $2;
- if ($chan eq "") {
- &help("4op");
+ if ($chan eq '') {
+ &help('4op');
return;
}
# backlog.
if ($message =~ /^backlog(\s+(.*))?$/i) {
- return unless (&hasFlag("o"));
- return unless (&IsParam("backlog"));
+ return unless (&hasFlag('o'));
+ return unless (&IsParam('backlog'));
my $num = $2;
my $max = $param{'backlog'};
if (!defined $num) {
- &help("backlog");
+ &help('backlog');
return;
} elsif ($num !~ /^\d+/) {
&msg($who, "error: argument is not positive integer.");
# dump variables.
if ($message =~ /^dumpvars$/i) {
- return unless (&hasFlag("o"));
- return unless (&IsParam("DumpVars"));
+ return unless (&hasFlag('o'));
+ return unless (&IsParam('DumpVars'));
&status("Dumping all variables...");
&dumpallvars();
# kick.
if ($message =~ /^kick(\s+(.*?))$/) {
- return unless (&hasFlag("o"));
+ return unless (&hasFlag('o'));
my $arg = $2;
- if ($arg eq "") {
- &help("kick");
+ if ($arg eq '') {
+ &help('kick');
return;
}
my @args = split(/\s+/, $arg);
# mode.
if ($message =~ /^mode(\s+(.*))?$/) {
- return unless (&hasFlag("n"));
+ return unless (&hasFlag('n'));
my ($chan,$mode) = split /\s+/,$2,2;
- if ($chan eq "") {
- &help("mode");
+ if ($chan eq '') {
+ &help('mode');
return;
}
# part.
if ($message =~ /^part(\s+(\S+))?$/i) {
- return unless (&hasFlag("o"));
+ return unless (&hasFlag('o'));
my $jchan = $2;
if ($jchan !~ /^$mask{chan}$/) {
&msg($who, "error, invalid chan.");
- &help("part");
+ &help('part');
return;
}
# lobotomy. sometimes we want the bot to be _QUIET_.
if ($message =~ /^(lobotomy|bequiet)$/i) {
- return unless (&hasFlag("o"));
+ return unless (&hasFlag('o'));
if ($lobotomized) {
&performReply("i'm already lobotomized");
} else {
- &performReply("i have been lobotomized");
+ &performReply('i have been lobotomized');
$lobotomized = 1;
}
# unlobotomy.
if ($message =~ /^(unlobotomy|benoisy)$/i) {
- return unless (&hasFlag("o"));
+ return unless (&hasFlag('o'));
if ($lobotomized) {
- &performReply("i have been unlobotomized, woohoo");
+ &performReply('i have been unlobotomized, woohoo');
$lobotomized = 0;
delete $cache{lobotomy};
# undef $cache{lobotomy}; # ??
# op.
if ($message =~ /^op(\s+(.*))?$/i) {
- return unless (&hasFlag("o"));
+ return unless (&hasFlag('o'));
my ($opee) = lc $2;
my @chans;
# deop.
if ($message =~ /^deop(\s+(.*))?$/i) {
- return unless (&hasFlag("o"));
+ return unless (&hasFlag('o'));
my ($opee) = lc $2;
my @chans;
# say.
if ($message =~ s/^say\s+(\S+)\s+(.*)//) {
- return unless (&hasFlag("o"));
+ return unless (&hasFlag('o'));
my ($chan,$msg) = (lc $1, $2);
&DEBUG("chan => '$1', msg => '$msg'.");
- # TODO: add nick destination.
- if (&validChan($chan)) {
- &msg($chan, $msg);
- } else {
- &msg($who,"i'm not on \002$chan\002, sorry.");
- }
+ &msg($chan, $msg);
return;
}
# do.
if ($message =~ s/^do\s+(\S+)\s+(.*)//) {
- return unless (&hasFlag("o"));
+ return unless (&hasFlag('o'));
my ($chan,$msg) = (lc $1, $2);
&DEBUG("chan => '$1', msg => '$msg'.");
- # TODO: add nick destination.
- if (&validChan($chan)) {
- &action($chan, $msg);
- } else {
- &msg($who,"i'm not on \002$chan\002, sorry.");
- }
+ &action($chan, $msg);
return;
}
# die.
if ($message =~ /^die$/) {
- return unless (&hasFlag("n"));
+ return unless (&hasFlag('n'));
&doExit();
# global factoid substitution.
if ($message =~ m|^\* =~ s([/,#])(.+?)\1(.*?)\1;?\s*$|) {
my ($delim,$op,$np) = ($1, $2, $3);
- return unless (&hasFlag("n"));
+ return unless (&hasFlag('n'));
### TODO: support flags to do full-on global.
# incorrect format.
### TODO: fix up $op to support mysql/sqlite/pgsql
### TODO: => add db/sql specific function to fix this.
- my @list = &searchTable("factoids", "factoid_key",
- "factoid_value", $op);
+ my @list = &searchTable('factoids', 'factoid_key',
+ 'factoid_value', $op);
if (!scalar @list) {
&performReply("Expression didn't match anything.");
}
&status("gsubst: going to alter ".scalar(@list)." factoids.");
- &performReply("going to alter ".scalar(@list)." factoids.");
+ &performReply('going to alter '.scalar(@list)." factoids.");
my $error = 0;
foreach (@list) {
&performReply("that's too long (or was long)");
return;
}
- &setFactInfo($faqtoid, "factoid_value", $result);
+ &setFactInfo($faqtoid, 'factoid_value', $result);
&status("update: '$faqtoid' =is=> '$result'; was '$was'");
} else {
&WARN("subst: that's weird... thought we found the string ($op) in '$faqtoid'.");
}
&performReply("Ok... did s/$op/$np/ for ".
- (scalar(@list) - $error)." factoids");
+ (scalar(@list) - $error).' factoids');
return;
}
# jump.
if ($message =~ /^jump(\s+(\S+))?$/i) {
- return unless (&hasFlag("n"));
+ return unless (&hasFlag('n'));
- if ($2 eq "") {
- &help("jump");
+ if ($2 eq '') {
+ &help('jump');
return;
}
# reload.
if ($message =~ /^reload$/i) {
- return unless (&hasFlag("n"));
+ return unless (&hasFlag('n'));
&status("USER reload $who");
&performStrictReply("reloading...");
# reset.
if ($message =~ /^reset$/i) {
- return unless (&hasFlag("n"));
+ return unless (&hasFlag('n'));
&msg($who,"resetting...");
my @done;
push(@done, $_);
sleep 1;
}
- &DEBUG("before clearircvars");
+ &DEBUG('before clearircvars');
&clearIRCVars();
- &DEBUG("before joinnextchan");
+ &DEBUG('before joinnextchan');
&joinNextChan();
- &DEBUG("after joinnextchan");
+ &DEBUG('after joinnextchan');
&status("USER reset $who");
- &msg($who,"reset complete");
+ &msg($who,'reset complete');
return;
}
# rehash.
if ($message =~ /^rehash$/) {
- return unless (&hasFlag("n"));
+ return unless (&hasFlag('n'));
&msg($who,"rehashing...");
- &restart("REHASH");
+ &restart('REHASH');
&status("USER rehash $who");
- &msg($who,"rehashed");
+ &msg($who,'rehashed');
return;
}
my @args = split /[\s\t]+/, $2; # hrm.
if (scalar @args != 1) {
- &help("chaninfo");
+ &help('chaninfo');
return;
}
}
if (!scalar @chans) {
- push(@chans, "_default");
+ push(@chans, '_default');
$no_chan = 1;
}
my($what,$val) = split /[\s\t]+/, $args, 2;
### TODO: "cannot set values without +m".
- return unless (&hasFlag("n"));
+ return unless (&hasFlag('n'));
# READ ONLY.
if (defined $what and $what !~ /^[-+]/ and !defined $val and $no_chan) {
}
### TODO: move to UserDCC again.
- if ($cmd eq "chanset" and !defined $what) {
+ if ($cmd eq 'chanset' and !defined $what) {
&DEBUG("showing channel conf.");
foreach $chan (@chans) {
if ($chan eq '_default') {
- &performStrictReply("Default channel settings");
+ &performStrictReply('Default channel settings');
} else {
&performStrictReply("chan: $chan (see _default also)");
}
my @items;
- my $str = "";
+ my $str = '';
foreach (sort keys %{ $chanconf{$chan} }) {
my $newstr = join(', ', @items);
### TODO: make length use channel line limit?
}
if ($message =~ /^(chanunset|\-chan)(\s+(.*))?$/) {
- return unless (&hasFlag("n"));
+ return unless (&hasFlag('n'));
my $args = $3;
my $no_chan = 0;
if (!defined $args) {
- &help("chanunset");
+ &help('chanunset');
return;
}
$delete = ($1) ? 1 : 0;
} else {
&VERB("no chan arg; setting to default.",2);
- $chan = "_default";
+ $chan = '_default';
$no_chan = 1;
}
return;
}
- if ($args ne "") {
+ if ($args ne '') {
if (!&getChanConf($args,$chan)) {
&performStrictReply("$args does not exist for $chan");
my @chans = &ChanConfList($args);
&DEBUG("scalar chans => ".scalar(@chans) );
- if (scalar @chans == 1 and $chans[0] eq "_default" and !$no_chan) {
+ if (scalar @chans == 1 and $chans[0] eq '_default' and !$no_chan) {
&performStrictReply("ok, $args was set only for _default; unsetting for _defaul but setting for other chans.");
my $val = $chanconf{$_}{_default};
my(@args) = split /[\s\t]+/, $2 || '';
if (scalar @args != 1) {
- &help("newpass");
+ &help('newpass');
return;
}
my(@args) = split /[\s\t]+/, $2 || '';
if (!scalar @args) {
- &help("chpass");
+ &help('chpass');
return;
}
if (scalar @args == 1) {
# del pass.
- if (!&IsFlag("n") and $who !~ /^\Q$verifyUser\E$/i) {
+ if (!&IsFlag('n') and $who !~ /^\Q$verifyUser\E$/i) {
&performStrictReply("cannot remove passwd of others.");
return;
}
my(@args) = split /[\s\t]+/, $2 || '';
if (!scalar @args) {
- &help("chattr");
+ &help('chattr');
return;
}
&DEBUG("who => $who");
&DEBUG("verifyUser => $verifyUser");
- if (!&IsFlag("n") and $who !~ /^\Q$verifyUser\E$/i) {
+ if (!&IsFlag('n') and $who !~ /^\Q$verifyUser\E$/i) {
&performStrictReply("cannto change attributes of others.");
- return "REPLY";
+ return 'REPLY';
}
my $state;
next if ($flags =~ /\Q$_\E/);
$flags .= $_;
} else {
- if (&IsParam("owner")
+ if (&IsParam('owner')
and $param{owner} =~ /^\Q$user\E$/i
and $flags =~ /[nmo]/
) {
if ($message =~ /^chnick(\s+(.*))?$/) {
my(@args) = split /[\s\t]+/, $2 || '';
- if ($who eq "_default") {
+ if ($who eq '_default') {
&WARN("$who or verifyuser tried to run chnick.");
- return "REPLY";
+ return 'REPLY';
}
if (!scalar @args or scalar @args > 2) {
- &help("chnick");
+ &help('chnick');
return;
}
return;
}
- if (!&IsFlag("n") and $who !~ /^\Q$verifyUser\E$/i) {
+ if (!&IsFlag('n') and $who !~ /^\Q$verifyUser\E$/i) {
&performStrictReply("cannto change nick of others.");
- return "REPLY" if ($who eq "_default");
+ return 'REPLY' if ($who eq '_default');
return;
}
}
if ($message =~ /^([-+])host(\s+(.*))?$/) {
- my $cmd = $1."host";
+ my $cmd = $1.'host';
my(@args) = split /[\s\t]+/, $3 || '';
my $state = ($1 eq "+") ? 1 : 0;
return;
}
- if ($who eq "_default") {
+ if ($who eq '_default') {
&WARN("$who or verifyuser tried to run $cmd.");
- return "REPLY";
+ return 'REPLY';
}
my ($user,$mask);
if ($args[0] =~ /^$mask{nick}$/i) { # <nick>
- return unless (&hasFlag("n"));
+ return unless (&hasFlag('n'));
$user = &getUser($args[0]);
$mask = $args[1];
} else { # <mask>
}
if (!defined $mask) {
- &performStrictReply("Hostmasks for $user: " . join(" ", keys %{$users{$user}{HOSTS}}));
+ &performStrictReply("Hostmasks for $user: " . join(' ', keys %{$users{$user}{HOSTS}}));
return;
}
- if (!&IsFlag("n") and $who !~ /^\Q$verifyUser\E$/i) {
+ if (!&IsFlag('n') and $who !~ /^\Q$verifyUser\E$/i) {
&performStrictReply("cannto change masks of others.");
return;
}
}
if ($message =~ /^([-+])ban(\s+(.*))?$/) {
- my $cmd = $1."ban";
+ my $cmd = $1.'ban';
my $flatarg = $3;
my(@args) = split /[\s\t]+/, $3 || '';
my $state = ($1 eq "+") ? 1 : 0;
if ($flatarg =~ s/^($mask{chan})\s*//) {
$chan = $1;
} else {
- $chan = "*"; # _default instead?
+ $chan = '*'; # _default instead?
}
if ($state == 0) { # delete.
$reason = $1;
}
- if (!&IsFlag("n") and $who !~ /^\Q$verifyUser\E$/i) {
+ if (!&IsFlag('n') and $who !~ /^\Q$verifyUser\E$/i) {
&performStrictReply("cannto change masks of others.");
return;
}
my $arg = $2;
if (!defined $arg) {
- &help("whois");
+ &help('whois');
return;
}
foreach (keys %{ $users{$user} }) {
my $ref = ref $users{$user}{$_};
- if ($ref eq "HASH") {
+ if ($ref eq 'HASH') {
my $type = $_;
### DOES NOT WORK???
foreach (keys %{ $users{$user}{$type} }) {
my $arg = $2;
if (defined $arg) {
- if ($arg ne "_default" and !&validChan($arg) ) {
+ if ($arg ne '_default' and !&validChan($arg) ) {
&performStrictReply("error: chan $chan is invalid.");
return;
}
foreach (keys %{ $bans{$c} }) {
my $val = $bans{$c}{$_};
- if (ref $val eq "ARRAY") {
+ if (ref $val eq 'ARRAY') {
my @array = @{ $val };
&performStrictReply(" $_: @array");
} else {
}
if ($message =~ /^save$/) {
- return unless (&hasFlag("o"));
+ return unless (&hasFlag('o'));
&writeUserFile();
&writeChanFile();
- &performStrictReply("saved user and chan files");
+ &performStrictReply('saved user and chan files');
return;
}
# ignore.
if ($message =~ /^(\+|\-)ignore(\s+(.*))?$/i) {
- return unless (&hasFlag("o"));
+ return unless (&hasFlag('o'));
my $state = ($1 eq "+") ? 1 : 0;
- my $str = $1."ignore";
+ my $str = $1.'ignore';
my $args = $3;
if (!$args) {
if ($args =~ s/^($mask{chan}|\*)\s*//) {
$chan = $1;
} else {
- $chan = "*";
+ $chan = '*';
}
# time.
foreach (keys %{ $ignore{$c} }) {
my $ref = ref $ignore{$c}{$_};
- if ($ref eq "ARRAY") {
+ if ($ref eq 'ARRAY') {
my @array = @{ $ignore{$c}{$_} };
&performStrictReply(" $_: @array");
} else {
# adduser/deluser.
if ($message =~ /^(add|del)user(\s+(.*))?$/i) {
my $str = $1;
- my $strstr = $1."user";
+ my $strstr = $1.'user';
my @args = split /\s+/, $3 || '';
my $args = $3;
my $state = ($str =~ /^(add)$/) ? 1 : 0;
my @time;
foreach (sort { $a <=> $b } keys %time) {
- my $str = join(", ", sort keys %{ $time{$_} });
+ my $str = join(', ', sort keys %{ $time{$_} });
&DEBUG("time => $_, str => $str");
push(@time, "$str (".&Time2String($_).")");
}
}
# quite a cool hack: reply in DCC CHAT.
- $msgType = "chat" if (exists $dcc{'CHAT'}{$who});
+ $msgType = 'chat' if (exists $dcc{'CHAT'}{$who});
my $done = 0;
$done++ if &parseCmdHook($message);
return;
}
- return "REPLY";
+ return 'REPLY';
}
1;