summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorGiuseppe Bilotta <giuseppe.bilotta@gmail.com>2010-11-25 17:53:57 +0100
committerGiuseppe Bilotta <giuseppe.bilotta@gmail.com>2010-11-25 17:53:57 +0100
commita95675a1961cb5c205ba997c9f0599f453b19d4a (patch)
treee82726c7c5eb75a9f14079aad5119c3a6695fab4
parentd39aeaf236b8d2865df642b6f8a1070a4a41acf2 (diff)
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.
-rw-r--r--data/rbot/plugins/rss.rb19
1 files changed, 16 insertions, 3 deletions
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