From a1cb62bab38e6a5545356d885040bc744c2e5605 Mon Sep 17 00:00:00 2001 From: Jay Thomas Date: Thu, 25 Apr 2013 21:15:58 -0400 Subject: note: upgrade old registry keys on initialize --- data/rbot/plugins/note.rb | 22 +++++++++++++++++++--- 1 file changed, 19 insertions(+), 3 deletions(-) (limited to 'data/rbot') diff --git a/data/rbot/plugins/note.rb b/data/rbot/plugins/note.rb index 0c1683a6..227beaa7 100644 --- a/data/rbot/plugins/note.rb +++ b/data/rbot/plugins/note.rb @@ -9,10 +9,26 @@ # License:: MIT license class NotePlugin < Plugin + Note = Struct.new('Note', :time, :from, :private, :text) - def help(plugin, topic="") - "note => stores a note () for " + 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 => stores a note () for ' 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 -- cgit v1.2.3