Class: Syndi::IRC::State::Support

Inherits:
Object
  • Object
show all
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

Instance Method Summary collapse

Constructor Details

#initializeSupport

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

#capArray<String>

Returns A list of enabled capabilities.

Returns:

  • (Array<String>)

    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_modesHash{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.

Returns:

  • (Hash{Symbol => Array<Symbol>})

    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

#chanlenInteger

Returns The maximum length of a channel's name permissible.

Returns:

  • (Integer)

    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

#connectedBoolean

Returns Whether we are connected and registered.

Returns:

  • (Boolean)

    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

#modelenInteger

Returns The maximum number of modes permissible in a single /MODE.

Returns:

  • (Integer)

    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

#nicklenInteger

Returns The maximum length of a nickname permissible.

Returns:

  • (Integer)

    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

#prefixesHash{Symbol => String}

Returns The list of channel user prefixes supported.

Returns:

  • (Hash{Symbol => String})

    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_idArray<String>

Returns Identities of SASL-related timers.

Returns:

  • (Array<String>)

    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_methodSymbol

Returns Method of SASL authentication (+:plain+ or +:dh_blowfish+).

Returns:

  • (Symbol)

    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_nameString

Returns Name of the server to which we are connected (e.g. asimov.freenode.net).

Returns:

  • (String)

    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

#topiclenInteger

Returns The maximum length of a /TOPIC permissible.

Returns:

  • (Integer)

    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.

Parameters:



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.

Parameters:

  • data (String)

    The data string.



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.

Parameters:

  • data (String)

    The data string.



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