# 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;
}
# 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();