X-Git-Url: https://git.donarmstrong.com/?a=blobdiff_plain;f=src%2FDynaConfig.pl;h=f4ba9c3f207fd3d489a62a3672921fa5b480e471;hb=fac42dc0ecb4cd1e715dcf428887b2768b1d5e5b;hp=f2158b710228ac9cd29c51b1ed15652c8bd31de9;hpb=fa73d1328bfe3f10f6e3d19549ddfb527875c319;p=infobot.git diff --git a/src/DynaConfig.pl b/src/DynaConfig.pl index f2158b7..f4ba9c3 100644 --- a/src/DynaConfig.pl +++ b/src/DynaConfig.pl @@ -32,7 +32,7 @@ sub readUserFile { my $s2 = -s "$f~"; if ($s2 > $s1*3) { - &DEBUG("rUF: backup file bigger than current file. FIXME"); + &FIXME("rUF: backup file bigger than current file."); } } @@ -160,6 +160,8 @@ sub writeUserFile { print OUT "--$what\t\t$_\n"; } + } elsif ($_ eq 'FLAGS') { + print OUT "--$_\t\t" . join('', sort split('', $val)) . "\n"; } else { print OUT "--$_\t\t$val\n"; } @@ -224,7 +226,7 @@ sub writeUserFile { $wtime_userfile = time(); &status("--- Saved USERFILE ($cusers users; $cbans bans; $cignore ignore) at $time"); if (defined $msgType and $msgType =~ /^chat$/) { - &pSReply("--- Writing user file..."); + &performStrictReply("--- Writing user file..."); } } @@ -239,7 +241,7 @@ sub readChanFile { my $s2 = -s "$f~"; if ($s2 > $s1*3) { - &DEBUG("rCF: backup file bigger than current file. FIXME"); + &FIXME("rCF: backup file bigger than current file."); } } @@ -269,12 +271,10 @@ sub readChanFile { $chanconf{$chan}{$1} = 1; } elsif (/^[\s\t]+\-(\S+)$/) { # bool, false. - &DEBUG("deprecated support of negative options.") unless ($cache{negative}); # although this is supported in run-time configuration. - $cache{negative} = 1; -# $chanconf{$chan}{$1} = 0; + $chanconf{$chan}{$1} = 0; - } elsif (/^[\s\t]+(\S+)[\ss\t]+(.*)$/) {# what = val. + } elsif (/^[\s\t]+(\S+)[\s\t]+(.*)$/) {# what = val. $chanconf{$chan}{$1} = $2; } else { @@ -295,8 +295,6 @@ sub readChanFile { } } - delete $cache{negative}; - &status("CHANFILE: Loaded: ".(scalar(keys %chanconf)-1)." chans"); } @@ -397,7 +395,7 @@ sub writeChanFile { " chans) at $time"); if (defined $msgType and $msgType =~ /^chat$/) { - &pSReply("--- Writing chan file..."); + &performStrictReply("--- Writing chan file..."); } } @@ -405,7 +403,8 @@ sub writeChanFile { ##### USER COMMANDS. ##### -# todo: support multiple flags. +# TODO: support multiple flags. +# TODO: return all flags for opers sub IsFlag { my $flags = shift; my ($ret, $f, $o) = ""; @@ -500,7 +499,7 @@ sub hasFlag { return 1; } else { &status("DCC CHAT: <$who> $message -- not enough flags."); - &pSReply("error: you do not have enough flags for that. ($flag required)"); + &performStrictReply("error: you do not have enough flags for that. ($flag required)"); return 0; } } @@ -525,7 +524,7 @@ sub ignoreAdd { $ignore{$chan}{$mask} = [$expire, time(), $who, $comment]; - # todo: improve this. + # TODO: improve this. if ($expire == 0) { &status("ignore: Added $mask for $chan to NEVER expire, by $who, for $comment"); } else { @@ -696,20 +695,20 @@ sub chanSet { if ($cmd eq "+chan") { if (exists $chanconf{$chan}) { - &pSReply("chan $chan already exists."); + &performStrictReply("chan $chan already exists."); return; } $chanconf{$chan}{_time_added} = time(); - $chanconf{$chan}{autojoin} = 1; + $chanconf{$chan}{autojoin} = $conn->nick(); - &pSReply("Joining $chan..."); + &performStrictReply("Joining $chan..."); &joinchan($chan); return; } if (!exists $chanconf{$chan}) { - &pSReply("no such channel $chan"); + &performStrictReply("no such channel $chan"); return; } @@ -719,12 +718,12 @@ sub chanSet { ### ".chanset +blah" ### ".chanset +blah 10" -- error. - my $state = ($1 eq "+") ? 1 : 0; + my $set = ($1 eq "+") ? 1 : 0; my $was = $chanconf{$chan}{$what}; - if ($state) { # add/set. + if ($set) { # add/set. if (defined $was and $was eq "1") { - &pSReply("setting $what for $chan already 1."); + &performStrictReply("setting $what for $chan already 1."); return; } @@ -732,12 +731,7 @@ sub chanSet { } else { # delete/unset. if (!defined $was) { - &pSReply("setting $what for $chan is not set."); - return; - } - - if ($was eq "0") { - &pSReply("setting $what for $chan already 0."); + &performStrictReply("setting $what for $chan is not set."); return; } @@ -745,13 +739,13 @@ sub chanSet { } # alter for cosmetic (print out) reasons only. - $was = ($was) ? "; was '$was'" : ""; + $was = (defined $was) ? "; was '$was'" : ""; if ($val eq "0") { - &pSReply("Unsetting $what for $chan$was."); + &performStrictReply("Unsetting $what for $chan$was."); delete $chanconf{$chan}{$what}; } else { - &pSReply("Setting $what for $chan to '$val'$was."); + &performStrictReply("Setting $what for $chan to '$val'$was."); $chanconf{$chan}{$what} = $val; } @@ -762,11 +756,11 @@ sub chanSet { my $was = $chanconf{$chan}{$what}; if (defined $was and $was eq $val) { - &pSReply("setting $what for $chan already '$val'."); + &performStrictReply("setting $what for $chan already '$val'."); return; } $was = ($was) ? "; was '$was'" : ""; - &pSReply("Setting $what for $chan to '$val'$was."); + &performStrictReply("Setting $what for $chan to '$val'$was."); $chanconf{$chan}{$what} = $val; @@ -782,9 +776,9 @@ sub chanSet { } if (exists $chanconf{$chan}{$what}) { - &pSReply("$what for $chan is '$chanconf{$chan}{$what}'"); + &performStrictReply("$what for $chan is '$chanconf{$chan}{$what}'"); } else { - &pSReply("$what for $chan is not set."); + &performStrictReply("$what for $chan is not set."); } } @@ -805,17 +799,22 @@ sub rehashConfVars { &DEBUG("rehashConfVars: _ => $_"); if (/^news$/ and $i) { - &loadMyModule("news"); + &loadMyModule('News'); delete $cache{confvars}{$_}; } if (/^uptime$/ and $i) { - &loadMyModule("uptime"); + &loadMyModule('Uptime'); delete $cache{confvars}{$_}; } if (/^rootwarn$/i and $i) { - &loadMyModule($_); + &loadMyModule('RootWarn'); + delete $cache{confvars}{$_}; + } + + if (/^onjoin$/i and $i) { + &loadMyModule('OnJoin'); delete $cache{confvars}{$_}; } } @@ -825,31 +824,21 @@ sub rehashConfVars { delete $cache{confvars}; } -# registered flags... not used yet. -my @regFlagsChan = ( - "autojoin", - "limitcheckInterval", - "limitcheckPlus", - "allowConv", - "allowDNS", -### TODO: finish off this list. -); - my @regFlagsUser = ( - "m", # modify factoid. (includes renaming) - "r", # remove factoid. - "t", # teach/add factoid. + # possible chars to include in FLAG + "A", # bot administration over /msg + # default is only via DCC CHAT + "O", # dynamic ops (as on channel). (automatic +o) + "T", # add topics. "a", # ask/request factoid. - "n", # bot owner - # can "reload" + "m", # modify factoid. (includes renaming) + "n", # bot owner, can "reload" "o", # master of bot (automatic +amrt) # can search on factoid strings shorter than 2 chars # can tell bot to join new channels # can [un]lock factoids - "O", # dynamic ops (as on channel). (automatic +o) - "A", # bot administration over /msg - # default is only via DCC CHAT - "T", # add topics. + "r", # remove factoid. + "t", # teach/add factoid. ); 1;