From 81e0b9c7405c3731f6df1e50f6b32a35c224dfa7 Mon Sep 17 00:00:00 2001 From: Simon Hafner Date: Wed, 21 Jan 2009 21:58:02 +0100 Subject: + (userdata) method delete_botdata(key) --- lib/rbot/core/userdata.rb | 15 +++++++++++++++ 1 file changed, 15 insertions(+) (limited to 'lib') 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 -- cgit v1.2.3