Module: Repp::Handler::Shell::KeyboardHandler

Includes:
EM::Protocols::LineText2
Defined in:
lib/repp/handler/shell.rb

Instance Method Summary collapse

Instance Method Details

#initialize(app) ⇒ Object



8
# File 'lib/repp/handler/shell.rb', line 8

def initialize(app) @app = app.new; end

#receive_line(data) ⇒ Object



9
10
11
12
13
14
15
16
# File 'lib/repp/handler/shell.rb', line 9

def receive_line(data)
  reply_to = /@\w+/.match(data)&.[](1)
  message = Event::Receive.new(type: :message, body: data, reply_to: reply_to, bot?: false)
  res = @app.call(message)
  if res.any?
    $stdout.puts res.first
  end
end