Multiple scripts were not running due to improper variable assingment.
For efficiency's sake, do not do a string comparison before returning
and instead do another variable assignment in the parent function.
Doing this reduces the length of regex hooks in the parent calls,
but also removes the need for unnecessary O(n) complexity of comparing
two string variables.
If there are errors, it would be advisable to add string comparison
and revert back to the old logic in parent function calls.
Signed-off-by: kingbri <bdashore3@proton.me>
Sendas uses a different character's name for messages, so allow
the use of a character name override in the regex match function.
This overrides substituteParams to use a different value.
Signed-off-by: kingbri <bdashore3@proton.me>
If the extension is disabled, don't use any regex formatting. In
addition, wrap all foreach logic into its own function which
reduces the size of all regex injections.
This commit also removes the need for working around static imports
as UI is separate from the engine and is therefore imported at the
same time as other non-static extensions.
Signed-off-by: kingbri <bdashore3@proton.me>
Some extensions are statically imported inside script.js, bypassing
the extension load method. The true method to solve this is using
dynamic imports and undefined checks, but implementing this is
extremely time-consuming.
For now, add the extension_first_load event which fires when
first load is about to start. This changes loading priority to
static -> offline -> online/API.
In addition, initialize the event source earlier since it's more
important than most of the other imports.
Signed-off-by: kingbri <bdashore3@proton.me>
Regex is a method that is commonly used to find and replace parts
of a string using a single pattern. Add support for using regex in
SillyTavern which allows users to dynamically change various aspects
of the chatting experience.
Users are able to choose where a given regex script should apply
(both invasive and non-invasive options!). Invasive options alter
chat history while non-invasive alters markdown display for the
entire chat.
A new variable called {{match}} is added in regex scripts which
substitutes in the found match from the original find regex script.
There is a lot more that can be added to this extension, but for now,
this is enough.
Signed-off-by: kingbri <bdashore3@proton.me>
This allows for more flexible popups with options rather than
implementing a brand new popup just to change button text.
Signed-off-by: kingbri <bdashore3@proton.me>