Module: Hahamut::Message

Defined in:
lib/hahamut/message.rb,
lib/hahamut/message/base.rb,
lib/hahamut/message/text.rb,
lib/hahamut/message/image.rb,
lib/hahamut/message/command.rb,
lib/hahamut/message/sticker.rb,
lib/hahamut/message/bot_event.rb,
lib/hahamut/message/bot_start.rb

Overview

Hahamut Message

Defined Under Namespace

Classes: Base, BotEvent, BotStart, Command, Image, Sticker, Text

Class Method Summary collapse

Class Method Details

.parse(message) ⇒ Object



19
20
21
22
23
# File 'lib/hahamut/message.rb', line 19

def parse(message)
  # TODO: Improve type match
  klass = types.find { |type| type.match?(message) }
  klass&.new(message['message'], message['sender_id'])
end

.typesObject



15
16
17
# File 'lib/hahamut/message.rb', line 15

def types
  @types ||= (constants - [:Base]).map { |name| const_get(name) }
end