From: timriker Date: Tue, 23 Nov 2004 05:16:45 +0000 (+0000) Subject: -> slashdot, should really use rss now... X-Git-Url: https://git.donarmstrong.com/?a=commitdiff_plain;h=421eba68ec4e842819be2934c390c167d3766741;p=infobot.git -> slashdot, should really use rss now... git-svn-id: https://svn.code.sf.net/p/infobot/code/trunk@1065 c11ca15a-4712-0410-83d8-924469b57eb5 --- diff --git a/blootbot/src/CommandStubs.pl b/blootbot/src/CommandStubs.pl index b230798..1cc0159 100644 --- a/blootbot/src/CommandStubs.pl +++ b/blootbot/src/CommandStubs.pl @@ -216,7 +216,7 @@ sub parseCmdHook { 'Forker' => 1, 'Cmdstats' => 'Dict') ); &addCmdHook("extra", 'slashdot', ('CODEREF' => 'Slashdot::Slashdot', 'Identifier' => 'slashdot', 'Forker' => 1, - 'Cmdstats' => 'Slashdot') ); + 'Cmdstats' => 'slashdot') ); &addCmdHook("extra", 'Plug', ('CODEREF' => 'Plug::Plug', 'Identifier' => 'Plug', 'Forker' => 1, 'Cmdstats' => 'Plug') ); diff --git a/blootbot/src/Modules/Slashdot3.pl b/blootbot/src/Modules/Slashdot3.pl deleted file mode 100644 index 7b94b09..0000000 --- a/blootbot/src/Modules/Slashdot3.pl +++ /dev/null @@ -1,103 +0,0 @@ -# -# Slashdot.pl: Slashdot headline retrival -# Author: Chris Tessone -# Modified: dms -# Licensing: Artistic License (as perl itself) -# Version: v0.4 (19991125) -# - -### -# fixed up to use XML'd /. backdoor 7/31 by richardh@rahga.com -# My only request if this gets included in infobot is that the -# other header gets trimmed to 2 lines, dump the fluff ;) -rah -# -# added a status message so people know to install LWP - oznoid -# also simplified the return code because it wasn't working. -### - -package Slashdot; - -use strict; - -sub slashdotParse { - my @list; - - foreach (@_) { - next unless (/(.*?)<\/title>/); - my $title = $1; - $title =~ s/&\;/&/g; - push(@list, $title); - } - - return @list; -} - -sub Slashdot { - my @results = &::getURL("http://slashdot.org/slashdot.xml"); - my $retval = "i could not get the headlines."; - - if (scalar @results) { - my $prefix = "Slashdot Headlines "; - my @list = &slashdotParse(@results); - $retval = &::formListReply(0, $prefix, @list); - } - - &::performStrictReply($retval); -} - -sub slashdotAnnounce { - my $file = "$::param{tempDir}/slashdot.xml"; - - my @Cxml = &::getURL("http://slashdot.org/slashdot.xml"); - if (!scalar @Cxml) { - &::DEBUG("sdA: failure (Cxml == NULL)."); - return; - } - - if (! -e $file) { # first time run. - open(OUT, ">$file"); - foreach (@Cxml) { - print OUT "$_\n"; - } - close OUT; - - return; - } - - my @Oxml; - open(IN, $file); - while (<IN>) { - chop; - push(@Oxml,$_); - } - close IN; - - my @Chl = &slashdotParse(@Cxml); - my @Ohl = &slashdotParse(@Oxml); - - my @new; - foreach (@Chl) { - last if ($_ eq $Ohl[0]); - push(@new, $_); - } - - if (scalar @new == 0) { - &::status("Slashdot: no new headlines."); - return; - } - - if (scalar @new == scalar @Chl) { - &::DEBUG("sdA: scalar(new) == scalar(Chl). bad?"); - } - - open(OUT,">$file"); - foreach (@Cxml) { - print OUT "$_\n"; - } - close OUT; - - return "Slashdot: News for nerds, stuff that matters -- ". - join(" \002::\002 ", @new); -} - -1; diff --git a/blootbot/src/Modules/slashdot.pl b/blootbot/src/Modules/slashdot.pl new file mode 100644 index 0000000..7b94b09 --- /dev/null +++ b/blootbot/src/Modules/slashdot.pl @@ -0,0 +1,103 @@ +# +# Slashdot.pl: Slashdot headline retrival +# Author: Chris Tessone <tessone@imsa.edu> +# Modified: dms +# Licensing: Artistic License (as perl itself) +# Version: v0.4 (19991125) +# + +### +# fixed up to use XML'd /. backdoor 7/31 by richardh@rahga.com +# My only request if this gets included in infobot is that the +# other header gets trimmed to 2 lines, dump the fluff ;) -rah +# +# added a status message so people know to install LWP - oznoid +# also simplified the return code because it wasn't working. +### + +package Slashdot; + +use strict; + +sub slashdotParse { + my @list; + + foreach (@_) { + next unless (/<title>(.*?)<\/title>/); + my $title = $1; + $title =~ s/&\;/&/g; + push(@list, $title); + } + + return @list; +} + +sub Slashdot { + my @results = &::getURL("http://slashdot.org/slashdot.xml"); + my $retval = "i could not get the headlines."; + + if (scalar @results) { + my $prefix = "Slashdot Headlines "; + my @list = &slashdotParse(@results); + $retval = &::formListReply(0, $prefix, @list); + } + + &::performStrictReply($retval); +} + +sub slashdotAnnounce { + my $file = "$::param{tempDir}/slashdot.xml"; + + my @Cxml = &::getURL("http://slashdot.org/slashdot.xml"); + if (!scalar @Cxml) { + &::DEBUG("sdA: failure (Cxml == NULL)."); + return; + } + + if (! -e $file) { # first time run. + open(OUT, ">$file"); + foreach (@Cxml) { + print OUT "$_\n"; + } + close OUT; + + return; + } + + my @Oxml; + open(IN, $file); + while (<IN>) { + chop; + push(@Oxml,$_); + } + close IN; + + my @Chl = &slashdotParse(@Cxml); + my @Ohl = &slashdotParse(@Oxml); + + my @new; + foreach (@Chl) { + last if ($_ eq $Ohl[0]); + push(@new, $_); + } + + if (scalar @new == 0) { + &::status("Slashdot: no new headlines."); + return; + } + + if (scalar @new == scalar @Chl) { + &::DEBUG("sdA: scalar(new) == scalar(Chl). bad?"); + } + + open(OUT,">$file"); + foreach (@Cxml) { + print OUT "$_\n"; + } + close OUT; + + return "Slashdot: News for nerds, stuff that matters -- ". + join(" \002::\002 ", @new); +} + +1; diff --git a/blootbot/src/modules.pl b/blootbot/src/modules.pl index 2ff267b..5ab42ea 100644 --- a/blootbot/src/modules.pl +++ b/blootbot/src/modules.pl @@ -45,7 +45,7 @@ if ($@) { "RootWarn" => "RootWarn.pl", "Rss" => "Rss.pl", "Search" => "Search.pl", - "slashdot" => "Slashdot3.pl", + "slashdot" => "slashdot.pl", "symdump" => "DumpVars2.pl", "topic" => "Topic.pl", "units" => "Units.pl",