Browse files

swineflu command: grab date from the table of state data, not from el…

…sewhere
  • Loading branch information...
1 parent f5a98cd commit 53b84b156543c3793de4b8f5b376da44e3d32a96 samlehman committed May 19, 2009
Showing with 7 additions and 4 deletions.
  1. +7 −4 fatbot.rb
View
11 fatbot.rb
@@ -122,11 +122,14 @@ def ops?(nick)
begin
page = WWW::Mechanize.new.get(url)
totals = (page/'.mSyndicate strong').map { |i| i.content }[1..4]
- timedate = (page/'.mSyndicate span').map { |i| i.content }[0..1]
+ timedate = (page/'.mSyndicate span').map { |i| i.content }[2]
raise "no totals" if totals.size < 3
- timeago = TwitterSearch::Tweet.time_ago_or_time_stamp( Time.parse(timedate[0]) )
-
- text = "U.S. Human Cases of H1N1 Flu Infection (As of #{timeago}): #{totals[1..2].join(", ")} -- http://www.cdc.gov/h1n1flu/"
+
+ if timedate =~ /\(As of (.+)\)/
+ timedate = TwitterSearch::Tweet.time_ago_or_time_stamp( Time.parse($1) )
+ end
+
+ text = "U.S. Human Cases of H1N1 Flu Infection (As of #{timedate}): #{totals[1..2].join(", ")} -- http://www.cdc.gov/h1n1flu/"
rescue Exception => e
text = (e.message == "no totals") ? "no totals data! #{totals.inspect}" : "Exception: #{e.message}"
end

0 comments on commit 53b84b1

Please sign in to comment.