Sha256: 1f2057d2bb8677f94d1d52e33ae6dddd58c61648e184e9782e019c01a47b77a8

Contents?: true

Size: 601 Bytes

Versions: 1

Compression:

Stored size: 601 Bytes

Contents

# frozen_string_literal: true

module Twitch
  module Bot
    # Base class for implementing chat commands
    class CommandHandler < EventHandler
      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

1 entries across 1 versions & 1 rubygems

Version Path
twitch-bot-4.1.0 lib/twitch/bot/command_handler.rb