summaryrefslogtreecommitdiff
path: root/lib
diff options
context:
space:
mode:
authorGiuseppe Bilotta <giuseppe.bilotta@gmail.com>2007-12-04 11:34:15 +0000
committerGiuseppe Bilotta <giuseppe.bilotta@gmail.com>2007-12-04 11:34:15 +0000
commitfd158900253be71240ac4e8c1f8035b85a09040f (patch)
treee5070164fbad2fcb5d3c120e5d0db1ea62f91ac7 /lib
parent8c59761859a6f77483efb1ea04911ff653b4a0f6 (diff)
New Auth Framework: migrate userdata on botuser copy/rename
Diffstat (limited to 'lib')
-rw-r--r--lib/rbot/core/auth.rb10
-rw-r--r--lib/rbot/core/userdata.rb9
2 files changed, 16 insertions, 3 deletions
diff --git a/lib/rbot/core/auth.rb b/lib/rbot/core/auth.rb
index 0d78bdfb..179044eb 100644
--- a/lib/rbot/core/auth.rb
+++ b/lib/rbot/core/auth.rb
@@ -683,13 +683,17 @@ class AuthModule < CoreBotModule
@bot.auth.load_array(buser_array, true)
@bot.auth.set_changed
+ call_event(:botuser, copying ? :copy : :rename, :source => source, :dest => dest)
rescue => e
return m.reply(_("failed: %{exception}") % {:exception=>e})
end
- return m.reply(_("botuser %{source} copied to %{dest}") %
- {:source=>source, :dest=>dest}) if copying
- return m.reply(_("botuser %{source} renamed to %{dest}") %
+ if copying
+ m.reply(_("botuser %{source} copied to %{dest}") %
{:source=>source, :dest=>dest})
+ else
+ m.reply(_("botuser %{source} renamed to %{dest}") %
+ {:source=>source, :dest=>dest})
+ end
end
diff --git a/lib/rbot/core/userdata.rb b/lib/rbot/core/userdata.rb
index 96995724..bfe71dd7 100644
--- a/lib/rbot/core/userdata.rb
+++ b/lib/rbot/core/userdata.rb
@@ -152,6 +152,15 @@ class UserDataModule < CoreBotModule
# data = params[:data].to_s
# 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
+ end
+
end
plugin = UserDataModule.new