diff options
author | Giuseppe Bilotta <giuseppe.bilotta@gmail.com> | 2007-09-04 01:50:37 +0000 |
---|---|---|
committer | Giuseppe Bilotta <giuseppe.bilotta@gmail.com> | 2007-09-04 01:50:37 +0000 |
commit | 0d5d3a20e1185e162102c7b8bea87962729f910a (patch) | |
tree | 3ad842ddc15085cc131ec956f8218fee95cb35bb /lib/rbot | |
parent | e1227011b1fd4dbba1aaa93b5f5b9032c92c1db0 (diff) |
New Auth Framework, New Irc Framework: convenience methods for Irc::User to retrieve the associated BotUser and its data
Diffstat (limited to 'lib/rbot')
-rw-r--r-- | lib/rbot/botuser.rb | 19 | ||||
-rw-r--r-- | lib/rbot/message.rb | 2 |
2 files changed, 19 insertions, 2 deletions
diff --git a/lib/rbot/botuser.rb b/lib/rbot/botuser.rb index fe28947b..dc019655 100644 --- a/lib/rbot/botuser.rb +++ b/lib/rbot/botuser.rb @@ -217,10 +217,10 @@ module Irc attr_reader :password
attr_reader :netmasks
attr_reader :perm
+ attr_reader :data
attr_writer :login_by_mask
attr_writer :autologin
attr_writer :transient
- attr_accessor :data
# Checks if the BotUser is transient
def transient?
@@ -810,4 +810,21 @@ module Irc end
+ class User
+
+ # A convenience method to automatically found the botuser
+ # associated with the receiver
+ #
+ def botuser
+ Irc::Auth.authmanager.irc_to_botuser(self)
+ end
+
+ # The botuser is used to store data associated with the
+ # given Irc::User
+ #
+ def data
+ self.botuser.data
+ end
+ end
+
end
diff --git a/lib/rbot/message.rb b/lib/rbot/message.rb index 6331825d..969dbc7d 100644 --- a/lib/rbot/message.rb +++ b/lib/rbot/message.rb @@ -167,7 +167,7 @@ module Irc # Access the botuser corresponding to the source, if any # def botuser - @bot.auth.autologin(@source) rescue @bot.auth.everyone + m.source.botuser rescue @bot.auth.everyone end |