chiark / gitweb /
Create sites.test. Also use different cachedir in --test mode.
authorW. Ross Younger <ryounger@chiark.greenend.org.uk>
Sat, 18 Dec 2010 17:44:20 +0000 (17:44 +0000)
committerW. Ross Younger <ryounger@chiark.greenend.org.uk>
Sat, 18 Dec 2010 17:44:20 +0000 (17:44 +0000)
rss2irc.pl
sites.test [new file with mode: 0644]

index 46e9681..43afe40 100644 (file)
@@ -18,11 +18,13 @@ my $irc = new Net::IRC;
 
 my $TEST = 0;
 my $SITESFILE = "sites";
+my $CACHEDIR = "cache/";
 
 my $t = shift @ARGV;
 if ($t eq '--test') {
     $TEST=1;
     $SITESFILE = "sites.test";
+    $CACHEDIR = "cache.test/";
 }
 
 print "Connecting...\n";
@@ -43,7 +45,7 @@ my $throttle = 3; # seconds between reports
 $conn->{status} = "wait"; # "wait" or "check" states
 $conn->{oldtime} = time;
 $conn->{newtime} = time;
-my $cachedir = "cache/";
+mkdir $CACHEDIR unless -d $CACHEDIR;
 my @sites;
 my $hupflag = 0;
 
@@ -208,7 +210,7 @@ sub get_news {
 sub read_cache($) {
     my ($name) = shift;
     my ($fh, $cachelink);
-    my $cachefile = $cachedir."/".$name;
+    my $cachefile = $CACHEDIR."/".$name;
     my @rv;
     return undef if( ! -e $cachefile ); 
     open($fh, $cachefile) or die ("Cant open cachefile: $!");
@@ -242,7 +244,7 @@ sub update_cache {
     # args: name, cachelink [,link [,link ...]]
     # so @_ is now the new cache. OVERWRITES what's already there!
     my $fh;
-    my $cachefile = $cachedir."/".$name;
+    my $cachefile = $CACHEDIR."/".$name;
     open($fh, ">", $cachefile) or die ("Can't open cachefile: $!");
     print $fh $_.$/ for (@_);
     close($fh);
diff --git a/sites.test b/sites.test
new file mode 100644 (file)
index 0000000..aa38711
--- /dev/null
@@ -0,0 +1,22 @@
+# SYNTAX:
+#   channel;feedshortname;colour;url
+#   NB that channel must have no leading '#' or it will be mistaken
+#   for a comment!
+#
+# FIXME:  TODO: Reinstate the proper URL-encoding in the bot.
+#
+beeb;bbc-uk;0;http://feeds.bbci.co.uk/news/uk/rss.xml?edition=uk
+beeb;bbc-world;0;http://feeds.bbci.co.uk/news/world/rss.xml
+beeb;bbc-biz;0;http://feeds.bbci.co.uk/news/business/rss.xml
+beeb;bbc-sci;0;http://feeds.bbci.co.uk/news/science_and_environment/rss.xml
+beeb;bbc-tech;0;http://feeds.bbci.co.uk/news/technology/rss.xml
+#
+# Now that we report by guid, rather than by link, the BBC weather forecasts can work without a logic facelift:
+weather;Cambridge;2;http://newsrss.bbc.co.uk/weather/forecast/324/ObservationsRSS.xml
+weather;Cambridge;2;http://newsrss.bbc.co.uk/weather/forecast/324/Next3DaysRSS.xml
+weather;Oxford;3;http://newsrss.bbc.co.uk/weather/forecast/25/ObservationsRSS.xml
+weather;Oxford;3;http://newsrss.bbc.co.uk/weather/forecast/25/Next3DaysRSS.xml
+#
+# OTOH the Met Office site, at least the warnings, have serial numbers...
+weather;meto-ee-warnings;2;http://www.metoffice.gov.uk/xml/warnings_rss_ee.xml
+weather;meto-se-warnings;3;http://www.metoffice.gov.uk/xml/warnings_rss_se.xml