Sha256: 41bb28578e52407184d90c715d77b7581e5e01bef4cca0cc8054697eee371860

Contents?: true

Size: 1.76 KB

Versions: 19

Compression:

Stored size: 1.76 KB

Contents

# frozen_string_literal: true

require_relative 'fetch'
require_relative 'affixes'
require_relative 'adapters'

module NanoBot
  module Logic
    module Cartridge
      module Tools
        def self.fetch_from_interface(cartridge, interface, action, path)
          Fetch.cascate(cartridge, [
                          [:interfaces, interface, :tools, action].concat(path),
                          [:interfaces, :tools, action].concat(path),
                          %i[interfaces tools].concat(path)
                        ])
        end

        def self.feedback?(cartridge, interface, action)
          Fetch.cascate(cartridge, [
                          [:interfaces, interface, :tools, action, :feedback],
                          [:interfaces, :tools, action, :feedback],
                          %i[interfaces tools feedback]
                        ])
        end

        def self.input(cartridge, interface, content)
          lua = Adapter.expression(cartridge, interface, :input, :lua)
          fennel = Adapter.expression(cartridge, interface, :input, :fennel)

          prefix = Affixes.get(cartridge, interface, :input, :prefix)
          suffix = Affixes.get(cartridge, interface, :input, :suffix)

          { content:, prefix:, suffix:, lua:, fennel: }
        end

        def self.output(cartridge, interface, result, streaming, _finished)
          if streaming
            result[:message] = { content: result[:message], lua: nil, fennel: nil }
            return result
          end

          lua = Adapter.expression(cartridge, interface, :output, :lua)
          fennel = Adapter.expression(cartridge, interface, :output, :fennel)

          result[:message] = { content: result[:message], lua:, fennel: }

          result
        end
      end
    end
  end
end

Version data entries

19 entries across 19 versions & 1 rubygems

Version Path
nano-bots-3.4.0 logic/cartridge/tools.rb
nano-bots-3.3.0 logic/cartridge/tools.rb
nano-bots-3.2.0 logic/cartridge/tools.rb
nano-bots-3.0.1 logic/cartridge/tools.rb
nano-bots-3.0.0 logic/cartridge/tools.rb
nano-bots-2.5.1 logic/cartridge/tools.rb
nano-bots-2.5.0 logic/cartridge/tools.rb
nano-bots-2.4.1 logic/cartridge/tools.rb
nano-bots-2.4.0 logic/cartridge/tools.rb
nano-bots-2.3.0 logic/cartridge/tools.rb
nano-bots-2.2.0 logic/cartridge/tools.rb
nano-bots-2.1.0 logic/cartridge/tools.rb
nano-bots-2.0.0 logic/cartridge/tools.rb
nano-bots-1.2.0 logic/cartridge/tools.rb
nano-bots-1.1.2 logic/cartridge/tools.rb
nano-bots-1.1.1 logic/cartridge/tools.rb
nano-bots-1.1.0 logic/cartridge/tools.rb
nano-bots-1.0.1 logic/cartridge/tools.rb
nano-bots-1.0.0 logic/cartridge/tools.rb