]> git.donarmstrong.com Git - infobot.git/commitdiff
- forgot to delete hash key even if current pid == parent pid.
authordms <dms@c11ca15a-4712-0410-83d8-924469b57eb5>
Fri, 8 Nov 2002 14:05:29 +0000 (14:05 +0000)
committerdms <dms@c11ca15a-4712-0410-83d8-924469b57eb5>
Fri, 8 Nov 2002 14:05:29 +0000 (14:05 +0000)
- IsChanConf now checks $param{} via &IsParam()
- removed debugging messages related to uptime. now we know why it
  didn't run. (related to above comment)
- added 303/ison hook... although where are we notified of nicks
  signing off?

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

src/IRC/Irc.pl
src/IRC/IrcHooks.pl
src/IRC/Schedulers.pl
src/Modules/Uptime.pl
src/Shm.pl
src/core.pl

index d7adf87238273869d0143cc55db94025a464a5a0..3496cb4cd1720eda09c5b29a02b11e0ab380bdac 100644 (file)
@@ -143,6 +143,7 @@ sub irc {
        $conn->add_global_handler('disconnect', \&on_disconnect);
        $conn->add_global_handler([251,252,253,254,255], \&on_init);
 ###    $conn->add_global_handler([251,252,253,254,255,302], \&on_init);
+       $conn->add_global_handler(303, \&on_ison); # notify.
        $conn->add_global_handler(315, \&on_endofwho);
        $conn->add_global_handler(422, \&on_endofwho); # nomotd.
        $conn->add_global_handler(324, \&on_modeis);
index 117daa2d3f03ca0889b2d1e45be3d001f372727f..fee1b60622c3700697f87928d0f6d366f352db43 100644 (file)
@@ -133,6 +133,17 @@ sub on_chat {
     return 'DCC CHAT MESSAGE';
 }
 
+# is there isoff? how do we know if someone signs off?
+sub on_ison {
+    my ($self, $event) = @_;
+    my $x1 = ($event->args)[0];
+    my $x2 = ($event->args)[1];
+
+#    &nick( $param{'ircNick'} );
+
+    &DEBUG("on_ison: x1 = '$x1', x2 => '$x2'");
+}
+
 sub on_endofmotd {
     my ($self) = @_;
 
@@ -192,8 +203,8 @@ sub on_endofmotd {
     # ok, we're free to do whatever we want now. go for it!
     $running = 1;
 
-    $conn->ison($ident);
-    &DEBUG("adding self to NOTIFY/ISON.");
+    # add ourself to notify.
+    $conn->ison( $param{'ircNick'} );
 
     # Q, as on quakenet.org.
     if (&IsParam("Q_pass")) {
index c0c9cf2ef857bf56211f7e78e12eb63b36e315c1..caa902ae19041dafffc10c73a89194db4d8292d4 100644 (file)
@@ -748,7 +748,7 @@ sub ircCheck {
 
     if ($ident !~ /^\Q$param{ircNick}\E$/) {
        # this does not work unfortunately.
-       &WARN("ircCheck: ident($ident) != param{ircNick}($param{IrcNick}).");
+       &WARN("ircCheck: ident($ident) != param{ircNick}($param{ircNick}).");
 
        # this check is misleading... perhaps we should do a notify.
        if (! &IsNickInAnyChan( $param{ircNick} ) ) {
index 8be74bf6a7eaacbd6ad4f34d0c29a729c7fa1c18..ca2e58449965c223bdd23919b75686d7ef0eff68 100644 (file)
@@ -5,7 +5,7 @@
 #   Created: 19990925.
 #
 
-use strict;
+use strict;
 
 my $uptimerecords      = 3;
 
@@ -29,8 +29,6 @@ sub uptimeGetInfo {
   my @results;
   my $file = $file{utm};
 
-  &::DEBUG("uGI: reading $file...");
-
   if (!open(IN, $file)) {
     &status("Writing uptime file for first time usage (nothing special).");
     open(OUT,">$file");
@@ -85,9 +83,11 @@ sub uptimeWriteFile {
   }
 
   close OUT;
+  &status("--- Saved uptime records.");
+
+  return unless defined $conn;
 
   $conn->schedule(&getRandomInt("1800-3600"), \&uptimeWriteFile, "");
-  return;
 }
 
 1;
index ab7e9964538e7549481d5489388b933993a39296..41f96bfbeda99ebb76c4a324cb08a10a6eb139fe 100644 (file)
@@ -113,13 +113,11 @@ sub addForked {
            next;
        }
 
-       # don't kill parent!
-       if ($pid == $$) {
-           &status("Fork: pid == \$\$ ($$)");
-           next;
-       }
+       if ($pid == $bot_pid) {
+           # don't kill parent, just warn.
+           &status("Fork: pid == \$bot_pid == \$\$ ($bot_pid)");
 
-       if ( -d "/proc/$pid") {
+       } elsif ( -d "/proc/$pid") {    # pid != bot_pid.
            &status("Fork: killing $name ($pid)");
            kill 9, $pid;
        }
@@ -134,10 +132,11 @@ sub addForked {
        if ($count > 3) {       # 3 seconds.
            my $list = join(', ', keys %forked);
            if (defined $who) {
-               &msg($who, "already running ($list) => exceeded allowed forked processes count (1?).");
+               &msg($who, "exceeded allowed forked count: $list");
            } else {
                &status("Fork: I ran too many forked processes :) Giving up $name.");
            }
+
            return 0;
        }
 
index bf03587fb5b1fb9bb2503431509f44b6db1bc515..77c8f9c4fc3767d981a0d99290c6f14e5ae75532 100644 (file)
@@ -110,9 +110,6 @@ sub doExit {
        }
        &writeUserFile();
        &writeChanFile();
-       if (&IsChanConf("uptime")) {
-           &DEBUG("going to write uptime file info.");
-       }
        &uptimeWriteFile()      if (&IsChanConf("uptime"));
        &News::writeNews()      if (&ChanConfList("news"));
        &closeDB();
@@ -212,6 +209,13 @@ sub IsChanConf {
        return 0;
     }
 
+    # should we use IsParam() externally where needed or hack it in 
+    # here just in case? fix it later.
+    if (&IsParam($param)) {
+       &status("ICC: found '$param' option in main config file.");
+       return 1;
+    }
+
     $chan      ||= "_default";
 
     my $old = $chan;