class Twitch::Bot::MessageParser

This class calls the parser related to the IRC command we received.

Attributes

irc_message[R]

Public Class Methods

new(irc_message) click to toggle source
# File lib/twitch/bot/message_parser.rb, line 7
def initialize(irc_message)
  @irc_message = irc_message
end

Public Instance Methods

message() click to toggle source
# File lib/twitch/bot/message_parser.rb, line 11
def message
  parse_command
end

Private Instance Methods

parse_command() click to toggle source
# File lib/twitch/bot/message_parser.rb, line 19
def parse_command
  command_parser = {
    "MODE" => ModeCommandParser,
    "PING" => PingCommandParser,
    "372" => AuthenticatedCommandParser,
    "366" => JoinCommandParser,
    "PRIVMSG" => PrivMsgCommandParser,
    "ROOMSTATE" => RoomStateCommandParser,
    "NOTICE" => NoticeCommandParser,
  }
  parser = command_parser[irc_message.command]
  if parser
    parser.new(irc_message).call
  else
    Message::NotSupported.new(irc_message)
  end
end