Sha256: cd7000f3c6f7e9226e4e2d43b278fe7be3905e1daa215bdcd5be38d839346d7d

Contents?: true

Size: 666 Bytes

Versions: 7

Compression:

Stored size: 666 Bytes

Contents

# frozen_string_literal: true

module Twitch
  module Bot
    # Base class for implementing chat commands
    class CommandHandler < EventHandler
      def self.handled_events
        [:user_message]
      end

      def initialize(event:, client:)
        super
        @command_aliases = []
      end

      def call
        if event.command? && command_aliases.include?(event.command)
          handle_command
        end
      end

      def command_alias(command_alias)
        @command_aliases << command_alias
      end

      private

      attr_reader :command_aliases

      def handle_command
        raise NotImplementedError
      end
    end
  end
end

Version data entries

7 entries across 7 versions & 1 rubygems

Version Path
twitch-bot-5.0.6 lib/twitch/bot/command_handler.rb
twitch-bot-5.0.5 lib/twitch/bot/command_handler.rb
twitch-bot-5.0.4 lib/twitch/bot/command_handler.rb
twitch-bot-5.0.2 lib/twitch/bot/command_handler.rb
twitch-bot-5.0.1 lib/twitch/bot/command_handler.rb
twitch-bot-5.0.0 lib/twitch/bot/command_handler.rb
twitch-bot-4.1.1 lib/twitch/bot/command_handler.rb