module ChannelModes
Constants
- FLOATLIM_HINT
Public Instance Methods
Source
# File lib/irc_capabilities.rb, line 76 def channel_modes(channel) return channel if channel.is_a?(Hash) channel.respond_to?(:modes) ? channel.modes : nil end
Source
# File lib/irc_capabilities.rb, line 49 def format_active_modes(modes) parts = [] %w[m n t i k l r R D d C c p s].each do |flag| next unless modes[flag] if flag == "l" parts << "+l #{modes[flag]}" elsif flag == "k" parts << "+k" else parts << "+#{flag.downcase == "r" && modes["R"] ? "R" : flag}" end end parts.empty? ? "(none)" : parts.join(" ") end
Source
# File lib/irc_capabilities.rb, line 65 def protection_notes(modes) notes = [] notes << "Speech: moderated — only ops and voiced users can talk." if modes["m"] notes << "Join: registered X users only (+r)." if modes["r"] notes << "Join: invite only (+i)." if modes["i"] notes << "Joins hidden until speak/voice (+D)." if modes["D"] || modes["d"] return "" if notes.empty? notes.join(" ") end
Source
# File lib/irc_capabilities.rb, line 38 def summary(channel, capabilities: nil) modes = channel_modes(channel) return "Channel modes: (unknown)" if modes.nil? active = format_active_modes(modes) lines = ["Channel modes: #{active}"] lines << protection_notes(modes) lines << FLOATLIM_HINT if capabilities.nil? || capabilities[:isupport] lines.join("\n") end