diff options
Diffstat (limited to 'controllers/interfaces/tools.rb')
-rw-r--r-- | controllers/interfaces/tools.rb | 13 |
1 files changed, 13 insertions, 0 deletions
diff --git a/controllers/interfaces/tools.rb b/controllers/interfaces/tools.rb index 1136600..d32afed 100644 --- a/controllers/interfaces/tools.rb +++ b/controllers/interfaces/tools.rb @@ -10,6 +10,17 @@ module NanoBot module Controllers module Interfaces module Tool + def self.confirm(session, cartridge, mode, feedback) + yeses = Logic::Cartridge::Safety.yeses(cartridge) + default_answer = Logic::Cartridge::Safety.default_answer(cartridge) + dispatch_feedback(session, cartridge, mode, feedback) + session.flush + answer = $stdin.gets.chomp.to_s.downcase.strip + answer = default_answer if answer == '' + session.print("\n") + yeses.include?(answer) + end + def self.adapt(feedback, adapter, cartridge) call = { parameters: %w[id name parameters parameters-as-json output], @@ -41,6 +52,8 @@ module NanoBot def self.dispatch_feedback(session, cartridge, mode, feedback) enabled = Logic::Cartridge::Tools.feedback?(cartridge, mode.to_sym, feedback[:action].to_sym) + enabled = true if feedback[:action].to_sym == :confirm + return unless enabled color = Logic::Cartridge::Tools.fetch_from_interface( |