Sha256: 9aac5b0e88165f8500a21e7b3efdd788ea68cd77b326f7b4cd773c6505c8782b

Contents?: true

Size: 955 Bytes

Versions: 12

Compression:

Stored size: 955 Bytes

Contents

# frozen_string_literal: true

module Twitch
  module Bot
    module Adapter
      # This adapter connects the chat client to the terminal
      class Terminal
        def initialize(client:)
          @client = client
        end

        def connect; end

        def shutdown; end

        def read_data
          read_message_from_terminal
        end

        def send_message(text)
          send_data(text)
        end

        def send_data(data)
          puts data
        end

        def join_channel(_channel); end

        def part_channel; end

        private

        attr_reader :client

        def read_message_from_terminal
          Twitch::Bot::Logger.debug "Waiting for input..."
          input = read_terminal
          Twitch::Bot::Message::UserMessage.new(
            text: input,
            user: client.channel.name,
          )
        end

        def read_terminal
          gets
        end
      end
    end
  end
end

Version data entries

12 entries across 12 versions & 1 rubygems

Version Path
twitch-bot-6.0.0 lib/twitch/bot/adapter/terminal.rb
twitch-bot-5.0.6 lib/twitch/bot/adapter/terminal.rb
twitch-bot-5.0.5 lib/twitch/bot/adapter/terminal.rb
twitch-bot-5.0.4 lib/twitch/bot/adapter/terminal.rb
twitch-bot-5.0.2 lib/twitch/bot/adapter/terminal.rb
twitch-bot-5.0.1 lib/twitch/bot/adapter/terminal.rb
twitch-bot-5.0.0 lib/twitch/bot/adapter/terminal.rb
twitch-bot-4.1.1 lib/twitch/bot/adapter/terminal.rb
twitch-bot-4.1.0 lib/twitch/bot/adapter/terminal.rb
twitch-bot-4.0.1 lib/twitch/bot/adapter/terminal.rb
twitch-bot-4.0.0 lib/twitch/bot/adapter/terminal.rb
twitch-bot-3.2.1 lib/twitch/bot/adapter/terminal.rb