lib/lita/adapters/shell.rb in lita-1.1.2 vs lib/lita/adapters/shell.rb in lita-2.0.0

- old
+ new

@@ -1,26 +1,37 @@ module Lita module Adapters + # An adapter that runs Lita in a UNIX shell. class Shell < Adapter + # Creates a "Shell User" and then loops a prompt and input, passing the + # incoming messages to the robot. + # @return [void] def run - user = User.new(1, name: "Shell User") + user = User.create(1, name: "Shell User") source = Source.new(user) puts 'Type "exit" or "quit" to end the session.' loop do print "#{robot.name} > " input = $stdin.gets.chomp.strip break if input == "exit" || input == "quit" message = Message.new(robot, input, source) - Thread.new { robot.receive(message) } + message.command! if Lita.config.adapter.private_chat + robot.receive(message) end end + # Outputs outgoing messages to the shell. + # @param target [Lita::Source] Unused, since there is only one user in the + # shell environment. + # @param strings [Array<String>] An array of strings to output. + # @return [void] def send_messages(target, strings) - puts puts strings end + # Adds a blank line for a nice looking exit. + # @return [void] def shut_down puts end end