Class: Rodbot::Simulator

Inherits:
Object
  • Object
show all
Defined in:
lib/rodbot/simulator.rb

Overview

Simulate a chat client

Instance Method Summary collapse

Constructor Details

#initialize(sender, raw: false) ⇒ Simulator

Returns a new instance of Simulator.

Parameters:

  • sender (String)

    sender to mimick

  • raw (Boolean) (defaults to: false)

    whether to display raw Markdown



17
18
19
20
21
# File 'lib/rodbot/simulator.rb', line 17

def initialize(sender, raw: false)
  @sender, @raw = sender, raw
  @relay = Rodbot::Relay.new
  @pastel = Pastel.new
end

Instance Method Details

#runObject



23
24
25
26
27
28
29
30
# File 'lib/rodbot/simulator.rb', line 23

def run
  puts nil, "Talking to app on #{Rodbot::Services::App.url} as sender #{@pastel.inverse(@sender)}."
  puts 'Type commands beginning with "!" or empty line to exit.', nil
  while (line = Readline.readline("rodbot> ", true)) && !line.empty?
    puts nil, reply_to(line), nil
  end
  puts
end