]> git.donarmstrong.com Git - infobot.git/commitdiff
- dbGet: warn if $select is NULL
authordms <dms@c11ca15a-4712-0410-83d8-924469b57eb5>
Sat, 26 May 2001 14:37:03 +0000 (14:37 +0000)
committerdms <dms@c11ca15a-4712-0410-83d8-924469b57eb5>
Sat, 26 May 2001 14:37:03 +0000 (14:37 +0000)
- Update: return 1 if we failed and outputted text
- rootwarn: don't check +o outside RootWarn.pl
- don't make getNewsItem resolve full-string to number; use newsS2N()
- fixed "news set blah"
- added ".tellme x" in DCC CHAT.

git-svn-id: https://svn.code.sf.net/p/infobot/code/trunk/blootbot@500 c11ca15a-4712-0410-83d8-924469b57eb5

src/CommandStubs.pl
src/Factoids/Update.pl
src/IRC/IrcHooks.pl
src/Modules/Debian.pl
src/Modules/News.pl
src/Modules/RootWarn.pl
src/Modules/UserDCC.pl
src/db_mysql.pl

index f302d0cf94bfd0c9fa4ce2c7fd5c94f9ad0d5215..addcb05ba398b7b642f8fd77b0dee9ee2e566e90 100644 (file)
@@ -406,7 +406,7 @@ sub Modules {
     }
 
     # Topic management. xk++
-    # may want to add a flag(??) for topic in the near future. -xk
+    # may want to add a userflags for topic. -xk
     if ($message =~ /^topic(\s+(.*))?$/i) {
        return unless (&hasParam("topic"));
 
index e94a7b7108a6ae1ed4746aa9dfa9b382b26595dc..1f117c44816e84ce81d626a8bc5346caddd86f11 100644 (file)
@@ -205,7 +205,7 @@ sub update {
                &performStrictReply("...but \002$lhs\002 is already something else...");
                &status("FAILED update: <$who> \'$lhs\' =$mhs=> \'$rhs\'");
            }
-           return;
+           return 1;
        }
 
        my $author = &getFactInfo($lhs, "created_by") || "";
index 42e80187381ce874e9d8a48a5f4f23611ecc0b3a..ff75f369b984ece5b1b5decfe887c114828d9ee4 100644 (file)
@@ -514,11 +514,10 @@ sub on_join {
     }
 
     ### ROOTWARN:
-    # what's the +o requirement?
-    &rootWarn($who,$user,$host,$chan)
-               if (&IsChanConf("rootWarn") &&
-                   $user =~ /^r(oo|ew|00)t$/i &&
-                   $channels{$chan}{'o'}{$ident});
+    &rootWarn($who,$user,$host,$chan) if (
+               &IsChanConf("rootWarn") &&
+               $user =~ /^r(oo|ew|00)t$/i
+    );
 
     ### NEWS:
     if (&IsChanConf("news") && &IsChanConf("newsKeepRead")) {
index e525e028816a6837cf0ff9842b4ba4dd06b71937..2dfea69ac4b4cc918a2f2738292a764736e2d933 100644 (file)
@@ -166,7 +166,7 @@ sub DebianDownload {
 # Usage: &searchContents($query);
 sub searchContents {
     my ($dist, $query) = &getDistroFromStr($_[0]);
-    &::status("Debian: Contents search for '$query' on $dist.");
+    &::status("Debian: Contents search for '$query' in '$dist'.");
     my $dccsend        = 0;
 
     $dccsend++         if ($query =~ s/^dcc\s+//i);
index 4696982a3eae772f9aa5e7bdabfb4e7fdcd4873f..c9d0d580c06cecd7563ab43efb70925548354024 100644 (file)
@@ -550,8 +550,11 @@ sub mod {
 
 sub set {
     my($args) = @_;
-    $args =~ /^(\S+)\s+(\S+)\s+(.*)$/;
-    my($item, $what, $value) = ($1,$2,$3);
+    my($item, $what, $value);
+
+    $item = $1 if ($args =~ s/^(\S+)\s*//);
+    $what = $1 if ($args =~ s/^(\S+)\s*//);
+    $value = $args;
 
     &::DEBUG("news: set called.");
 
@@ -560,7 +563,6 @@ sub set {
        return;
     }
 
-    &::DEBUG("news: set: item => '$item'.");
     my $news = &getNewsItem($item);
 
     if (!defined $news) {
@@ -569,8 +571,8 @@ sub set {
     }
 
     # list all values for chan.
-    if (!defined $what) {
-       &::DEBUG("news: set: 1");
+    if (!defined $what or $what =~ /^\s*$/) {
+       &::msg($::who, "set: you didn't fill me on the arguments! (what and values)");
        return;
     }
 
@@ -589,8 +591,8 @@ sub set {
     }
 
     # show (read) what.
-    if (!defined $value) {
-       &::DEBUG("news: set: 2");
+    if (!defined $value or $value =~ /^\s*$/) {
+       &::msg($::who, "set: you didn't fill me on the arguments! (value)");
        return;
     }
 
@@ -627,6 +629,7 @@ sub set {
 
        if (!$time or ($value and $value !~ /^never$/i)) {
            &::DEBUG("news: set: Expire... need to parse.");
+           &::msg($::who, "hrm... couldn't parse that.");
            return;
        }
 
@@ -867,18 +870,18 @@ sub getNewsItem {
        foreach (sort { $a <=> $b } keys %time) {
            $item++;
 #          $no = $item if ($time{$_} eq $what);
-           if ($time{$_} eq $what) {
-               $no = $item;
-               next;
-           }
+##         if ($time{$_} eq $what) {
+##             $no = $item;
+##             next;
+##         }
 
            push(@items, $time{$_}) if ($time{$_} =~ /\Q$what\E/i);
        }
 
-       if (defined $no and !@items) {
-           &::DEBUG("news: string->number resolution: $what->$no.");
-           return $no;
-       }
+##     if (defined $no and !@items) {
+##         &::DEBUG("news: string->number resolution: $what->$no.");
+##         return $no;
+##     }
 
        if (scalar @items > 1) {
            &::DEBUG("news: Multiple matches, not guessing.");
@@ -945,7 +948,7 @@ sub stats {
     my $t = time();
     foreach $chan (keys %::newsuser) {
        $i += $t - $::newsuser{$chan}{$_};
-       &DEBUG(" i = $i");
+       &::DEBUG(" i = $i");
        $j++;
     }
     &::DEBUG("news: stats: average latest time read: total time: $i");
index 3fe7900aaa174ba9929946b3ed679868872182b3..1a3d6c6df8536da241856226e82ce52c6c003d06 100644 (file)
@@ -13,11 +13,11 @@ sub rootWarn {
     my $warnmode       = &getChanConf("rootWarnMode");
 
     if ($attempt == 0) {       # first timer.
-       if (defined $warnmode and $warnmode =~ /aggressive/i) {
-           &status("rootwarn: Detected root user; notifying nick and channel.");
-           rawout("PRIVMSG $chan :R".("O" x int(rand 80 + 2))."T has landed!");
-       } else {
+       if (defined $warnmode and $warnmode =~ /quiet/i) {
            &status("rootwarn: Detected root user; notifying user");
+       } else {
+           &status("rootwarn: Detected root user; notifying nick and channel.");
+           rawout("PRIVMSG $chan :R".("O" x int(rand 70 + 2))."T has landed!");
        }
 
        if ($_ = &getFactoid("root")) {
@@ -65,6 +65,7 @@ sub rootWarn {
 }
 
 # Extras function.
+# todo: support arguments to get info on a particular nick?
 sub CmdrootWarn {
     my $reply;
     my $count = &countKeys("rootwarn");
@@ -75,7 +76,7 @@ sub CmdrootWarn {
     }
 
     # reply #1.
-    $reply = "there ".&fixPlural("has",$count) ." been \002$i\002 ".
+    $reply = "there ".&fixPlural("has",$count) ." been \002$count\002 ".
                &fixPlural("rooter",$count) ." warned about root.";
 
     if ($param{'DBType'} !~ /^mysql$/i) {
index f8a309cc7f8c4fc443bac626ec13fed08684e004..09082a86ee22c116f6a64ddcdb6b5e2cdfc154ba 100644 (file)
@@ -38,6 +38,19 @@ sub userDCC {
 
     ### for those users with enough flags.
 
+    if ($message =~ /^tellme(\s+(.*))?$/i) {
+       my $args = $2;
+       if ($args =~ /^\s*$/) {
+           &help("tellme");
+           return;
+       }
+
+       my $result = &doQuestion($args);
+       &pSReply($result);
+
+       return;
+    }
+
     # 4op.
     if ($message =~ /^4op(\s+($mask{chan}))?$/i) {
        return unless (&hasFlag("o"));
index 4c31e5a9f7e41e3b171616c116940f9b3e9a7e6f..1fb8d4b9ec4f2a51e88494ebcb4efe57b40049c9 100644 (file)
@@ -46,6 +46,11 @@ sub dbGet {
     my $query   = "SELECT $select FROM $table";
     $query     .= " WHERE $where" if ($where);
 
+    if (!defined $select) {
+       &WARN("dbGet: select == NULL. table => $table");
+       return;
+    }
+
     my $sth;
     if (!($sth = $dbh->prepare($query))) {
        &ERROR("Get: prepare: $DBI::errstr");