Class: Lemmibot::CommandInterface

Inherits:
Object
  • Object
show all
Defined in:
lib/lemmibot/command_interface.rb

Overview

An interface for issuing commands to a Lemmibot via interactive command-line or piped in scripts

Instance Method Summary collapse

Constructor Details

#initializeCommandInterface

Returns a new instance of CommandInterface.



5
6
7
# File 'lib/lemmibot/command_interface.rb', line 5

def initialize
  @bot = Lemmibot::Bot.new
end

Instance Method Details

#startObject



9
10
11
12
13
14
15
16
17
18
19
20
21
# File 'lib/lemmibot/command_interface.rb', line 9

def start
  # Start a session, receiving and processing commands from standard input
  puts 'Lemmibot is awaiting your commands'
  loop do
    command = gets
    return unless command
    begin
      process_command(command.chomp)
    rescue
      # Malformed and failed commands should be ignored, so take no action
    end
  end
end