Class: Syndi::IRC::State::Support
- Inherits:
-
Object
- Object
- Syndi::IRC::State::Support
- Defined in:
- lib/syndi/irc/state/support.rb
Overview
A state-management class which records the various capabilities of the IRC daemon.
Instance Attribute Summary collapse
-
#cap ⇒ Array<String>
A list of enabled capabilities.
-
#chan_modes ⇒ Hash{Symbol => Array<Symbol>}
The list of channel modes supported.
-
#chanlen ⇒ Integer
The maximum length of a channel's name permissible.
-
#connected ⇒ Boolean
Whether we are connected and registered.
-
#modelen ⇒ Integer
The maximum number of modes permissible in a single /MODE.
-
#nicklen ⇒ Integer
The maximum length of a nickname permissible.
-
#prefixes ⇒ Hash{Symbol => String}
The list of channel user prefixes supported.
-
#sasl_id ⇒ Array<String>
Identities of SASL-related timers.
-
#sasl_method ⇒ Symbol
Method of SASL authentication (+:plain+ or +:dh_blowfish+).
-
#server_name ⇒ String
Name of the server to which we are connected (e.g. asimov.freenode.net).
-
#topiclen ⇒ Integer
The maximum length of a /TOPIC permissible.
Instance Method Summary collapse
-
#initialize ⇒ Support
constructor
A new instance of Support.
-
#isupport(irc, data) ⇒ Object
Process ISUPPORT data.
-
#parse_channel_modes(data) ⇒ Object
private
Parse supported channel modes.
-
#parse_prefixes(data) ⇒ Object
private
Parse supported prefixes.
Constructor Details
#initialize ⇒ Support
Returns a new instance of Support.
51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 |
# File 'lib/syndi/irc/state/support.rb', line 51 def initialize # hashes %w[chan_modes prefixes].each do |hsh| instance_variable_set("@#{hsh}", {}) end # arrays %w[cap sasl_id].each do |arr| instance_variable_set("@#{arr}", []) end # strings/symbols/booleans/integers %w[sasl_method server_name nicklen topiclen modelen chanlen connected].each do |str| instance_variable_set("@#{str}", nil) end end |
Instance Attribute Details
#cap ⇒ Array<String>
Returns A list of enabled capabilities.
46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 91 92 93 94 95 96 97 98 99 100 101 102 103 104 105 106 107 108 109 110 111 112 113 114 115 116 117 118 119 120 121 122 123 124 125 126 127 128 129 130 131 132 133 134 |
# File 'lib/syndi/irc/state/support.rb', line 46 class Support attr_accessor :cap, :sasl_method, :sasl_id, :server_name, :nicklen, :prefixes, :chan_modes, :modelen, :topiclen, :chanlen, :connected def initialize # hashes %w[chan_modes prefixes].each do |hsh| instance_variable_set("@#{hsh}", {}) end # arrays %w[cap sasl_id].each do |arr| instance_variable_set("@#{arr}", []) end # strings/symbols/booleans/integers %w[sasl_method server_name nicklen topiclen modelen chanlen connected].each do |str| instance_variable_set("@#{str}", nil) end end # Process ISUPPORT data. # # @param [Syndi::IRC::Server] irc The IRC connection. # @param [String] data The ISUPPORT data string. def isupport irc, data # Nick, channel, topic, and mode length {'@nicklen' => 'NICKLEN', '@chanlen' => 'CHANNELLEN', '@topiclen' => 'TOPICLEN', '@modelen' => 'MODES' }.each_pair do |var, indic| if data =~ /#{indic}=(\d+)/ instance_variable_set(var, $1.to_i) end end # Parse channel modes. parse_channel_modes data # Parse prefixes. parse_prefixes data end ####### private ####### # Parse supported channel modes. # # @param [String] data The data string. def parse_channel_modes data if match = %r{\WCHANMODES=(\w+),(\w+),(\w+),(\w+)\W}.match(data) list = match[1].split // || [] always = match[2].split // || [] set = match[3].split // || [] never = match[4].split // || [] list.map! { |m| m.to_sym } always.map! { |m| m.to_sym } set.map! { |m| m.to_sym } never.map! { |m| m.to_sym } { list: list, always: always, set: set, never: never } end end # Parse supported prefixes. # # @param [String] data The data string. def parse_prefixes data if match = %r{\WPREFIX=\((\w+)\)(\W+)\s}.match(data) modes = match[1].split // prefixes = match[2].split // modes.map! { |m| m.to_sym } i = 0 modes.each do |m| @prefixes[m] = prefixes[i] i += 1 end end end end |
#chan_modes ⇒ Hash{Symbol => Array<Symbol>}
Returns The list of channel modes supported. The keys are +:never+, +:list+, +:set+, and +:always+. List: list mode (e.g. +b). Never: never has a parameter. Set: has a parameter only when set. Always: always has a parameter.
46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 91 92 93 94 95 96 97 98 99 100 101 102 103 104 105 106 107 108 109 110 111 112 113 114 115 116 117 118 119 120 121 122 123 124 125 126 127 128 129 130 131 132 133 134 |
# File 'lib/syndi/irc/state/support.rb', line 46 class Support attr_accessor :cap, :sasl_method, :sasl_id, :server_name, :nicklen, :prefixes, :chan_modes, :modelen, :topiclen, :chanlen, :connected def initialize # hashes %w[chan_modes prefixes].each do |hsh| instance_variable_set("@#{hsh}", {}) end # arrays %w[cap sasl_id].each do |arr| instance_variable_set("@#{arr}", []) end # strings/symbols/booleans/integers %w[sasl_method server_name nicklen topiclen modelen chanlen connected].each do |str| instance_variable_set("@#{str}", nil) end end # Process ISUPPORT data. # # @param [Syndi::IRC::Server] irc The IRC connection. # @param [String] data The ISUPPORT data string. def isupport irc, data # Nick, channel, topic, and mode length {'@nicklen' => 'NICKLEN', '@chanlen' => 'CHANNELLEN', '@topiclen' => 'TOPICLEN', '@modelen' => 'MODES' }.each_pair do |var, indic| if data =~ /#{indic}=(\d+)/ instance_variable_set(var, $1.to_i) end end # Parse channel modes. parse_channel_modes data # Parse prefixes. parse_prefixes data end ####### private ####### # Parse supported channel modes. # # @param [String] data The data string. def parse_channel_modes data if match = %r{\WCHANMODES=(\w+),(\w+),(\w+),(\w+)\W}.match(data) list = match[1].split // || [] always = match[2].split // || [] set = match[3].split // || [] never = match[4].split // || [] list.map! { |m| m.to_sym } always.map! { |m| m.to_sym } set.map! { |m| m.to_sym } never.map! { |m| m.to_sym } { list: list, always: always, set: set, never: never } end end # Parse supported prefixes. # # @param [String] data The data string. def parse_prefixes data if match = %r{\WPREFIX=\((\w+)\)(\W+)\s}.match(data) modes = match[1].split // prefixes = match[2].split // modes.map! { |m| m.to_sym } i = 0 modes.each do |m| @prefixes[m] = prefixes[i] i += 1 end end end end |
#chanlen ⇒ Integer
Returns The maximum length of a channel's name permissible.
46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 91 92 93 94 95 96 97 98 99 100 101 102 103 104 105 106 107 108 109 110 111 112 113 114 115 116 117 118 119 120 121 122 123 124 125 126 127 128 129 130 131 132 133 134 |
# File 'lib/syndi/irc/state/support.rb', line 46 class Support attr_accessor :cap, :sasl_method, :sasl_id, :server_name, :nicklen, :prefixes, :chan_modes, :modelen, :topiclen, :chanlen, :connected def initialize # hashes %w[chan_modes prefixes].each do |hsh| instance_variable_set("@#{hsh}", {}) end # arrays %w[cap sasl_id].each do |arr| instance_variable_set("@#{arr}", []) end # strings/symbols/booleans/integers %w[sasl_method server_name nicklen topiclen modelen chanlen connected].each do |str| instance_variable_set("@#{str}", nil) end end # Process ISUPPORT data. # # @param [Syndi::IRC::Server] irc The IRC connection. # @param [String] data The ISUPPORT data string. def isupport irc, data # Nick, channel, topic, and mode length {'@nicklen' => 'NICKLEN', '@chanlen' => 'CHANNELLEN', '@topiclen' => 'TOPICLEN', '@modelen' => 'MODES' }.each_pair do |var, indic| if data =~ /#{indic}=(\d+)/ instance_variable_set(var, $1.to_i) end end # Parse channel modes. parse_channel_modes data # Parse prefixes. parse_prefixes data end ####### private ####### # Parse supported channel modes. # # @param [String] data The data string. def parse_channel_modes data if match = %r{\WCHANMODES=(\w+),(\w+),(\w+),(\w+)\W}.match(data) list = match[1].split // || [] always = match[2].split // || [] set = match[3].split // || [] never = match[4].split // || [] list.map! { |m| m.to_sym } always.map! { |m| m.to_sym } set.map! { |m| m.to_sym } never.map! { |m| m.to_sym } { list: list, always: always, set: set, never: never } end end # Parse supported prefixes. # # @param [String] data The data string. def parse_prefixes data if match = %r{\WPREFIX=\((\w+)\)(\W+)\s}.match(data) modes = match[1].split // prefixes = match[2].split // modes.map! { |m| m.to_sym } i = 0 modes.each do |m| @prefixes[m] = prefixes[i] i += 1 end end end end |
#connected ⇒ Boolean
Returns Whether we are connected and registered.
46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 91 92 93 94 95 96 97 98 99 100 101 102 103 104 105 106 107 108 109 110 111 112 113 114 115 116 117 118 119 120 121 122 123 124 125 126 127 128 129 130 131 132 133 134 |
# File 'lib/syndi/irc/state/support.rb', line 46 class Support attr_accessor :cap, :sasl_method, :sasl_id, :server_name, :nicklen, :prefixes, :chan_modes, :modelen, :topiclen, :chanlen, :connected def initialize # hashes %w[chan_modes prefixes].each do |hsh| instance_variable_set("@#{hsh}", {}) end # arrays %w[cap sasl_id].each do |arr| instance_variable_set("@#{arr}", []) end # strings/symbols/booleans/integers %w[sasl_method server_name nicklen topiclen modelen chanlen connected].each do |str| instance_variable_set("@#{str}", nil) end end # Process ISUPPORT data. # # @param [Syndi::IRC::Server] irc The IRC connection. # @param [String] data The ISUPPORT data string. def isupport irc, data # Nick, channel, topic, and mode length {'@nicklen' => 'NICKLEN', '@chanlen' => 'CHANNELLEN', '@topiclen' => 'TOPICLEN', '@modelen' => 'MODES' }.each_pair do |var, indic| if data =~ /#{indic}=(\d+)/ instance_variable_set(var, $1.to_i) end end # Parse channel modes. parse_channel_modes data # Parse prefixes. parse_prefixes data end ####### private ####### # Parse supported channel modes. # # @param [String] data The data string. def parse_channel_modes data if match = %r{\WCHANMODES=(\w+),(\w+),(\w+),(\w+)\W}.match(data) list = match[1].split // || [] always = match[2].split // || [] set = match[3].split // || [] never = match[4].split // || [] list.map! { |m| m.to_sym } always.map! { |m| m.to_sym } set.map! { |m| m.to_sym } never.map! { |m| m.to_sym } { list: list, always: always, set: set, never: never } end end # Parse supported prefixes. # # @param [String] data The data string. def parse_prefixes data if match = %r{\WPREFIX=\((\w+)\)(\W+)\s}.match(data) modes = match[1].split // prefixes = match[2].split // modes.map! { |m| m.to_sym } i = 0 modes.each do |m| @prefixes[m] = prefixes[i] i += 1 end end end end |
#modelen ⇒ Integer
Returns The maximum number of modes permissible in a single /MODE.
46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 91 92 93 94 95 96 97 98 99 100 101 102 103 104 105 106 107 108 109 110 111 112 113 114 115 116 117 118 119 120 121 122 123 124 125 126 127 128 129 130 131 132 133 134 |
# File 'lib/syndi/irc/state/support.rb', line 46 class Support attr_accessor :cap, :sasl_method, :sasl_id, :server_name, :nicklen, :prefixes, :chan_modes, :modelen, :topiclen, :chanlen, :connected def initialize # hashes %w[chan_modes prefixes].each do |hsh| instance_variable_set("@#{hsh}", {}) end # arrays %w[cap sasl_id].each do |arr| instance_variable_set("@#{arr}", []) end # strings/symbols/booleans/integers %w[sasl_method server_name nicklen topiclen modelen chanlen connected].each do |str| instance_variable_set("@#{str}", nil) end end # Process ISUPPORT data. # # @param [Syndi::IRC::Server] irc The IRC connection. # @param [String] data The ISUPPORT data string. def isupport irc, data # Nick, channel, topic, and mode length {'@nicklen' => 'NICKLEN', '@chanlen' => 'CHANNELLEN', '@topiclen' => 'TOPICLEN', '@modelen' => 'MODES' }.each_pair do |var, indic| if data =~ /#{indic}=(\d+)/ instance_variable_set(var, $1.to_i) end end # Parse channel modes. parse_channel_modes data # Parse prefixes. parse_prefixes data end ####### private ####### # Parse supported channel modes. # # @param [String] data The data string. def parse_channel_modes data if match = %r{\WCHANMODES=(\w+),(\w+),(\w+),(\w+)\W}.match(data) list = match[1].split // || [] always = match[2].split // || [] set = match[3].split // || [] never = match[4].split // || [] list.map! { |m| m.to_sym } always.map! { |m| m.to_sym } set.map! { |m| m.to_sym } never.map! { |m| m.to_sym } { list: list, always: always, set: set, never: never } end end # Parse supported prefixes. # # @param [String] data The data string. def parse_prefixes data if match = %r{\WPREFIX=\((\w+)\)(\W+)\s}.match(data) modes = match[1].split // prefixes = match[2].split // modes.map! { |m| m.to_sym } i = 0 modes.each do |m| @prefixes[m] = prefixes[i] i += 1 end end end end |
#nicklen ⇒ Integer
Returns The maximum length of a nickname permissible.
46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 91 92 93 94 95 96 97 98 99 100 101 102 103 104 105 106 107 108 109 110 111 112 113 114 115 116 117 118 119 120 121 122 123 124 125 126 127 128 129 130 131 132 133 134 |
# File 'lib/syndi/irc/state/support.rb', line 46 class Support attr_accessor :cap, :sasl_method, :sasl_id, :server_name, :nicklen, :prefixes, :chan_modes, :modelen, :topiclen, :chanlen, :connected def initialize # hashes %w[chan_modes prefixes].each do |hsh| instance_variable_set("@#{hsh}", {}) end # arrays %w[cap sasl_id].each do |arr| instance_variable_set("@#{arr}", []) end # strings/symbols/booleans/integers %w[sasl_method server_name nicklen topiclen modelen chanlen connected].each do |str| instance_variable_set("@#{str}", nil) end end # Process ISUPPORT data. # # @param [Syndi::IRC::Server] irc The IRC connection. # @param [String] data The ISUPPORT data string. def isupport irc, data # Nick, channel, topic, and mode length {'@nicklen' => 'NICKLEN', '@chanlen' => 'CHANNELLEN', '@topiclen' => 'TOPICLEN', '@modelen' => 'MODES' }.each_pair do |var, indic| if data =~ /#{indic}=(\d+)/ instance_variable_set(var, $1.to_i) end end # Parse channel modes. parse_channel_modes data # Parse prefixes. parse_prefixes data end ####### private ####### # Parse supported channel modes. # # @param [String] data The data string. def parse_channel_modes data if match = %r{\WCHANMODES=(\w+),(\w+),(\w+),(\w+)\W}.match(data) list = match[1].split // || [] always = match[2].split // || [] set = match[3].split // || [] never = match[4].split // || [] list.map! { |m| m.to_sym } always.map! { |m| m.to_sym } set.map! { |m| m.to_sym } never.map! { |m| m.to_sym } { list: list, always: always, set: set, never: never } end end # Parse supported prefixes. # # @param [String] data The data string. def parse_prefixes data if match = %r{\WPREFIX=\((\w+)\)(\W+)\s}.match(data) modes = match[1].split // prefixes = match[2].split // modes.map! { |m| m.to_sym } i = 0 modes.each do |m| @prefixes[m] = prefixes[i] i += 1 end end end end |
#prefixes ⇒ Hash{Symbol => String}
Returns The list of channel user prefixes supported.
46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 91 92 93 94 95 96 97 98 99 100 101 102 103 104 105 106 107 108 109 110 111 112 113 114 115 116 117 118 119 120 121 122 123 124 125 126 127 128 129 130 131 132 133 134 |
# File 'lib/syndi/irc/state/support.rb', line 46 class Support attr_accessor :cap, :sasl_method, :sasl_id, :server_name, :nicklen, :prefixes, :chan_modes, :modelen, :topiclen, :chanlen, :connected def initialize # hashes %w[chan_modes prefixes].each do |hsh| instance_variable_set("@#{hsh}", {}) end # arrays %w[cap sasl_id].each do |arr| instance_variable_set("@#{arr}", []) end # strings/symbols/booleans/integers %w[sasl_method server_name nicklen topiclen modelen chanlen connected].each do |str| instance_variable_set("@#{str}", nil) end end # Process ISUPPORT data. # # @param [Syndi::IRC::Server] irc The IRC connection. # @param [String] data The ISUPPORT data string. def isupport irc, data # Nick, channel, topic, and mode length {'@nicklen' => 'NICKLEN', '@chanlen' => 'CHANNELLEN', '@topiclen' => 'TOPICLEN', '@modelen' => 'MODES' }.each_pair do |var, indic| if data =~ /#{indic}=(\d+)/ instance_variable_set(var, $1.to_i) end end # Parse channel modes. parse_channel_modes data # Parse prefixes. parse_prefixes data end ####### private ####### # Parse supported channel modes. # # @param [String] data The data string. def parse_channel_modes data if match = %r{\WCHANMODES=(\w+),(\w+),(\w+),(\w+)\W}.match(data) list = match[1].split // || [] always = match[2].split // || [] set = match[3].split // || [] never = match[4].split // || [] list.map! { |m| m.to_sym } always.map! { |m| m.to_sym } set.map! { |m| m.to_sym } never.map! { |m| m.to_sym } { list: list, always: always, set: set, never: never } end end # Parse supported prefixes. # # @param [String] data The data string. def parse_prefixes data if match = %r{\WPREFIX=\((\w+)\)(\W+)\s}.match(data) modes = match[1].split // prefixes = match[2].split // modes.map! { |m| m.to_sym } i = 0 modes.each do |m| @prefixes[m] = prefixes[i] i += 1 end end end end |
#sasl_id ⇒ Array<String>
Returns Identities of SASL-related timers.
46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 91 92 93 94 95 96 97 98 99 100 101 102 103 104 105 106 107 108 109 110 111 112 113 114 115 116 117 118 119 120 121 122 123 124 125 126 127 128 129 130 131 132 133 134 |
# File 'lib/syndi/irc/state/support.rb', line 46 class Support attr_accessor :cap, :sasl_method, :sasl_id, :server_name, :nicklen, :prefixes, :chan_modes, :modelen, :topiclen, :chanlen, :connected def initialize # hashes %w[chan_modes prefixes].each do |hsh| instance_variable_set("@#{hsh}", {}) end # arrays %w[cap sasl_id].each do |arr| instance_variable_set("@#{arr}", []) end # strings/symbols/booleans/integers %w[sasl_method server_name nicklen topiclen modelen chanlen connected].each do |str| instance_variable_set("@#{str}", nil) end end # Process ISUPPORT data. # # @param [Syndi::IRC::Server] irc The IRC connection. # @param [String] data The ISUPPORT data string. def isupport irc, data # Nick, channel, topic, and mode length {'@nicklen' => 'NICKLEN', '@chanlen' => 'CHANNELLEN', '@topiclen' => 'TOPICLEN', '@modelen' => 'MODES' }.each_pair do |var, indic| if data =~ /#{indic}=(\d+)/ instance_variable_set(var, $1.to_i) end end # Parse channel modes. parse_channel_modes data # Parse prefixes. parse_prefixes data end ####### private ####### # Parse supported channel modes. # # @param [String] data The data string. def parse_channel_modes data if match = %r{\WCHANMODES=(\w+),(\w+),(\w+),(\w+)\W}.match(data) list = match[1].split // || [] always = match[2].split // || [] set = match[3].split // || [] never = match[4].split // || [] list.map! { |m| m.to_sym } always.map! { |m| m.to_sym } set.map! { |m| m.to_sym } never.map! { |m| m.to_sym } { list: list, always: always, set: set, never: never } end end # Parse supported prefixes. # # @param [String] data The data string. def parse_prefixes data if match = %r{\WPREFIX=\((\w+)\)(\W+)\s}.match(data) modes = match[1].split // prefixes = match[2].split // modes.map! { |m| m.to_sym } i = 0 modes.each do |m| @prefixes[m] = prefixes[i] i += 1 end end end end |
#sasl_method ⇒ Symbol
Returns Method of SASL authentication (+:plain+ or +:dh_blowfish+).
46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 91 92 93 94 95 96 97 98 99 100 101 102 103 104 105 106 107 108 109 110 111 112 113 114 115 116 117 118 119 120 121 122 123 124 125 126 127 128 129 130 131 132 133 134 |
# File 'lib/syndi/irc/state/support.rb', line 46 class Support attr_accessor :cap, :sasl_method, :sasl_id, :server_name, :nicklen, :prefixes, :chan_modes, :modelen, :topiclen, :chanlen, :connected def initialize # hashes %w[chan_modes prefixes].each do |hsh| instance_variable_set("@#{hsh}", {}) end # arrays %w[cap sasl_id].each do |arr| instance_variable_set("@#{arr}", []) end # strings/symbols/booleans/integers %w[sasl_method server_name nicklen topiclen modelen chanlen connected].each do |str| instance_variable_set("@#{str}", nil) end end # Process ISUPPORT data. # # @param [Syndi::IRC::Server] irc The IRC connection. # @param [String] data The ISUPPORT data string. def isupport irc, data # Nick, channel, topic, and mode length {'@nicklen' => 'NICKLEN', '@chanlen' => 'CHANNELLEN', '@topiclen' => 'TOPICLEN', '@modelen' => 'MODES' }.each_pair do |var, indic| if data =~ /#{indic}=(\d+)/ instance_variable_set(var, $1.to_i) end end # Parse channel modes. parse_channel_modes data # Parse prefixes. parse_prefixes data end ####### private ####### # Parse supported channel modes. # # @param [String] data The data string. def parse_channel_modes data if match = %r{\WCHANMODES=(\w+),(\w+),(\w+),(\w+)\W}.match(data) list = match[1].split // || [] always = match[2].split // || [] set = match[3].split // || [] never = match[4].split // || [] list.map! { |m| m.to_sym } always.map! { |m| m.to_sym } set.map! { |m| m.to_sym } never.map! { |m| m.to_sym } { list: list, always: always, set: set, never: never } end end # Parse supported prefixes. # # @param [String] data The data string. def parse_prefixes data if match = %r{\WPREFIX=\((\w+)\)(\W+)\s}.match(data) modes = match[1].split // prefixes = match[2].split // modes.map! { |m| m.to_sym } i = 0 modes.each do |m| @prefixes[m] = prefixes[i] i += 1 end end end end |
#server_name ⇒ String
Returns Name of the server to which we are connected (e.g. asimov.freenode.net).
46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 91 92 93 94 95 96 97 98 99 100 101 102 103 104 105 106 107 108 109 110 111 112 113 114 115 116 117 118 119 120 121 122 123 124 125 126 127 128 129 130 131 132 133 134 |
# File 'lib/syndi/irc/state/support.rb', line 46 class Support attr_accessor :cap, :sasl_method, :sasl_id, :server_name, :nicklen, :prefixes, :chan_modes, :modelen, :topiclen, :chanlen, :connected def initialize # hashes %w[chan_modes prefixes].each do |hsh| instance_variable_set("@#{hsh}", {}) end # arrays %w[cap sasl_id].each do |arr| instance_variable_set("@#{arr}", []) end # strings/symbols/booleans/integers %w[sasl_method server_name nicklen topiclen modelen chanlen connected].each do |str| instance_variable_set("@#{str}", nil) end end # Process ISUPPORT data. # # @param [Syndi::IRC::Server] irc The IRC connection. # @param [String] data The ISUPPORT data string. def isupport irc, data # Nick, channel, topic, and mode length {'@nicklen' => 'NICKLEN', '@chanlen' => 'CHANNELLEN', '@topiclen' => 'TOPICLEN', '@modelen' => 'MODES' }.each_pair do |var, indic| if data =~ /#{indic}=(\d+)/ instance_variable_set(var, $1.to_i) end end # Parse channel modes. parse_channel_modes data # Parse prefixes. parse_prefixes data end ####### private ####### # Parse supported channel modes. # # @param [String] data The data string. def parse_channel_modes data if match = %r{\WCHANMODES=(\w+),(\w+),(\w+),(\w+)\W}.match(data) list = match[1].split // || [] always = match[2].split // || [] set = match[3].split // || [] never = match[4].split // || [] list.map! { |m| m.to_sym } always.map! { |m| m.to_sym } set.map! { |m| m.to_sym } never.map! { |m| m.to_sym } { list: list, always: always, set: set, never: never } end end # Parse supported prefixes. # # @param [String] data The data string. def parse_prefixes data if match = %r{\WPREFIX=\((\w+)\)(\W+)\s}.match(data) modes = match[1].split // prefixes = match[2].split // modes.map! { |m| m.to_sym } i = 0 modes.each do |m| @prefixes[m] = prefixes[i] i += 1 end end end end |
#topiclen ⇒ Integer
Returns The maximum length of a /TOPIC permissible.
46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 91 92 93 94 95 96 97 98 99 100 101 102 103 104 105 106 107 108 109 110 111 112 113 114 115 116 117 118 119 120 121 122 123 124 125 126 127 128 129 130 131 132 133 134 |
# File 'lib/syndi/irc/state/support.rb', line 46 class Support attr_accessor :cap, :sasl_method, :sasl_id, :server_name, :nicklen, :prefixes, :chan_modes, :modelen, :topiclen, :chanlen, :connected def initialize # hashes %w[chan_modes prefixes].each do |hsh| instance_variable_set("@#{hsh}", {}) end # arrays %w[cap sasl_id].each do |arr| instance_variable_set("@#{arr}", []) end # strings/symbols/booleans/integers %w[sasl_method server_name nicklen topiclen modelen chanlen connected].each do |str| instance_variable_set("@#{str}", nil) end end # Process ISUPPORT data. # # @param [Syndi::IRC::Server] irc The IRC connection. # @param [String] data The ISUPPORT data string. def isupport irc, data # Nick, channel, topic, and mode length {'@nicklen' => 'NICKLEN', '@chanlen' => 'CHANNELLEN', '@topiclen' => 'TOPICLEN', '@modelen' => 'MODES' }.each_pair do |var, indic| if data =~ /#{indic}=(\d+)/ instance_variable_set(var, $1.to_i) end end # Parse channel modes. parse_channel_modes data # Parse prefixes. parse_prefixes data end ####### private ####### # Parse supported channel modes. # # @param [String] data The data string. def parse_channel_modes data if match = %r{\WCHANMODES=(\w+),(\w+),(\w+),(\w+)\W}.match(data) list = match[1].split // || [] always = match[2].split // || [] set = match[3].split // || [] never = match[4].split // || [] list.map! { |m| m.to_sym } always.map! { |m| m.to_sym } set.map! { |m| m.to_sym } never.map! { |m| m.to_sym } { list: list, always: always, set: set, never: never } end end # Parse supported prefixes. # # @param [String] data The data string. def parse_prefixes data if match = %r{\WPREFIX=\((\w+)\)(\W+)\s}.match(data) modes = match[1].split // prefixes = match[2].split // modes.map! { |m| m.to_sym } i = 0 modes.each do |m| @prefixes[m] = prefixes[i] i += 1 end end end end |
Instance Method Details
#isupport(irc, data) ⇒ Object
Process ISUPPORT data.
71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 91 |
# File 'lib/syndi/irc/state/support.rb', line 71 def isupport irc, data # Nick, channel, topic, and mode length {'@nicklen' => 'NICKLEN', '@chanlen' => 'CHANNELLEN', '@topiclen' => 'TOPICLEN', '@modelen' => 'MODES' }.each_pair do |var, indic| if data =~ /#{indic}=(\d+)/ instance_variable_set(var, $1.to_i) end end # Parse channel modes. parse_channel_modes data # Parse prefixes. parse_prefixes data end |
#parse_channel_modes(data) ⇒ Object (private)
Parse supported channel modes.
100 101 102 103 104 105 106 107 108 109 110 111 112 113 114 |
# File 'lib/syndi/irc/state/support.rb', line 100 def parse_channel_modes data if match = %r{\WCHANMODES=(\w+),(\w+),(\w+),(\w+)\W}.match(data) list = match[1].split // || [] always = match[2].split // || [] set = match[3].split // || [] never = match[4].split // || [] list.map! { |m| m.to_sym } always.map! { |m| m.to_sym } set.map! { |m| m.to_sym } never.map! { |m| m.to_sym } { list: list, always: always, set: set, never: never } end end |
#parse_prefixes(data) ⇒ Object (private)
Parse supported prefixes.
119 120 121 122 123 124 125 126 127 128 129 130 131 132 |
# File 'lib/syndi/irc/state/support.rb', line 119 def parse_prefixes data if match = %r{\WPREFIX=\((\w+)\)(\W+)\s}.match(data) modes = match[1].split // prefixes = match[2].split // modes.map! { |m| m.to_sym } i = 0 modes.each do |m| @prefixes[m] = prefixes[i] i += 1 end end end |