]> git.donarmstrong.com Git - infobot.git/commitdiff
- nice patch from Phil Edwards <pme@devphil.com>. Thanks!
authordms <dms@c11ca15a-4712-0410-83d8-924469b57eb5>
Thu, 6 Mar 2003 19:21:36 +0000 (19:21 +0000)
committerdms <dms@c11ca15a-4712-0410-83d8-924469b57eb5>
Thu, 6 Mar 2003 19:21:36 +0000 (19:21 +0000)
  - 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

src/CommandStubs.pl
src/Factoids/Core.pl
src/IRC/Irc.pl
src/Process.pl
src/core.pl
src/logger.pl

index 54035dbdfc70a123887b43ac66de83a752ec822b..cc0a3fb926a759a0eaaeceff275cf1f303beeb62 100644 (file)
@@ -14,6 +14,7 @@ use vars qw(%channels %cache %mask %userstats %myModules %cmdstats
 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',
@@ -294,7 +295,7 @@ sub Modules {
     }
 
     # 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); } );
@@ -431,8 +432,8 @@ sub Modules {
            $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;
        }
 
index 59932d054f7ea74bafdc58aac49da649284df1be..fde06aa273292ebd14bad902ec70836b703646ff 100644 (file)
@@ -300,7 +300,7 @@ sub FactoidStuff {
 
        my $faqtoid = $message;
        if ($faqtoid eq "") {
-           &help("undelete");
+           &help("unforget");
            return;
        }
 
@@ -377,29 +377,31 @@ sub FactoidStuff {
        }
 
        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'.");
        }
index 8350e4d716a045ec18940603dfbd96d9551eb6e4..a73a51aea777508938ece215f74e560aa8362d7c 100644 (file)
@@ -868,7 +868,10 @@ sub joinfloodCheck {
 
        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;
index 04189826d507e9cf2bfe31d546c37c2661143cd9..40f4e701fbc837580eed188c039a1c6fe120a5c0 100644 (file)
@@ -24,7 +24,12 @@ sub process {
     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.
 
@@ -70,6 +75,11 @@ sub process {
            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.");
@@ -77,8 +87,7 @@ sub process {
            }
 
            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.
@@ -290,18 +299,11 @@ sub process {
     ###
 
     # 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");
index c82c47e666f4e03d896247ab5038c16531d3cb03..9bcaccd07031b863cc5f7cb37b6d4cd722ac34a2 100644 (file)
@@ -301,7 +301,7 @@ sub getChanConf {
     $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) {
index bcf767341fc7d03a148bca86193d10a48b20c7ad..c7593a7ba064bf374fa87d15ca32ffb8b725fd67 100644 (file)
@@ -347,6 +347,7 @@ sub status {
 
     # 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.
     }