lib/lita/adapters/shell.rb in lita-3.3.1 vs lib/lita/adapters/shell.rb in lita-4.0.0.rc1

- old
+ new

@@ -1,10 +1,12 @@ module Lita # A namespace to hold all subclasses of {Adapter}. module Adapters # An adapter that runs Lita in a UNIX shell. class Shell < Adapter + config :private_chat, default: false + # Creates a "Shell User" and then loops a prompt and input, passing the # incoming messages to the robot. # @return [void] def run user = User.create(1, name: "Shell User") @@ -14,11 +16,11 @@ run_loop end # Outputs outgoing messages to the shell. - # @param target [Lita::Source] Unused, since there is only one user in the + # @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) strings = Array(strings) @@ -37,11 +39,11 @@ private def build_message(input, source) message = Message.new(robot, input, source) - message.command! if Lita.config.adapter.private_chat + message.command! if robot.config.adapters.shell.private_chat message end def normalize_history(input) if input == "" || (Readline::HISTORY.size >= 2 && input == Readline::HISTORY[-2]) @@ -55,10 +57,10 @@ def read_input input = Readline.readline("#{robot.name} > ", true) # Input read via rb-readline will always be encoded as US-ASCII. # @see https://github.com/luislavena/rb-readline/blob/master/lib/readline.rb#L1 - input.force_encoding(Encoding.default_external) + input.force_encoding(Encoding.default_external) if input end def run_loop loop do input = read_input