X-Git-Url: https://git.netwichtig.de/gitweb/?a=blobdiff_plain;f=data%2Frbot%2Fplugins%2Frss.rb;h=eb3fa5f86b1bcb60be626006f323b91ac1341a14;hb=a95675a1961cb5c205ba997c9f0599f453b19d4a;hp=fc3082e8cd4d6d0dd0df5ae5ccc11516f4ffce7a;hpb=c9825354a325085251df81dd6bc6dcdd37c70756;p=user%2Fhenk%2Fcode%2Fruby%2Frbot.git diff --git a/data/rbot/plugins/rss.rb b/data/rbot/plugins/rss.rb index fc3082e8..eb3fa5f8 100644 --- a/data/rbot/plugins/rss.rb +++ b/data/rbot/plugins/rss.rb @@ -162,21 +162,23 @@ module ::RSS end end + # Atom categories are squashed to their label only { :link => %w{link.href link}, :guid => %w{guid.content guid}, :content => %w{content.content content}, :description => %w{description.content description}, :title => %w{title.content title}, - :category => %w{category.content category}, + :category => %w{category.content category.label category}, :dc_subject => %w{dc_subject}, :author => %w{author.name.content author.name author}, :dc_creator => %w{dc_creator} }.each { |name, chain| def_bang name, chain } def categories! + return nil unless self.respond_to? :categories cats = categories.map do |c| - blank2nil { c.content rescue c rescue nil } + blank2nil { c.content rescue c.label rescue c rescue nil } end.compact cats.empty? ? nil : cats end @@ -779,15 +781,28 @@ class RSSFeedsPlugin < Plugin end case params[:what].intern when :handle - new = params[:new].downcase - if @feeds.key?(new) and @feeds[new] + # preserve rename case, but beware of key + realnew = params[:new] + new = realnew.downcase + if feed.handle.downcase == new + if feed.handle == realnew + m.reply _("You want me to rename %{handle} to itself?") % { + :handle => feed.handle + } + return false + else + feed.mutex.synchronize do + feed.handle = realnew + end + end + elsif @feeds.key?(new) and @feeds[new] m.reply "There already is a feed with handle #{new}" return else feed.mutex.synchronize do @feeds[new] = feed @feeds.delete(handle) - feed.handle = new + feed.handle = realnew end handle = new end @@ -926,7 +941,7 @@ class RSSFeedsPlugin < Plugin debug "fetching #{feed}" first_run = !feed.last_success - if (@bot.config['rss.announce_timeout'] > 0 && + if (!first_run && @bot.config['rss.announce_timeout'] > 0 && (Time.now - feed.last_success > @bot.config['rss.announce_timeout'])) debug "#{feed} wasn't polled for too long, supressing output" first_run = true