Changeset 264
- Timestamp:
- 05/20/06 12:28:29 (3 years ago)
- Files:
-
- 1 modified
-
trunk/tools/irc/trac.rb (modified) (3 diffs)
Legend:
- Unmodified
- Added
- Removed
-
trunk/tools/irc/trac.rb
r263 r264 28 28 require 'rss/2.0' 29 29 require 'open-uri' 30 require 'timeout' 30 31 require 'yaml' 31 32 … … 41 42 @feeds = {} 42 43 @period = 60 44 @time_limit = 5 45 @retry_limit = 5 43 46 @bot.timer.add( @period, self ) { |tracer| 44 47 tracer.feed … … 47 50 48 51 def feed 49 puts @feeds.to_yaml50 52 @feeds.each {|url,params| 53 tries = 0 51 54 begin 52 open( url ) {|page| 53 data = page.read 54 @bot.say params[:where], parse( data, params ) 55 Timeout::timeout( @time_limit ) { 56 open( url ) {|page| 57 data = page.read 58 @bot.say params[:where], parse( data, params ) 59 } 55 60 } 56 61 rescue OpenURI::HTTPError, EOFError 57 retry #:MC: is this going to be really bad, like, if the connection goes down? 62 tries += 1 63 retry unless tries >= @retry_limit 64 rescue RSS::NotWellFormedError, SocketError, Timeout::Error 65 # just let these errors slide, but don't retry 58 66 end 59 67 }
