]> git.donarmstrong.com Git - infobot.git/blobdiff - src/Process.pl
foo+1 does not work on sqlReplace for sqlite.
[infobot.git] / src / Process.pl
index 1a4b126764036c7639d11e53f2d0ea219ba61015..3563866c101790061fd01d4750c9124dab7e2e09 100644 (file)
@@ -6,7 +6,13 @@
 # process the incoming message
 #
 
-#use strict;
+use strict;
+
+use vars qw($who $msgType $addressed $message $ident $user $host $chan
+       $learnok $talkok $force_public_reply $noreply $addrchar
+       $literal $addressedother $userHandle $lobotomized);
+use vars qw(%channels %users %param %cache %chanconf %mask %orig %lang
+       );
 
 sub process {
     $learnok   = 0;    # Able to learn?
@@ -22,6 +28,14 @@ sub process {
 
     &shmFlush();               # hack.
 
+    # hack to support channel +o as "+o" in bot user file.
+    # requires +O in user file.
+    # is $who arg lowercase?
+    if (exists $channels{$chan}{o}{ $orig{who} } && &IsFlag("O") eq "O") {
+       &status("Gave $who/$chan +o (+O)\'ness");
+       $users{$userHandle}{FLAGS} .= "o";
+    }
+
     # check if we have our head intact.
     if ($lobotomized) {
        if ($addressed and IsFlag("o") eq "o") {
@@ -182,6 +196,8 @@ sub process {
        my $found = 0;
 
        foreach (keys %channels) {
+           # don't test for $channel{_default} elsewhere !!!
+           next if (/^\s*$/ || /^_?default$/);
            next unless (&IsNickInChan($who,$_));
 
            $found++;
@@ -240,7 +256,7 @@ sub process {
 
        # customized random message.
        my $tmp = (rand() < 0.5) ? ", $who" : "";
-       &performStrictReply(&getRandom(keys %{ $lang{'hello'} }) . $tmp);
+       &pSReply( &getRandom(keys %{ $lang{'hello'} }) . $tmp );
        return;
     }
 
@@ -262,7 +278,7 @@ sub process {
        &status("random praise detected");
 
        my $tmp = (rand() < 0.5) ? "thanks $who " : "";
-       &performStrictReply($tmp.":)");
+       &pSReply($tmp.":)");
 
        return;
     }
@@ -282,6 +298,9 @@ 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);
 
@@ -295,18 +314,20 @@ sub process {
            return;
        }
 
-       my $karma = &dbGet("stats", "counter", "nick=".&dbQuote($term).
-                       " AND type='karma'") || 0;
+       my $karma = &sqlSelect("stats", "counter",
+               { nick => $term, type => "karma" }) || 0;
        if ($inc eq '++') {
            $karma++;
        } else {
            $karma--;
        }
 
-       &dbSet("stats", 
-               { nick => $term, type => "karma" },
-               { counter => $karma }
-       );
+       &sqlReplace("stats", {
+           nick        => $term,
+           type        => "karma",
+           'time'      => time(),
+           counter     => $karma,
+       } );
 
        return;
     }
@@ -323,13 +344,22 @@ sub process {
            return 'SOMETHING 1';
        }
 
+       # allow administration of bot via messages (default is DCC CHAT only)
+       if (&IsFlag("A")) {
+           &loadMyModule( $myModules{'ircdcc'} );
+           $er = &userDCC();
+           if (!defined $er) {
+               return 'SOMETHING 2';
+           }
+       }
+
        if (0 and $addrchar) {
            &msg($who, "I don't trust people to use the core commands while addressing me in a short-cut way.");
            return;
        }
     }
 
-    if (&IsParam("factoids") and $param{'DBType'} =~ /^(mysql|pgsql|dbm)/i) {
+    if (&IsParam("factoids") and $param{'DBType'} =~ /^(mysql|sqlite|pgsql|dbm)/i) {
        &FactoidStuff();
     } elsif ($param{'DBType'} =~ /^none$/i) {
        return "NO FACTOIDS.";