-
Notifications
You must be signed in to change notification settings - Fork 12
Expand file tree
/
Copy pathsettings.js
More file actions
66 lines (51 loc) · 2.44 KB
/
settings.js
File metadata and controls
66 lines (51 loc) · 2.44 KB
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
54
55
56
57
58
59
60
61
62
63
64
65
66
// SPDX-License-Identifier: AGPL-3.0-or-later
// Copyright (C) 2025 Philipp Emanuel Weidmann <[email protected]>
import { extension_settings } from "../../../extensions.js";
import { NAME } from "./common.js";
const INSTRUCTIONS = `
-----
!!! IMPORTANT !!!
The following are instructions for inserting certain markers into your responses.
Read them VERY carefully and follow them to the letter:
{{#each scripts}}When {{this.condition}}, insert the following string into the response, precisely at the point where it happens: %[{{this.id}}]
Do this ONLY when {{this.condition}}, not under any other circumstances.
{{/each}}Insert these markers only under the conditions described above, not when something tangentially related happens.
Write the markers exactly as given above. Do not place them inside quotes.
Do not use the same marker more than once per response, unless the trigger condition occurs multiple times.
Here is an example that demonstrates how the markers should be used:
Let's say you have been instructed to insert the marker %[987] when a certain character gives the user something to drink.
In that case, a dialogue might look like this:
User: "I'm completely parched."
Character: "I know, it's so hot today. Here." *She fills a glass with water and hands it to him.* %[987] "So, what are we going to do later?"
User: "How about we go bowling?"
Character: "Great idea! Let's do that." *Her eyes sparkle with excitement.*
-----
`;
const DEFAULT_SETTINGS = {
enabled: true,
flashIcon: true,
instructions: INSTRUCTIONS,
markerRegex: "%\\[(\\d+)\\]",
partialMarkerRegex: "%(?:\\[\\d*)?$",
scripts: [
{
id: 1,
enabled: true,
condition: "{{char}} turns off the lights",
stscript: "/# Make sure you have the background set to something *other* than black first. |\n/bg _black\n",
javascript: 'console.log("Lights out!");\n'
}
]
};
export function loadSettings() {
extension_settings[NAME] = Object.assign(
// Start with an empty object to avoid overwriting anything.
{},
// Use the default settings as a baseline, so that new settings added in an extension update
// are set to the defaults even if other settings are already saved.
DEFAULT_SETTINGS,
// Finally apply any saved settings, overriding the defaults where present.
extension_settings[NAME] || {}
);
return extension_settings[NAME];
}