Skip to content

Commit

Permalink
feed entry is desc
Browse files Browse the repository at this point in the history
  • Loading branch information
cho45 committed May 19, 2010
1 parent e40992a commit 20cf0eb
Showing 1 changed file with 29 additions and 17 deletions.
46 changes: 29 additions & 17 deletions examples/gig.rb
Original file line number Diff line number Diff line change
Expand Up @@ -57,24 +57,36 @@ def on_user(m)

@retrieve_thread = Thread.start do
loop do
@log.info 'retrieveing feed...'
doc = LibXML::XML::Document.file("http://github.com/#{@real}.private.atom?token=#{@pass}")
ns = %w|a:http://www.w3.org/2005/Atom|
doc.find('/a:feed/a:entry', ns).each do |n|
datetime = Time.parse n.find('string(a:published)', ns)
next if datetime < @last_retrieved

id = n.find('string(a:id)', ns)
title = n.find('string(a:title)', ns)
author = n.find('string(a:author/a:name)', ns)
link = n.find('string(a:link/@href)', ns)

post author, PRIVMSG, main_channel, "#{title} \00314#{link}\017"
begin
@log.info 'retrieveing feed...'
doc = LibXML::XML::Document.file("http://github.com/#{@real}.private.atom?token=#{@pass}")
ns = %w|a:http://www.w3.org/2005/Atom|
entries = []
doc.find('/a:feed/a:entry', ns).each do |n|
datetime = Time.parse n.find('string(a:published)', ns)
next if datetime < @last_retrieved

entries << {
:id => n.find('string(a:id)', ns),
:title => n.find('string(a:title)', ns),
:author => n.find('string(a:author/a:name)', ns),
:link => n.find('string(a:link/@href)', ns),
}
end

entries.reverse_each do |entry|
post entry[:author], PRIVMSG, main_channel, "#{entry[:title]} \00314#{entry[:link]}\017"
end

@last_retrieved = Time.now
@log.info 'sleep'
sleep 30
rescue Exception => e
@log.error e.inspect
e.backtrace.each do |l|
@log.error "\t#{l}"
end
end

@last_retrieved = Time.now
@log.info 'sleep'
sleep 30
end
end
end
Expand Down

0 comments on commit 20cf0eb

Please sign in to comment.