+sub latest {
+ my($tchan, $flag) = @_;
+
+ $chan ||= $tchan; # hack hack hack.
+
+ # todo: if chan = undefined, guess.
+ if (!exists $::news{$chan}) {
+ &::msg($::who, "invalid chan $chan");
+ return;
+ }
+
+ my @new;
+ foreach (keys %{ $::news{$chan} }) {
+ my $t = $::newsuser{$chan}{$::who};
+ next if (!defined $t);
+ next if ($t > $::news{$chan}{$_}{Time});
+
+ push(@new, $_);
+ }
+
+ if (!scalar @new and $flag) {
+ &::msg($::who, "no new news for $chan.");
+ return;
+ }
+
+ if (scalar @new) {
+ &::msg($::who, "+==== New news for \002$chan\002 (".
+ scalar(@new)." new items):");
+
+ my $timestr = &::Time2String( time() - $::newsuser{$chan}{$::who} );
+ &::msg($::who, "|= Last time read $timestr ago");
+
+ foreach (@new) {
+ my $i = &newsS2N($_);
+ &::DEBUG("i = $i, _ => $_");
+ my $age = time() - $::news{$chan}{$_}{Time};
+ &::msg($::who, sprintf("\002[\002%2d\002]\002 %s",
+ $i, $_) );
+# $i, $_, &::Time2String($age) ) );
+ }
+
+ &::msg($::who, "|= to read, do 'news read <#>' or 'news read <keyword>'");
+
+ # lame hack to prevent dupes if we just ignore it.
+ $::newsuser{$chan}{$::who} = time();
+ }
+}
+