From e4d2961c1e0af6330ba49252ed0245a98514a270 Mon Sep 17 00:00:00 2001 From: Giuseppe Bilotta Date: Mon, 24 Sep 2007 08:08:33 +0000 Subject: core/userdata: refactor set_data_hash method --- lib/rbot/core/userdata.rb | 27 +++++++++++++-------------- 1 file changed, 13 insertions(+), 14 deletions(-) (limited to 'lib') diff --git a/lib/rbot/core/userdata.rb b/lib/rbot/core/userdata.rb index 844a6c58..0164f659 100644 --- a/lib/rbot/core/userdata.rb +++ b/lib/rbot/core/userdata.rb @@ -76,6 +76,17 @@ class UserDataModule < CoreBotModule return h[key] end + def set_data_hash(user, h) + iu = user.to_irc_user + bu = iu.botuser + + if bu.transient? or bu.default? + @ircuser[iu.nick] = h + else + @botuser[bu.username] = h + end + end + def set_data(user, key, value=nil, &block) h = get_data_hash(user) debug h @@ -92,14 +103,8 @@ class UserDataModule < CoreBotModule end debug ret - iu = user.to_irc_user - bu = iu.botuser + set_data_hash(user, h) - if bu.transient? or bu.default? - @ircuser[iu.nick] = h - else - @botuser[bu.username] = h - end return ret end @@ -108,14 +113,8 @@ class UserDataModule < CoreBotModule debug h yield h - iu = user.to_irc_user - bu = iu.botuser + set_data_hash(user, h) - if bu.transient? or bu.default? - @ircuser[iu.nick] = h - else - @botuser[bu.username] = h - end return h end -- cgit v1.2.3