From 7287bb0af9381403e8fad1d71e6e83f93b2bd276 Mon Sep 17 00:00:00 2001 From: Giuseppe Bilotta Date: Sun, 2 Sep 2007 17:17:35 +0000 Subject: New Auth Framework: introducing transient botusers --- lib/rbot/botuser.rb | 21 +++++++++++++++++---- 1 file changed, 17 insertions(+), 4 deletions(-) (limited to 'lib/rbot') diff --git a/lib/rbot/botuser.rb b/lib/rbot/botuser.rb index 6131a7b7..615b18d6 100644 --- a/lib/rbot/botuser.rb +++ b/lib/rbot/botuser.rb @@ -188,10 +188,14 @@ module Irc attr_reader :perm attr_writer :login_by_mask attr_writer :autologin + attr_accessor :transient # Create a new BotUser with given username - def initialize(username) - @username = BotUser.sanitize_username(username) + def initialize(username, options={}) + opts = {:transient => false}.merge(options) + @transient = opts[:transient] + @username = @transient ? "*" : "" + @username << BotUser.sanitize_username(username) @password = nil @netmasks = NetmaskList.new @perm = {} @@ -378,6 +382,14 @@ module Irc end + # A TransientBotUser is a BotUser that is not intended + # for permanent storage. + # + class TransientBotUser < BotUser + def initialize + super(object_id, :transient => true) + end + end # This is the default BotUser: it's used for all users which haven't # identified with the bot @@ -561,14 +573,15 @@ module Irc create_botuser(u) end get_botuser(u).from_hash(x) + get_botuser(u).transient = false } @has_changes=false end def save_array @allbotusers.values.map { |x| - x.to_hash - } + x.transient ? nil : x.to_hash + }.compact end # checks if we know about a certain BotUser username -- cgit v1.2.3