X-Git-Url: https://git.netwichtig.de/gitweb/?a=blobdiff_plain;f=lib%2Frbot%2Fbotuser.rb;h=defb3a47afa9b119f7cbaeb626d41dce29d2cbc2;hb=43864ec494a9c2538934690f32eacb8bfb5cc921;hp=a710a86375d65395accbab83bb51baaa271cc721;hpb=478abdd11956f5de0d8250cd2dbe44e8a104c4d1;p=user%2Fhenk%2Fcode%2Fruby%2Frbot.git diff --git a/lib/rbot/botuser.rb b/lib/rbot/botuser.rb index a710a863..defb3a47 100644 --- a/lib/rbot/botuser.rb +++ b/lib/rbot/botuser.rb @@ -182,6 +182,9 @@ class Bot # def permit?(str) cmd = str.to_irc_auth_command + # TODO user-configurable list of always-allowed commands, + # for admins that want to set permissions -* for everybody + return true if cmd.command == :login allow = nil cmd.path.reverse.each { |k| if @perm.has_key?(k) @@ -267,7 +270,7 @@ class Bot # Make the BotUser permanent def make_permanent(name) - raise TypError, "permanent already" if permanent? + raise TypeError, "permanent already" if permanent? @username = BotUser.sanitize_username(name) @transient = false reset_autologin @@ -318,7 +321,7 @@ class Bot # Inspection def inspect - str = "<#{self.class}:#{'0x%08x' % self.object_id}" + str = self.__to_s__[0..-2] str << " (transient)" if @transient str << ":" str << " @username=#{@username.inspect}" @@ -601,6 +604,19 @@ class Bot end + class BotUser + # Check if the current BotUser is the default one + def default? + return DefaultBotUserClass === self + end + + # Check if the current BotUser is the owner + def owner? + return BotOwnerClass === self + end + end + + # This is the ManagerClass singleton, used to manage # Irc::User/Irc::Bot::Auth::BotUser connections and everything # @@ -794,8 +810,9 @@ class Bot # BotUser (if any) it's logged in as # def make_permanent(user, name) + buname = BotUser.sanitize_username(name) # TODO merge BotUser instead? - raise "there's already a BotUser called #{name}" if include?(name) + raise "there's already a BotUser called #{name}" if include?(buname) tuser = nil case user @@ -809,7 +826,7 @@ class Bot return nil unless tuser raise TypeError, "#{tuser} is not transient" unless tuser.transient? - tuser.make_permanent(name) + tuser.make_permanent(buname) @allbotusers[tuser.username.to_sym] = tuser return tuser