class Twitch::Bot::IrcMessage
This class splits an IRC message into its basic parts. see ircv3.net/specs/extensions/message-tags.html#format
rubocop:disable Layout/LineLength <message> ::= ['@' <tags> <SPACE>] [':' <prefix> <SPACE> ] <command> <params> <crlf> rubocop:enable Layout/LineLength
Attributes
command[R]
params[R]
prefix[R]
Public Class Methods
new(msg)
click to toggle source
# File lib/twitch/bot/irc_message.rb, line 102 def initialize(msg) raw_tags, @prefix, @command, raw_params = msg.match( /^(?:@(\S+) )?(?::(\S+) )?(\S+)(.*)/, ).captures @tags = IrcMessageTags.new(raw_tags) @params = IrcMessageParams.new(raw_params).params end
Public Instance Methods
channel()
click to toggle source
Not really a :reek:NilCheck
# File lib/twitch/bot/irc_message.rb, line 138 def channel params.detect { |param| param.start_with?("#") }&.delete("#") end
error()
click to toggle source
# File lib/twitch/bot/irc_message.rb, line 111 def error command[/[45]\d\d/] ? command.to_i : 0 end
error?()
click to toggle source
# File lib/twitch/bot/irc_message.rb, line 115 def error? error.positive? end
target()
click to toggle source
# File lib/twitch/bot/irc_message.rb, line 119 def target channel || user end
text()
click to toggle source
# File lib/twitch/bot/irc_message.rb, line 123 def text if error? error.to_s else params.last end end
user()
click to toggle source
# File lib/twitch/bot/irc_message.rb, line 131 def user return unless prefix prefix[/^(\S+)!/, 1] end