X-Git-Url: https://git.netwichtig.de/gitweb/?a=blobdiff_plain;ds=sidebyside;f=lib%2Frbot%2Fbotuser.rb;h=83fb26240333a0456a743fe662b3c61f26ebce01;hb=b1debac35f5e45545066da07027ddaaf6c9faca7;hp=146912b43587093325e4625fe6ae02c0df73fb4e;hpb=6f5528a63b44e610a3d25d7fe583399163d7d2da;p=user%2Fhenk%2Fcode%2Fruby%2Frbot.git diff --git a/lib/rbot/botuser.rb b/lib/rbot/botuser.rb index 146912b4..83fb2624 100644 --- a/lib/rbot/botuser.rb +++ b/lib/rbot/botuser.rb @@ -19,7 +19,7 @@ require 'set' # class_eval { # define_method(m) { |*a| # r = super(*a) -# Irc::Bot::Auth.authmanager.set_changed +# Irc::Bot::Auth.manager.set_changed # r # } # } @@ -236,7 +236,7 @@ class Bot attr_reader :password attr_reader :netmasks attr_reader :perm - # Please remember to #set_changed() the authmanager + # Please remember to #set_changed() the Auth.manager # when modifying data attr_reader :data attr_writer :login_by_mask @@ -344,13 +344,13 @@ class Bot # Reset the login-by-mask option # def reset_login_by_mask - @login_by_mask = Auth.authmanager.bot.config['auth.login_by_mask'] unless defined?(@login_by_mask) + @login_by_mask = Auth.manager.bot.config['auth.login_by_mask'] unless defined?(@login_by_mask) end # Reset the autologin option # def reset_autologin - @autologin = Auth.authmanager.bot.config['auth.autologin'] unless defined?(@autologin) + @autologin = Auth.manager.bot.config['auth.autologin'] unless defined?(@autologin) end # Do we allow automatic logging in? @@ -601,10 +601,10 @@ class Bot end - # This is the AuthManagerClass singleton, used to manage User/BotUser connections and - # everything + # This is the ManagerClass singleton, used to manage + # Irc::User/Irc::Bot::Auth::BotUser connections and everything # - class AuthManagerClass + class ManagerClass include Singleton @@ -757,13 +757,21 @@ class Bot end # Creates a new transient BotUser associated with Irc::User _user_, - # automatically logging him in + # automatically logging him in. Note that transient botuser creation can + # fail, typically if we don't have the complete user netmask (e.g. for + # messages coming in from a linkbot) # def create_transient_botuser(user) ircuser = user.to_irc_user - bu = BotUser.new(ircuser, :transient => true, :masks => ircuser) - bu.login(ircuser) - @transients << bu + bu = everyone + begin + bu = BotUser.new(ircuser, :transient => true, :masks => ircuser) + bu.login(ircuser) + @transients << bu + rescue + warning "failed to create transient for #{user}" + error $! + end return bu end @@ -826,10 +834,10 @@ class Bot end - # Returns the only instance of AuthManagerClass + # Returns the only instance of ManagerClass # - def Auth.authmanager - return AuthManagerClass.instance + def Auth.manager + return ManagerClass.instance end end @@ -841,7 +849,7 @@ end # associated with the receiver # def botuser - Irc::Bot::Auth.authmanager.irc_to_botuser(self) + Irc::Bot::Auth.manager.irc_to_botuser(self) end # Bot-specific data can be stored with Irc::Users. This is @@ -867,7 +875,7 @@ end def set_bot_data(key,value=nil,&block) if not block_given? self.botuser.data[key]=value - Irc::Bot::Auth.authmanager.set_changed + Irc::Bot::Auth.manager.set_changed return value end if value and not bot_data.has_key?(key) @@ -877,7 +885,7 @@ end begin r = yield bot_data(key) ensure - Irc::Bot::Auth.authmanager.set_changed + Irc::Bot::Auth.manager.set_changed end return r end