]> git.netwichtig.de Git - user/henk/code/ruby/rbot.git/commitdiff
note: upgrade old registry keys on initialize
authorJay Thomas <degradinglight@gmail.com>
Fri, 26 Apr 2013 01:15:58 +0000 (21:15 -0400)
committerGiuseppe Bilotta <giuseppe.bilotta@gmail.com>
Fri, 26 Apr 2013 06:24:54 +0000 (08:24 +0200)
data/rbot/plugins/note.rb

index 0c1683a6e0b813c4f0f25673cd8ba3b808df1465..227beaa7e5bd46f22be3bb162270c8d6a8b7552d 100644 (file)
@@ -9,10 +9,26 @@
 # License:: MIT license
 
 class NotePlugin < Plugin
+
   Note = Struct.new('Note', :time, :from, :private, :text)
 
-  def help(plugin, topic="")
-    "note <nick> <string> => stores a note (<string>) for <nick>"
+  def initialize
+    super
+    return if @registry.nil? or @registry.length < 1
+    debug 'Checking registry for old-formatted notes...'
+    n = 0
+    @registry.dup.each_key do |key|
+      unless key == key.downcase
+        @registry[key.downcase] = @registry[key] + @registry[key.downcase]
+        @registry.delete key
+        n += 1
+      end
+    end
+    debug "#{n} entries converted and merged."
+  end
+
+  def help(plugin, topic='')
+    'note <nick> <string> => stores a note (<string>) for <nick>'
   end
 
   def message(m)
@@ -33,7 +49,7 @@ class NotePlugin < Plugin
       end
 
       if !priv.empty?
-        @bot.say m.sourcenick, "you have notes! " + priv.join(' ')
+        @bot.say m.sourcenick, 'you have notes! ' + priv.join(' ')
       end
       @registry.delete nick
     rescue Exception => e