Class: IRC::StatefulClient
- Defined in:
- lib/rhuidean/stateful_client.rb
Overview
A StatefulClient builds on Client and tracks everything it does. This is useful for getting a head start on a bot.
Constant Summary
Constants included from Rhuidean
Rhuidean::VERSION, Rhuidean::V_MAJOR, Rhuidean::V_MINOR, Rhuidean::V_PATCH
Instance Attribute Summary collapse
-
#casemapping ⇒ Object
readonly
instance attributes.
-
#channel_modes ⇒ Object
readonly
instance attributes.
-
#channels ⇒ Object
readonly
instance attributes.
-
#eventq ⇒ Object
readonly
instance attributes.
-
#status_modes ⇒ Object
readonly
instance attributes.
-
#users ⇒ Object
readonly
Returns the value of attribute users.
Attributes inherited from Client
#bind_to, #nickname, #password, #port, #realname, #server, #socket, #thread, #username
Instance Method Summary collapse
-
#add_user(user) ⇒ Object
Adds a
StatefulUserto our known-users list. -
#delete_user(user) ⇒ Object
Removes a
StatefulUserfrom our known-users list, usually so it can die and be eaten by the GC. -
#initialize ⇒ StatefulClient
constructor
Creates a new
StatefulClient.
Methods inherited from Client
#connect, #connected?, #ctcp, #ctcp_reply, #dead?, #exit, #invite, #io_loop, #join, #kick, #mode, #nick, #notice, #on, #oper, #part, #pass, #privmsg, #quit, #raw, #to_s, #topic, #umode, #user
Methods included from Loggable
Constructor Details
#initialize ⇒ StatefulClient
Creates a new StatefulClient.
- returns
-
self
29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 |
# File 'lib/rhuidean/stateful_client.rb', line 29 def initialize # StatefulChannels keyed by channel name @channels = IRCHash.new(:rfc) # Known channel types, from RPL_ISUPPORT @channel_types = %w(# &) # Additional channel modes from RPL_ISUPPORT @channel_modes = {} # Additional status modes we get from RPL_ISUPPORT @status_modes = {} # StatefulUsers we know about, keyed by nickname @users = IRCHash.new(:rfc) super end |
Instance Attribute Details
#casemapping ⇒ Object (readonly)
instance attributes
21 22 23 |
# File 'lib/rhuidean/stateful_client.rb', line 21 def casemapping @casemapping end |
#channel_modes ⇒ Object (readonly)
instance attributes
21 22 23 |
# File 'lib/rhuidean/stateful_client.rb', line 21 def channel_modes @channel_modes end |
#channels ⇒ Object (readonly)
instance attributes
21 22 23 |
# File 'lib/rhuidean/stateful_client.rb', line 21 def channels @channels end |
#eventq ⇒ Object (readonly)
instance attributes
21 22 23 |
# File 'lib/rhuidean/stateful_client.rb', line 21 def eventq @eventq end |
#status_modes ⇒ Object (readonly)
instance attributes
21 22 23 |
# File 'lib/rhuidean/stateful_client.rb', line 21 def status_modes @status_modes end |
#users ⇒ Object (readonly)
Returns the value of attribute users.
22 23 24 |
# File 'lib/rhuidean/stateful_client.rb', line 22 def users @users end |
Instance Method Details
#add_user(user) ⇒ Object
Adds a StatefulUser to our known-users list.
- user
-
a
StatefulUser - returns
-
self
58 59 60 61 62 |
# File 'lib/rhuidean/stateful_client.rb', line 58 def add_user(user) @users[user.nickname] = user self end |
#delete_user(user) ⇒ Object
Removes a StatefulUser from our known-users list, usually so it can die and be eaten by the GC.
- user
-
either a
StatefulUseror the name of one - returns
-
self(nil on catestrophic failure)
71 72 73 74 75 76 77 78 79 80 81 |
# File 'lib/rhuidean/stateful_client.rb', line 71 def delete_user(user) if user.class == String @users.delete(user) self elsif user.class == StatefulUser @users.delete(user.nickname) self else nil end end |