summaryrefslogtreecommitdiff
path: root/controllers/interfaces
diff options
context:
space:
mode:
authoricebaker <icebaker@proton.me>2023-11-18 21:45:16 -0300
committericebaker <icebaker@proton.me>2023-11-18 21:45:16 -0300
commitc470d63b169058d81f44569a5f1c4c1fb222279f (patch)
tree8d2f520d4eb73e65a44e3815f36e38ff09943d52 /controllers/interfaces
parent89962f27a75183947fc44cd051a1061ce157221d (diff)
adding support for confirm
Diffstat (limited to 'controllers/interfaces')
-rw-r--r--controllers/interfaces/tools.rb13
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(