1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
|
# 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
|