diff options
author | Giuseppe Bilotta <giuseppe.bilotta@gmail.com> | 2007-09-02 17:17:35 +0000 |
---|---|---|
committer | Giuseppe Bilotta <giuseppe.bilotta@gmail.com> | 2007-09-02 17:17:35 +0000 |
commit | 7287bb0af9381403e8fad1d71e6e83f93b2bd276 (patch) | |
tree | b803e04903c1a984044d608cc887588a92db5f9b | |
parent | 3fbe5309c69bff7ed5456b196f974c7aa3dfb868 (diff) |
New Auth Framework: introducing transient botusers
-rw-r--r-- | lib/rbot/botuser.rb | 21 |
1 files changed, 17 insertions, 4 deletions
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
|