From c470d63b169058d81f44569a5f1c4c1fb222279f Mon Sep 17 00:00:00 2001 From: icebaker Date: Sat, 18 Nov 2023 21:45:16 -0300 Subject: adding support for confirm --- logic/cartridge/safety.rb | 21 +++++++++++++++++++++ 1 file changed, 21 insertions(+) (limited to 'logic/cartridge') diff --git a/logic/cartridge/safety.rb b/logic/cartridge/safety.rb index 84b39d7..6414e51 100644 --- a/logic/cartridge/safety.rb +++ b/logic/cartridge/safety.rb @@ -6,6 +6,27 @@ module NanoBot module Logic module Cartridge module Safety + def self.default_answer(cartridge) + default = Fetch.cascate(cartridge, [%i[interfaces tools confirm default]]) + return [] if default.nil? + + default + end + + def self.yeses(cartridge) + yeses_values = Fetch.cascate(cartridge, [%i[interfaces tools confirm yeses]]) + return [] if yeses_values.nil? + + yeses_values + end + + def self.confirmable?(cartridge) + confirmable = Fetch.cascate(cartridge, [%i[safety tools confirmable]]) + return true if confirmable.nil? + + confirmable + end + def self.sandboxed?(cartridge) sandboxed = Fetch.cascate(cartridge, [%i[safety functions sandboxed]]) return true if sandboxed.nil? -- cgit v1.2.3