Sha256: ddd53da44e2ffc3f4e7572afebaf498528f112c0c82f62006d6401a8d3db1b13

Contents?: true

Size: 643 Bytes

Versions: 1

Compression:

Stored size: 643 Bytes

Contents

# frozen_string_literal: true

require 'hahamut/message/base'
require 'hahamut/message/text'
require 'hahamut/message/image'
require 'hahamut/message/sticker'
require 'hahamut/message/command'
require 'hahamut/message/bot_start'
require 'hahamut/message/bot_event'

module Hahamut
  # Hahamut Message
  module Message
    class << self
      def types
        @types ||= (constants - [:Base]).map { |name| const_get(name) }
      end

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

Version data entries

1 entries across 1 versions & 1 rubygems

Version Path
hahamut-0.1.2 lib/hahamut/message.rb