From b276236fed7673ec427b64dd57f6cb05d0784ebf Mon Sep 17 00:00:00 2001 From: Giuseppe Bilotta Date: Mon, 24 Sep 2007 08:08:37 +0000 Subject: core/userdata: store transient data too, keyed by (first-and-only) netmask --- lib/rbot/core/userdata.rb | 14 +++++++++++--- 1 file changed, 11 insertions(+), 3 deletions(-) (limited to 'lib') diff --git a/lib/rbot/core/userdata.rb b/lib/rbot/core/userdata.rb index 8a056820..34ed48ad 100644 --- a/lib/rbot/core/userdata.rb +++ b/lib/rbot/core/userdata.rb @@ -52,6 +52,7 @@ class UserDataModule < CoreBotModule def initialize super @ircuser = @registry.sub_registry('ircuser') + @transient = @registry.sub_registry('transient') @botuser = @registry.sub_registry('botuser') end @@ -61,12 +62,14 @@ class UserDataModule < CoreBotModule ih = @ircuser[iu.nick] || {} - if bu.transient? or bu.default? + if bu.default? return ih + elsif bu.transient? + bh = @transient[bu.netmasks.first.fullform] || {} else bh = @botuser[bu.username] || {} - return ih.merge! bh end + return ih.merge! bh end def get_data(user, key=nil) @@ -81,9 +84,14 @@ class UserDataModule < CoreBotModule bu = iu.botuser @ircuser[iu.nick] = h - unless bu.transient? or bu.default? + return h if bu.default? + + if bu.transient? + @transient[bu.netmasks.first.fullform] = h + else @botuser[bu.username] = h end + return h end def set_data(user, key, value=nil, &block) -- cgit v1.2.3