diff options
-rw-r--r-- | lib/rbot/core/userdata.rb | 15 |
1 files changed, 15 insertions, 0 deletions
diff --git a/lib/rbot/core/userdata.rb b/lib/rbot/core/userdata.rb index a08285f4..2b142bee 100644 --- a/lib/rbot/core/userdata.rb +++ b/lib/rbot/core/userdata.rb @@ -38,6 +38,13 @@ module ::Irc Irc::Utils.bot.plugins['userdata'].with_data(self, &block) end + # This method removes the data associated with the key, returning + # the value of the deleted key. + + def delete_botdata(*keys) + Irc::Utils.bot.plugins['userdata'].delete_data(self, *keys) + end + end end @@ -138,6 +145,14 @@ class UserDataModule < CoreBotModule return h end + def delete_data(user, *keys) + h = get_data_hash(user) + debug h + rv = keys.map { |k| h.delete k } + set_data_hash(user, h) + rv.size == 1 ? rv.first : rv + end + def handle_get(m, params) user = m.server.get_user(params[:nick]) || m.source key = params[:key].intern |