#\r
def permit?(str)\r
cmd = str.to_irc_auth_command\r
+ # TODO user-configurable list of always-allowed commands,\r
+ # for admins that want to set permissions -* for everybody\r
+ return true if cmd.command == :login\r
allow = nil\r
cmd.path.reverse.each { |k|\r
if @perm.has_key?(k)\r
\r
# Make the BotUser permanent\r
def make_permanent(name)\r
- raise TypError, "permanent already" if permanent?\r
+ raise TypeError, "permanent already" if permanent?\r
@username = BotUser.sanitize_username(name)\r
@transient = false\r
reset_autologin\r
\r
# Inspection\r
def inspect\r
- str = "<#{self.class}:#{'0x%08x' % self.object_id}"\r
+ str = self.__to_s__[0..-2]\r
str << " (transient)" if @transient\r
str << ":"\r
str << " @username=#{@username.inspect}"\r
end\r
\r
\r
+ class BotUser\r
+ # Check if the current BotUser is the default one\r
+ def default?\r
+ return DefaultBotUserClass === self\r
+ end\r
+\r
+ # Check if the current BotUser is the owner\r
+ def owner?\r
+ return BotOwnerClass === self\r
+ end\r
+ end\r
+\r
+\r
# This is the ManagerClass singleton, used to manage\r
# Irc::User/Irc::Bot::Auth::BotUser connections and everything\r
#\r
# BotUser (if any) it's logged in as\r
#\r
def make_permanent(user, name)\r
+ buname = BotUser.sanitize_username(name)\r
# TODO merge BotUser instead?\r
- raise "there's already a BotUser called #{name}" if include?(name)\r
+ raise "there's already a BotUser called #{name}" if include?(buname)\r
\r
tuser = nil\r
case user\r
return nil unless tuser\r
raise TypeError, "#{tuser} is not transient" unless tuser.transient?\r
\r
- tuser.make_permanent(name)\r
+ tuser.make_permanent(buname)\r
@allbotusers[tuser.username.to_sym] = tuser\r
\r
return tuser\r