From 82ac675c1e0af29f276457dd7256ad0d800b9021 Mon Sep 17 00:00:00 2001 From: Giuseppe Bilotta Date: Tue, 4 Dec 2007 12:35:02 +0000 Subject: [PATCH] New Auth Framework: migrate userdata on permification --- lib/rbot/core/auth.rb | 2 ++ lib/rbot/core/userdata.rb | 25 +++++++++++++++++++------ 2 files changed, 21 insertions(+), 6 deletions(-) diff --git a/lib/rbot/core/auth.rb b/lib/rbot/core/auth.rb index 179044eb..d54e8177 100644 --- a/lib/rbot/core/auth.rb +++ b/lib/rbot/core/auth.rb @@ -539,8 +539,10 @@ class AuthModule < CoreBotModule # BotUser name buname = params[:user] || nick begin + call_event(:botuser,:pre_perm, {:irc_user => irc_user, :bot_user => buname}) met = @bot.auth.make_permanent(irc_user, buname) @bot.auth.set_changed + call_event(:botuser,:post_perm, {:irc_user => irc_user, :bot_user => buname}) m.reply @bot.lang.get('hello_X') % met @bot.say nick, _("you are now registered as %{buname}. I created a random password for you : %{pass} and you can change it at any time by telling me 'user set password ' in private" % { :buname => buname, diff --git a/lib/rbot/core/userdata.rb b/lib/rbot/core/userdata.rb index bfe71dd7..f4338592 100644 --- a/lib/rbot/core/userdata.rb +++ b/lib/rbot/core/userdata.rb @@ -153,12 +153,25 @@ class UserDataModule < CoreBotModule # end def event_botuser(action, opts={}) - return unless [:copy, :rename].include?(action) - source = opts[:source] - return unless @botuser.key?(source) - dest = opts[:dest] - @botuser[dest] = @botuser[source].dup - @botuser.delete(source) if action == :rename + case action + when :copy, :rename + source = opts[:source] + return unless @botuser.key?(source) + dest = opts[:dest] + @botuser[dest] = @botuser[source].dup + @botuser.delete(source) if action == :rename + when :pre_perm + @permification ||= {} + k = [opts[:irc_user], opts[:bot_user]] + @permification[k] = get_data_hash(opts[:irc_user]) + when :post_perm + @permification ||= {} + k = [opts[:irc_user], opts[:bot_user]] + if @permification.has_key?(k) + @botuser[opts[:bot_user]] = @permification[k] + @permification.delete(k) + end + end end end -- 2.39.5