]> git.donarmstrong.com Git - infobot.git/blobdiff - src/core.pl
- bot stats: "blah has blah... is ranked xx/yy (zz percentile)"
[infobot.git] / src / core.pl
index 36e8c76b66eca42a3d37072b62892305937abd22..c8696653f0f3c18af99c80e5310a26a20bea695c 100644 (file)
@@ -99,6 +99,7 @@ sub doExit {
 
        &closeDCC();
        &closePID();
+       &closeStats();
        &seenFlush();
        &quit($param{'quitMsg'}) if (&whatInterface() =~ /IRC/);
        &writeUserFile();
@@ -201,6 +202,8 @@ sub IsChanConf {
        return 0;
     }
 
+    $chan      ||= "_default";
+
     my $old = $chan;
     if ($chan =~ tr/A-Z/a-z/) {
        &WARN("IsChanConf: lowercased chan. ($old)");
@@ -282,6 +285,7 @@ sub getChanConf {
 
     $c         ||= $chan;
     $c         ||= "_default";
+    $c         = "_default" if ($c eq "*");    # fix!
     my @c      = grep /^$c$/i, keys %chanconf;
 
     if (@c) {
@@ -295,6 +299,31 @@ sub getChanConf {
     return $chanconf{"_default"}{$param};
 }
 
+#####
+#  Usage: &findChanConf($param);
+#  About: Retrieve value for 'param' value from any chan.
+# Return: scalar for success, undef for failure.
+sub findChanConf {
+    my($param) = @_;
+
+    if (!defined $param) {
+       &WARN("param == NULL.");
+       return 0;
+    }
+
+    my $c;
+    foreach $c (keys %chanconf) {
+       foreach (keys %{ $chanconf{$c} }) {
+           next unless (/^$param$/);
+
+           &DEBUG("chanconf{$c}{$_} ...");
+           return $chanconf{$c}{$_};
+       }
+    }
+
+    return;
+}
+
 sub showProc {
     my ($prefix) = $_[0] || "";
 
@@ -452,8 +481,9 @@ sub restart {
 
        ### crappy bug in Net::IRC?
        if (!$conn->connected and time - $msgtime > 900) {
-           &status("reconnecting because of uncaught disconnect.");
+           &status("reconnecting because of uncaught disconnect \@ ".scalar(localtime) );
 ###        $irc->start;
+           &clearIRCVars();
            $conn->connect();
 ###        return;
        }