diff options
author | Simon Hafner <hafnersimon@gmail.com> | 2009-01-21 21:58:02 +0100 |
---|---|---|
committer | dmitry kim <jason@nichego.net> | 2009-01-22 04:58:10 +0300 |
commit | 81e0b9c7405c3731f6df1e50f6b32a35c224dfa7 (patch) | |
tree | 96678a9b0ca8524004516cdcf1412bc1816a1c7a | |
parent | 750f579b6ad2683abd50b51392e29dd1291d4d7e (diff) |
+ (userdata) method delete_botdata(key)
-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 |