mirror of
https://github.com/SillyTavern/SillyTavern.git
synced 2025-01-23 07:51:18 +01:00
#2046 Fix for undefined fields
This commit is contained in:
parent
d56722a4b6
commit
0594859fb9
@ -353,14 +353,30 @@ export function getGroupCharacterCards(groupId, characterId) {
|
||||
return null;
|
||||
}
|
||||
|
||||
/** Runs the macro engine on a text, with custom <FIELDNAME> replace @param {string} value @param {string} characterName @param {string} fieldName @returns {string} */
|
||||
/**
|
||||
* Runs the macro engine on a text, with custom <FIELDNAME> replace
|
||||
* @param {string} value Value to replace
|
||||
* @param {string} fieldName Name of the field
|
||||
* @param {string} characterName Name of the character
|
||||
* @returns {string} Replaced text
|
||||
* */
|
||||
function customBaseChatReplace(value, fieldName, characterName) {
|
||||
if (!value) {
|
||||
return '';
|
||||
}
|
||||
|
||||
// We should do the custom field name replacement first, and then run it through the normal macro engine with provided names
|
||||
value = value.replace(/<FIELDNAME>/gi, fieldName);
|
||||
return baseChatReplace(value.trim(), name1, characterName);
|
||||
}
|
||||
|
||||
/** Prepares text with prefix/suffix for a character field @param {string} value @param {string} characterName @param {string} fieldName @returns {string} */
|
||||
/**
|
||||
* Prepares text with prefix/suffix for a character field
|
||||
* @param {string} value Value to replace
|
||||
* @param {string} characterName Name of the character
|
||||
* @param {string} fieldName Name of the field
|
||||
* @returns {string} Prepared text
|
||||
* */
|
||||
function replaceAndPrepareForJoin(value, characterName, fieldName) {
|
||||
value = value.trim();
|
||||
if (!value) {
|
||||
|
@ -74,6 +74,8 @@ router.post('/create', jsonParser, (request, response) => {
|
||||
chat_id: request.body.chat_id ?? id,
|
||||
chats: request.body.chats ?? [id],
|
||||
auto_mode_delay: request.body.auto_mode_delay ?? 5,
|
||||
generation_mode_join_prefix: request.body.generation_mode_join_prefix ?? '',
|
||||
generation_mode_join_suffix: request.body.generation_mode_join_suffix ?? '',
|
||||
};
|
||||
const pathToFile = path.join(DIRECTORIES.groups, `${id}.json`);
|
||||
const fileData = JSON.stringify(groupMetadata);
|
||||
|
Loading…
Reference in New Issue
Block a user