From: Giuseppe Bilotta Date: Thu, 25 Nov 2010 16:53:57 +0000 (+0100) Subject: rss: watch handle case during rename X-Git-Url: https://git.netwichtig.de/gitweb/?a=commitdiff_plain;h=a95675a1961cb5c205ba997c9f0599f453b19d4a;p=user%2Fhenk%2Fcode%2Fruby%2Frbot.git rss: watch handle case during rename We allow rss handles to be of any case on creation, even though matching is case-insentivie. However, when renaming an rss using 'rss change handle' and only changing the case, two things prevented this from working correctly: * since the new downcased handle was equal to the old downcased handle, the bot would prevent the renaming due to the existence of the new handle * the new handle was forcefully downcased, preventing the user from renaming handle 'case' to 'CaSe'. Fix by checking for this case explicitly, and handling it separately. --- diff --git a/data/rbot/plugins/rss.rb b/data/rbot/plugins/rss.rb index 3b09930a..eb3fa5f8 100644 --- a/data/rbot/plugins/rss.rb +++ b/data/rbot/plugins/rss.rb @@ -781,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