$wtime_chanfile = 0;
$ucount_chanfile = 0;
-### CHANGE TO STATIC.
-$bot_version = "blootbot cvs (20001212) -- $^O";
+$bot_version = "blootbot cvs (20010214) -- $^O";
$noreply = "NOREPLY";
##########
&writeUserFile();
&writeChanFile();
&uptimeWriteFile() if (&ChanConfList("uptime"));
+ &News::writeNews() if (&ChanConfList("news"));
&closeDB();
&closeSHM($shm);
&dumpallvars() if (&IsParam("dumpvarsAtExit"));
return unless (defined $param);
my %chan = &getChanConfList($param);
- ### TODO: -option is included aswell though.
- return keys %chan;
+ if (exists $chan{_default}) {
+ return keys %chanconf;
+ } else {
+ return keys %chan;
+ }
}
#####
# Return: 1 for enabled, 0 for passive disable, -1 for active disable.
sub IsChanConf {
my($param) = shift;
+ my $debug = 0; # knocked tons of bugs with this! :)
if (!defined $param) {
- &WARN("param == NULL.");
+ &WARN("IsChanConf: param == NULL.");
return 0;
}
+ if ($chan =~ tr/A-Z/a-z/) {
+ &WARN("IsChanConf: lowercased chan.");
+ }
+
### TODO: VERBOSITY on how chanconf returned 1 or 0 or -1.
my %chan = &getChanConfList($param);
- if (!defined $msgType) {
- return $chan{_default} || 0;
+ if (!defined $msgType or $msgType eq "") {
+ if ($chan{$chan}) {
+ &DEBUG("ICC: !msgType: $chan{$chan} (_default/$param)") if ($debug);
+ } elsif ($chan{_default}) {
+ &DEBUG("ICC: !msgType: $chan{_default} (_default/$param)") if ($debug);
+ } else {
+ &DEBUG("ICC: !msgType: 0 ($param)") if ($debug);
+ }
+
+ return $chan{$chan} || $chan{_default} || 0;
}
if ($msgType eq "public") {
- return $chan{lc $chan} || $chan{_default} || 0;
+ if ($chan{$chan}) {
+ &DEBUG("ICC: public: $chan{$chan} ($chan/$param)") if ($debug);
+ } elsif ($chan{_default}) {
+ &DEBUG("ICC: public: $chan{_default} (_default/$param)") if ($debug);
+ } else {
+ &DEBUG("ICC: public: 0 ($param)") if ($debug);
+ }
+
+ return $chan{$chan} || $chan{_default} || 0;
}
if ($msgType eq "private") {
- return $chan{_default} || 0;
+ if ($chan{_default}) {
+ &DEBUG("ICC: private: $chan{_default} (_default/$param)") if ($debug);
+ } elsif ($chan{$chan}) {
+ &DEBUG("ICC: private: $chan{$chan} ($chan/$param) (hack)") if ($debug);
+ } else {
+ &DEBUG("ICC: private: 0 ($param)") if ($debug);
+ }
+
+ return $chan{$chan} || $chan{_default} || 0;
}
### debug purposes only.
# &DEBUG(" $_ => $chan{$_}");
# }
+ &DEBUG("ICC: no-match: 0/$param (msgType = $msgType)");
+
return 0;
}
}
close IN;
- if (defined $memusageOld and &IsParam("DEBUG")) {
- # it's always going to be increase.
- my $delta = $memusage - $memusageOld;
- my $str;
- if ($delta == 0) {
- return;
- } elsif ($delta > 500) {
- $str = "MEM:$prefix increased by $delta kB. (total: $memusage kB)";
- } elsif ($delta > 0) {
- $str = "MEM:$prefix increased by $delta kB";
- } else { # delta < 0.
- $delta = -$delta;
- # never knew RSS could decrease, probably Size can't?
- $str = "MEM:$prefix decreased by $delta kB. YES YES YES";
- }
-
- &status($str);
- }
- $memusageOld = $memusage;
+ } elsif ($^O eq "netbsd") {
+ $memusage = (stat "/proc/$$/mem")[7]/1024;
+
+ } elsif ($^O =~ /^(free|open)bsd$/) {
+ my @info = split /\s+/, `/bin/ps -l -p $$`;
+ $memusage = $info[20];
+
} else {
$memusage = "UNKNOWN";
+ return;
}
- ### TODO: FreeBSD/*BSD support.
+
+ if (defined $memusageOld and &IsParam("DEBUG")) {
+ # it's always going to be increase.
+ my $delta = $memusage - $memusageOld;
+ my $str;
+ if ($delta == 0) {
+ return;
+ } elsif ($delta > 500) {
+ $str = "MEM:$prefix increased by $delta kB. (total: $memusage kB)";
+ } elsif ($delta > 0) {
+ $str = "MEM:$prefix increased by $delta kB";
+ } else { # delta < 0.
+ $delta = -$delta;
+ # never knew RSS could decrease, probably Size can't?
+ $str = "MEM:$prefix decreased by $delta kB. YES YES YES";
+ }
+
+ &status($str);
+ }
+ $memusageOld = $memusage;
}
######
# read.
&loadLang($bot_misc_dir. "/blootbot.lang");
- &loadIRCServers($bot_misc_dir. "/ircII.servers");
+ &loadIRCServers();
&readUserFile();
&readChanFile();
&loadMyModulesNow(); # must be after chan file.
&openDB($param{'DBName'}, $param{'SQLUser'}, $param{'SQLPass'});
&status("Setup: ". &countKeys("factoids") ." factoids.");
+ &News::readNews() if (&ChanConfList("news"));
$param{tempDir} =~ s#\~/#$ENV{HOME}/#;
# reverse order of &setup().
&DEBUG("shutdown called.");
+ # opened files must be written to on shutdown/hup/whatever
+ # unless they're write-only, like uptime.
+ &writeUserFile();
+ &writeChanFile();
+ &News::writeNews() if (&ChanConfList("news"));
+
&closeDB();
&closeSHM($shm); # aswell. TODO: use this in &doExit?
&closeLog();