diff --git a/plugins/redhatsecurity.rb b/plugins/redhatsecurity.rb index 6e675be045a6167ab6bb35102e755beb25fb2aff..1361543d6a637ea77ca377a28a2ca0eede56e124 100644 --- a/plugins/redhatsecurity.rb +++ b/plugins/redhatsecurity.rb @@ -25,7 +25,6 @@ class Redhatsecurity # Default action for this plugin def main( nick, user, host, from, msg, arguments, con ) - end # Method to be called when the plugin is unloaded @@ -45,28 +44,30 @@ class Redhatsecurity # Grab rss xml = agent.get( @feed_url ).body xml = Nokogiri::XML( xml ) + # Parse out info + items = xms.css('item') title = xml.css( 'item title' ).last.text link = xml.css( 'item link' ).last.text # Check for already announced stuff if @recent.include? link - raise 'Stale RSS feed link' + @recent.delete link else - @recent.push link - if @recent.size > 10 - @recent = @recent [1..10] + # If the tinyurl plugin is loaded, use it + if( @status.checkplugin( "tinyurl" ) ) + plugin = @status.getplugin( "tinyurl" ) + link = plugin.main( nil, nil, nil, nil, nil, link, false ) end - end - # If the tinyurl plugin is loaded, use it - if( @status.checkplugin( "tinyurl" ) ) - plugin = @status.getplugin( "tinyurl" ) - link = plugin.main( nil, nil, nil, nil, nil, link, false ) + @irc.message( @channel, "\x02\x034,1Red\x0f\x030,1hat\x0f #{title} | #{link}" ) + @irc.message( @channel, " " ) end + @recent.push link + + # Trim buffer + @recent.shift(@recent.length - 50) if @recent.length > 50 - @irc.message( @channel, "\x02\x034,1Red\x0f\x030,1hat\x0f #{title} | #{link}" ) - @irc.message( @channel, " " ) rescue Exception => e # Silently fail @output.debug( "Failure while retrieving rss feed: #{e.message}\n" ) @@ -76,4 +77,4 @@ class Redhatsecurity sleep( @feed_timer ) end end -end \ No newline at end of file +end