]> git.donarmstrong.com Git - infobot.git/blobdiff - src/DynaConfig.pl
OnJoin - tensai, fixes by TimRiker
[infobot.git] / src / DynaConfig.pl
index f2158b710228ac9cd29c51b1ed15652c8bd31de9..e1cf464a1a68960ac691cf6b98e0002aa5639923 100644 (file)
@@ -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.");
        }
     }
 
@@ -274,7 +276,7 @@ sub readChanFile {
            $cache{negative} = 1;
 #          $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 {
@@ -397,7 +399,7 @@ sub writeChanFile {
                " chans) at $time");
 
     if (defined $msgType and $msgType =~ /^chat$/) {
-       &pSReply("--- Writing chan file...");
+       &performStrictReply("--- Writing chan file...");
     }
 }
 
@@ -405,7 +407,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 +503,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 +528,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 +699,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;
     }
 
@@ -724,7 +727,7 @@ sub chanSet {
 
        if ($state) {                   # 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 +735,12 @@ sub chanSet {
 
        } else {                        # delete/unset.
            if (!defined $was) {
-               &pSReply("setting $what for $chan is not set.");
+               &performStrictReply("setting $what for $chan is not set.");
                return;
            }
 
            if ($was eq "0") {
-               &pSReply("setting $what for $chan already 0.");
+               &performStrictReply("setting $what for $chan already 0.");
                return;
            }
 
@@ -748,10 +751,10 @@ sub chanSet {
        $was    = ($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 +765,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 +785,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 +808,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 +833,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;