Class: Cinch::UserList
- Inherits:
-
CachedList
- Object
- CachedList
- Cinch::UserList
- Defined in:
- lib/cinch/user_list.rb
Overview
Note:
In prior versions, this class was called UserManager
Instance Method Summary collapse
-
#delete(user)
private
-
#find(nick) ⇒ User?
Finds a user.
-
#find_ensured(*args) ⇒ User
Finds or creates a user.
-
#update_nick(user)
private
Methods inherited from CachedList
Constructor Details
This class inherits a constructor from Cinch::CachedList
Instance Method Details
#delete(user)
This method is part of a private API. You should avoid using this method if possible, as it may be removed or be changed in the future.
This method returns an undefined value.
80 81 82 |
# File 'lib/cinch/user_list.rb', line 80 def delete(user) @cache.delete_if { |_n, u| u == user } end |
#find(nick) ⇒ User?
Finds a user.
60 61 62 63 64 65 66 67 |
# File 'lib/cinch/user_list.rb', line 60 def find(nick) return @bot if nick == @bot.nick downcased_nick = nick.irc_downcase(@bot.irc.isupport["CASEMAPPING"]) @mutex.synchronize do return @cache[downcased_nick] end end |
#find_ensured(nick) ⇒ User #find_ensured(user, nick, host) ⇒ User
Finds or creates a user.
26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 |
# File 'lib/cinch/user_list.rb', line 26 def find_ensured(*args) user = nil host = nil case args.size when 1 nick = args.first = [nick] when 3 nick = args[1] = args user, _, host = else raise ArgumentError end user_obj = @bot if nick == @bot.nick downcased_nick = nick.irc_downcase(@bot.irc.isupport["CASEMAPPING"]) @mutex.synchronize do user_obj = @cache[downcased_nick] ||= User.new(*, @bot) if user_obj.nil? if user && host # Explicitly set user and host whenever we request a User # object to update them on e.g. JOIN. user_obj.sync(:user, user, true) user_obj.sync(:host, host, true) end user_obj end end |
#update_nick(user)
This method is part of a private API. You should avoid using this method if possible, as it may be removed or be changed in the future.
This method returns an undefined value.
71 72 73 74 75 76 |
# File 'lib/cinch/user_list.rb', line 71 def update_nick(user) @mutex.synchronize do @cache.delete user.last_nick.irc_downcase(@bot.irc.isupport["CASEMAPPING"]) @cache[user.nick.irc_downcase(@bot.irc.isupport["CASEMAPPING"])] = user end end |