diff options
author | Giuseppe Bilotta <giuseppe.bilotta@gmail.com> | 2007-12-04 12:35:02 +0000 |
---|---|---|
committer | Giuseppe Bilotta <giuseppe.bilotta@gmail.com> | 2007-12-04 12:35:02 +0000 |
commit | 82ac675c1e0af29f276457dd7256ad0d800b9021 (patch) | |
tree | 7230096eaba5650eb439961ddf58914e047d136c | |
parent | fd158900253be71240ac4e8c1f8035b85a09040f (diff) |
New Auth Framework: migrate userdata on permification
-rw-r--r-- | lib/rbot/core/auth.rb | 2 | ||||
-rw-r--r-- | 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 <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 |