]> git.donarmstrong.com Git - infobot.git/blobdiff - src/Modules/News.pl
really support negative booleans and and return -1 for IsChanConf() when they are...
[infobot.git] / src / Modules / News.pl
index 2afb80ad49c707f1f65e4d19937cadb65e254cf8..25b049c28d5fb1f4aa4a4a47d0706700a933a4d1 100644 (file)
@@ -40,7 +40,7 @@ sub Parse {
     }
 
     if (defined $what and $what =~ s/^($::mask{chan})\s*//) {
-       # todo: check if the channel exists aswell.
+       # TODO: check if the channel exists aswell.
        $chan   = lc $1;
 
        if (!&::IsNickInChan($who, $chan)) {
@@ -118,8 +118,8 @@ sub Parse {
     } elsif ($what =~ /^(un)?notify$/i) {
        my $state = ($1) ? 0 : 1;
 
-       # todo: don't notify even if "news" is called.
-       if (!&::IsChanConf("newsNotifyAll")) {
+       # TODO: don't notify even if "News" is called.
+       if (&::IsChanConf("newsNotifyAll") <= 0) {
            &::DEBUG("news: chan => $chan, ::chan => $::chan.");
            &::notice($who, "not available for this channel or disabled altogether.");
            return;
@@ -167,7 +167,7 @@ sub readNews {
     while (<NEWS>) {
        chop;
 
-       # todo: allow commands.
+       # TODO: allow commands.
 
        if (/^[\s\t]+(\S+):[\s\t]+(.*)$/) {
            if (!defined $item) {
@@ -218,7 +218,7 @@ sub writeNews {
        return;
     }
 
-    # todo: add commands to output file.
+    # TODO: add commands to output file.
     my $c = 0;
     my($cc,$ci,$cu) = (0,0,0);
 
@@ -243,7 +243,7 @@ sub writeNews {
        }
     }
 
-    # todo: show how many users we wrote down.
+    # TODO: show how many users we wrote down.
     if (&::getChanConfList("newsKeepRead")) {
        # old users are removed in newsFlush(), perhaps it should be
        # done here.
@@ -281,7 +281,7 @@ sub add {
     }
 
     $::news{$chan}{$str}{Time} = time();
-    my $expire = &::getChanConfDefault("newsDefaultExpire",7);
+    my $expire = &::getChanConfDefault("newsDefaultExpire",7, $chan);
     $::news{$chan}{$str}{Expire}       = time() + $expire*60*60*24;
     $::news{$chan}{$str}{Author}       = $::who;       # case!
 
@@ -353,7 +353,7 @@ sub del {
        $auth++ if (&::IsFlag("o"));
 
        if (!$auth) {
-           # todo: show when it'll expire.
+           # TODO: show when it'll expire.
            &::notice($who, "Sorry, you cannot remove items; just let them expire on their own.");
            return;
        }
@@ -371,7 +371,7 @@ sub list {
        return;
     }
 
-    if (&::IsChanConf("newsKeepRead")) {
+    if (&::IsChanConf("newsKeepRead") > 0) {
        my $x = $::newsuser{$chan}{$who};
 
        if (defined $x and ($x == 0 or $x == -1)) {
@@ -420,7 +420,7 @@ sub list {
            next;
        }
 
-       # todo: show request stats aswell.
+       # TODO: show request stats aswell.
        &::msg($who, sprintf("\002[\002%2d\002]\002%s %s",
                                $i, $chr, $subtopic));
        $i++;
@@ -452,7 +452,7 @@ sub read {
 
     my $item   = &getNewsItem($str);
     if (!defined $item or !scalar keys %{ $::news{$chan}{$item} }) {
-       # todo: numerical check.
+       # TODO: numerical check.
        if ($str =~ /^(\d+)[-, ](\d+)$/ or
            $str =~ /^-(\d+)$/ or
            $str =~ /^(\d+)-$/ or 0
@@ -536,13 +536,13 @@ sub mod {
        }
 
        ### TODO: use m### to make code safe!
-       # todo: make code safer.
+       # TODO: make code safer.
        my $done = 0;
-       # todo: use eval to deal with flags easily.
+       # TODO: use eval to deal with flags easily.
        if ($flags eq "") {
            $done++ if (!$done and $mod_news  =~ s/\Q$op\E/$np/);
            $done++ if (!$done and $mod_nnews =~ s/\Q$op\E/$np/);
-        } elsif ($flags eq "g") {
+       } elsif ($flags eq "g") {
            $done++ if ($mod_news  =~ s/\Q$op\E/$np/g);
            $done++ if ($mod_nnews =~ s/\Q$op\E/$np/g);
        }
@@ -642,7 +642,7 @@ sub set {
     }
 
     if ($what eq "Expire") {
-       # todo: use do_set().
+       # TODO: use do_set().
 
        my $time = 0;
        my $plus = ($value =~ s/^\+//g);
@@ -706,12 +706,12 @@ sub set {
     }
 
     if (!$auth) {
-       # todo: show when it'll expire.
+       # TODO: show when it'll expire.
        &::notice($who, "Sorry, you cannot set items. (author $author owns it)");
        return;
     }
 
-    # todo: clean this up.
+    # TODO: clean this up.
     my $old = $::news{$chan}{$news}{$what};
     if (defined $old) {
        &::DEBUG("news: old => $old.");
@@ -727,7 +727,7 @@ sub latest {
     $chan = $tchan;
     $who  = $::who;
 
-    # todo: if chan = undefined, guess.
+    # TODO: if chan = undefined, guess.
 #    if (!exists $::news{$chan}) {
     if (!exists $::channels{$chan}) {
        &::notice($who, "invalid chan $chan") if ($flag);
@@ -751,8 +751,7 @@ sub latest {
     }
 
     $::chan    = $chan;
-    my $x = &::IsChanConf("newsNotifyAll");
-    return if (!$x);
+    return if (&::IsChanConf("newsNotifyAll") <= 0);
 
     # I don't understand this code ;)
     $t = 1 if (!defined $t);
@@ -792,14 +791,14 @@ sub latest {
     # scalar @new, !$flag
     my $unread = scalar @new;
     my $total  = scalar keys %{ $::news{$chan} };
-    if (!$flag && !&::IsChanConf("newsTellUnread")) {
+    if (!$flag && &::IsChanConf("newsTellUnread") <= 0) {
        return;
     }
 
     if (!$flag) {
        return unless ($unread);
 
-       # just a temporary measure not to flood ourself off the 
+       # just a temporary measure not to flood ourself off the
        # network with news until we get global notice() and msg()
        # throttling.
        if (time() - ($::cache{newsTime} || 0) < 5) {
@@ -831,7 +830,7 @@ sub latest {
            $i   = &newsS2N($_);
            $sorted[$i] = $_;
        }
-       
+
        for ($i=0; $i<=scalar(@sorted); $i++) {
            my $news = $sorted[$i];
            next unless (defined $news);
@@ -844,7 +843,7 @@ sub latest {
            } );
        }
 
-       # todo: implement throttling via schedule into &notice() / &msg().
+       # TODO: implement throttling via schedule into &notice() / &msg().
        $::conn->schedule(int((2+$i)/2), sub {
            &::notice($who, "|= to read, do \002news $chan read <#>\002 or \002news $chan read <keyword>\002");
        } );
@@ -989,7 +988,7 @@ sub do_set {
        return;
     }
 
-    &::DEBUG("news: do_set: TODO...");
+    &::TODO("news: do_set:");
 }
 
 sub stats {