class Twitch::Bot::Message::UserMessage
This class stores the details of a user's chat message.
Attributes
text[R]
user[R]
Public Class Methods
new(text:, user:)
click to toggle source
# File lib/twitch/bot/message/user_message.rb, line 10 def initialize(text:, user:) @text = text @user = user @type = :user_message end
Public Instance Methods
command()
click to toggle source
# File lib/twitch/bot/message/user_message.rb, line 24 def command first_word&.match(/^!(\w+)/) do |match| match.captures&.first end end
command?()
click to toggle source
# File lib/twitch/bot/message/user_message.rb, line 20 def command? !(command.nil? || command.empty?) end
command_args()
click to toggle source
# File lib/twitch/bot/message/user_message.rb, line 30 def command_args text_words.tap(&:shift) end
command_name?(check_command)
click to toggle source
# File lib/twitch/bot/message/user_message.rb, line 16 def command_name?(check_command) command == check_command end
Private Instance Methods
first_word()
click to toggle source
# File lib/twitch/bot/message/user_message.rb, line 40 def first_word text_words.first end
text_words()
click to toggle source
# File lib/twitch/bot/message/user_message.rb, line 36 def text_words text.split(/\s+/) end