From b6accd0ec31c9e167c396b7d6db73ce9d47815ad Mon Sep 17 00:00:00 2001 From: dms Date: Sat, 26 May 2001 14:37:03 +0000 Subject: [PATCH] - dbGet: warn if $select is NULL - 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 | 2 +- src/Factoids/Update.pl | 2 +- src/IRC/IrcHooks.pl | 9 ++++----- src/Modules/Debian.pl | 2 +- src/Modules/News.pl | 35 +++++++++++++++++++---------------- src/Modules/RootWarn.pl | 11 ++++++----- src/Modules/UserDCC.pl | 13 +++++++++++++ src/db_mysql.pl | 5 +++++ 8 files changed, 50 insertions(+), 29 deletions(-) diff --git a/src/CommandStubs.pl b/src/CommandStubs.pl index f302d0c..addcb05 100644 --- a/src/CommandStubs.pl +++ b/src/CommandStubs.pl @@ -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")); diff --git a/src/Factoids/Update.pl b/src/Factoids/Update.pl index e94a7b7..1f117c4 100644 --- a/src/Factoids/Update.pl +++ b/src/Factoids/Update.pl @@ -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") || ""; diff --git a/src/IRC/IrcHooks.pl b/src/IRC/IrcHooks.pl index 42e8018..ff75f36 100644 --- a/src/IRC/IrcHooks.pl +++ b/src/IRC/IrcHooks.pl @@ -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")) { diff --git a/src/Modules/Debian.pl b/src/Modules/Debian.pl index e525e02..2dfea69 100644 --- a/src/Modules/Debian.pl +++ b/src/Modules/Debian.pl @@ -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); diff --git a/src/Modules/News.pl b/src/Modules/News.pl index 4696982..c9d0d58 100644 --- a/src/Modules/News.pl +++ b/src/Modules/News.pl @@ -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"); diff --git a/src/Modules/RootWarn.pl b/src/Modules/RootWarn.pl index 3fe7900..1a3d6c6 100644 --- a/src/Modules/RootWarn.pl +++ b/src/Modules/RootWarn.pl @@ -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) { diff --git a/src/Modules/UserDCC.pl b/src/Modules/UserDCC.pl index f8a309c..09082a8 100644 --- a/src/Modules/UserDCC.pl +++ b/src/Modules/UserDCC.pl @@ -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")); diff --git a/src/db_mysql.pl b/src/db_mysql.pl index 4c31e5a..1fb8d4b 100644 --- a/src/db_mysql.pl +++ b/src/db_mysql.pl @@ -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"); -- 2.39.2