- W3Search regex now doesn't catch "smile for me" for example.
- allow +o users to have no restrictions on factoid searching.
- updated comments for user flags.
- join: check validity of channel name.
- karma: update if statement and comment.
- core: if channel contains regex, *boom*. fixed.
- rename factoids: logic fixed.
- irc: prevent perl warnings in flood check code.
- norm: cosmetic clean up.
- added config check ("logColors") to retain control characters in log files.
- forgot to commit a fix for learn == HUNGRY.
git-svn-id: https://svn.code.sf.net/p/infobot/code/trunk/blootbot@774
c11ca15a-4712-0410-83d8-
924469b57eb5
use vars qw($total $x $type $i $good);
$babel_lang_regex = "fr|sp|es|po|pt|it|ge|de|gr|en|zh|ja|jp|ko|kr|ru";
+$w3search_regex = "google";
### COMMAND HOOK IMPLEMENTATION.
# addCmdHook("SECTION", 'TEXT_HOOK',
}
# google searching. Simon++
- if ($message =~ /^(?:search\s+)?(\S+)\s+for\s+['"]?(.*?)["']?\s*\?*$/i) {
+ if ($message =~ /^(?:search\s+)?($w3search_regex)\s+for\s+['"]?(.*?)["']?\s*\?*$/i) {
return unless (&hasParam("wwwsearch"));
&Forker("wwwsearch", sub { &W3Search::W3Search($1,$2); } );
$args =~ s/^["']|["']$//g;
}
- if (length $args == 1) {
- &msg($who,"search string is too short.");
+ if (length $args < 2 && &IsFlag("o") ne "o") {
+ &msg($who, "search string is too short.");
return;
}
my $faqtoid = $message;
if ($faqtoid eq "") {
- &help("undelete");
+ &help("unforget");
return;
}
}
if ($message =~ /^'(.*)'\s+'(.*)'$/) {
- my($from,$to) = (lc $1, lc $2);
+ my ($from,$to) = (lc $1, lc $2);
my $result = &getFactoid($from);
if (defined $result) {
- my $author = &getFactInfo($from, "created_by");
-
- if (0 and !&IsFlag("m") or $author !~ /^\Q$who\E\!/i) {
- &msg($who, "It's not yours to modify.");
- return;
- }
+ &performReply("i didn't have anything called '$from'");
+ return;
+ }
- if ($_ = &getFactoid($to)) {
- &performReply("destination factoid already exists.");
- return;
- }
+ my $author = &getFactInfo($from, "created_by");
- &setFactInfo($from,"factoid_key",$to);
+ # who == nick!user@host.
+ if (&IsFlag("m") ne "m" and $author !~ /^\Q$who\E\!/i) {
+ &msg($who, "factoid '$form' is not yours to modify.");
+ return;
+ }
- &status("rename: <$who> '$from' is now '$to'");
- &performReply("i renamed '$from' to '$to'");
- } else {
- &performReply("i didn't have anything called '$from'");
+ if ($_ = &getFactoid($to)) {
+ &performReply("destination factoid already exists.");
+ return;
}
+
+ &setFactInfo($from,"factoid_key",$to);
+
+ &status("rename: <$who> '$from' is now '$to'");
+ &performReply("i renamed '$from' to '$to'");
} else {
&msg($who,"error: wrong format. ask me about 'help rename'.");
}
my $time;
foreach (keys %{ $floodjoin{$c} }) {
- $time += $floodjoin{$c}{$_}{Time};
+ my $t = $floodjoin{$c}{$_}{Time};
+ next unless (defined $t);
+
+ $time += $t;
}
&DEBUG("joinflood: time => $time");
$time /= $count;
return 'addressedother set' if ($addressedother);
$talkok = ($param{'addressing'} =~ /^OPTIONAL$/i or $addressed);
- $learnok = ($param{'learn'} =~ /^HUNGRY$/i or $addressed);
+ $learnok = 1 if ($addressed);
+ if ($param{'learn'} =~ /^HUNGRY$/i) {
+ $learnok = 1;
+ $addressed = 1;
+ $talkok = 1;
+ }
&shmFlush(); # hack.
return;
}
+ if ($thischan !~ /^$mask{chan}$/) {
+ &msg($who, "$thischan is not a valid channel name.");
+ return;
+ }
+
if (&IsFlag("o") ne "o") {
if (!exists $chanconf{$thischan}) {
&msg($who, "I am not allowed to join $thischan.");
}
if (&validChan($thischan)) {
- &msg($who,"warn: I'm already on $thischan, joining anyway...");
-# return;
+ &msg($who,"warn: I'm already on $thischan, joining anyway...");
}
}
$cache{join}{$thischan} = $who; # used for on_join self.
###
# karma. set...
- if ($message =~ /^(\S+)(--|\+\+)\s*$/ and $addressed) {
- return '' unless (&hasParam("karma"));
- # well... since it is policy to do bot functions before factoids
- # karma gets hit if, for example, "g++" is issued.
- # only way to request it is to put a question mark at the end.
-
- my($term,$inc) = (lc $1,$2);
-
- if ($msgType !~ /public/i) {
- &msg($who, "karma must be done in public!");
- return;
- }
+ if ($message =~ /^(\S+)(--|\+\+)\s*$/ && $addressed &&
+ &hasParam("karma") && $msgType =~ /public/i
+ ) {
+ # to request factoids such as "g++" or "libstdc++", append "?" to the query.
+ my ($term,$inc) = (lc $1,$2);
if (lc $term eq lc $who) {
&msg($who, "please don't karma yourself");
$c ||= $chan;
$c ||= "_default";
$c = "_default" if ($c eq "*"); # fix!
- my @c = grep /^$c$/i, keys %chanconf;
+ my @c = grep /^\Q$c\E$/i, keys %chanconf;
if (@c) {
if (0 and $c[0] ne $c) {
# remove control characters from logging to LOGFILE.
for ($input) {
+ last if (&IsParam("logColors"));
s/\e\[[0-9;]+m//g; # escape codes.
s/[\cA-\c_]//g; # control chars.
}