From 8f6e9d37ccdfda5d6bf71c5c588eeb786448f881 Mon Sep 17 00:00:00 2001 From: dms Date: Fri, 8 Nov 2002 14:05:29 +0000 Subject: [PATCH] - forgot to delete hash key even if current pid == parent pid. - 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 | 1 + src/IRC/IrcHooks.pl | 15 +++++++++++++-- src/IRC/Schedulers.pl | 2 +- src/Modules/Uptime.pl | 8 ++++---- src/Shm.pl | 13 ++++++------- src/core.pl | 10 +++++++--- 6 files changed, 32 insertions(+), 17 deletions(-) diff --git a/src/IRC/Irc.pl b/src/IRC/Irc.pl index d7adf87..3496cb4 100644 --- a/src/IRC/Irc.pl +++ b/src/IRC/Irc.pl @@ -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); diff --git a/src/IRC/IrcHooks.pl b/src/IRC/IrcHooks.pl index 117daa2..fee1b60 100644 --- a/src/IRC/IrcHooks.pl +++ b/src/IRC/IrcHooks.pl @@ -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")) { diff --git a/src/IRC/Schedulers.pl b/src/IRC/Schedulers.pl index c0c9cf2..caa902a 100644 --- a/src/IRC/Schedulers.pl +++ b/src/IRC/Schedulers.pl @@ -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} ) ) { diff --git a/src/Modules/Uptime.pl b/src/Modules/Uptime.pl index 8be74bf..ca2e584 100644 --- a/src/Modules/Uptime.pl +++ b/src/Modules/Uptime.pl @@ -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; diff --git a/src/Shm.pl b/src/Shm.pl index ab7e996..41f96bf 100644 --- a/src/Shm.pl +++ b/src/Shm.pl @@ -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; } diff --git a/src/core.pl b/src/core.pl index bf03587..77c8f9c 100644 --- a/src/core.pl +++ b/src/core.pl @@ -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; -- 2.39.2