diff options
-rw-r--r-- | lib/rbot/core/auth.rb | 10 | ||||
-rw-r--r-- | lib/rbot/core/userdata.rb | 9 |
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 |