mirror of
https://github.com/SillyTavern/SillyTavern.git
synced 2025-06-05 21:59:27 +02:00
Merge branch 'staging' into ruRuNew
This commit is contained in:
@@ -2317,6 +2317,16 @@ export function scrollChatToBottom() {
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* Substitutes {{macro}} parameters in a string.
|
||||
* @param {string} content - The string to substitute parameters in.
|
||||
* @param {Record<string,any>} additionalMacro - Additional environment variables for substitution.
|
||||
* @returns {string} The string with substituted parameters.
|
||||
*/
|
||||
export function substituteParamsExtended(content, additionalMacro = {}) {
|
||||
return substituteParams(content, undefined, undefined, undefined, undefined, true, additionalMacro);
|
||||
}
|
||||
|
||||
/**
|
||||
* Substitutes {{macro}} parameters in a string.
|
||||
* @param {string} content - The string to substitute parameters in.
|
||||
@@ -2325,9 +2335,10 @@ export function scrollChatToBottom() {
|
||||
* @param {string} [_original] - The original message for {{original}} substitution.
|
||||
* @param {string} [_group] - The group members list for {{group}} substitution.
|
||||
* @param {boolean} [_replaceCharacterCard] - Whether to replace character card macros.
|
||||
* @param {Record<string,any>} [additionalMacro] - Additional environment variables for substitution.
|
||||
* @returns {string} The string with substituted parameters.
|
||||
*/
|
||||
export function substituteParams(content, _name1, _name2, _original, _group, _replaceCharacterCard = true) {
|
||||
export function substituteParams(content, _name1, _name2, _original, _group, _replaceCharacterCard = true, additionalMacro = {}) {
|
||||
const environment = {};
|
||||
|
||||
if (typeof _original === 'string') {
|
||||
@@ -2377,6 +2388,10 @@ export function substituteParams(content, _name1, _name2, _original, _group, _re
|
||||
environment.group = environment.charIfNotGroup = getGroupValue();
|
||||
environment.model = getGeneratingModel();
|
||||
|
||||
if (additionalMacro && typeof additionalMacro === 'object') {
|
||||
Object.assign(environment, additionalMacro);
|
||||
}
|
||||
|
||||
return evaluateMacros(content, environment);
|
||||
}
|
||||
|
||||
@@ -4673,7 +4688,7 @@ function addChatsSeparator(mesSendString) {
|
||||
async function DupeChar() {
|
||||
if (!this_chid) {
|
||||
toastr.warning('You must first select a character to duplicate!');
|
||||
return;
|
||||
return '';
|
||||
}
|
||||
|
||||
const confirmMessage = `
|
||||
@@ -4684,7 +4699,7 @@ async function DupeChar() {
|
||||
|
||||
if (!confirm) {
|
||||
console.log('User cancelled duplication');
|
||||
return;
|
||||
return '';
|
||||
}
|
||||
|
||||
const body = { avatar_url: characters[this_chid].avatar };
|
||||
@@ -4699,6 +4714,8 @@ async function DupeChar() {
|
||||
await eventSource.emit(event_types.CHARACTER_DUPLICATED, { oldAvatar: body.avatar_url, newAvatar: data.path });
|
||||
getCharacters();
|
||||
}
|
||||
|
||||
return '';
|
||||
}
|
||||
|
||||
export async function itemizedParams(itemizedPrompts, thisPromptSet) {
|
||||
@@ -7708,6 +7725,8 @@ window['SillyTavern'].getContext = function () {
|
||||
activateSendButtons,
|
||||
deactivateSendButtons,
|
||||
saveReply,
|
||||
substituteParams,
|
||||
substituteParamsExtended,
|
||||
registerSlashCommand: registerSlashCommand,
|
||||
executeSlashCommands: executeSlashCommands,
|
||||
timestampToMoment: timestampToMoment,
|
||||
@@ -8261,10 +8280,12 @@ async function selectInstructCallback(_, name) {
|
||||
|
||||
async function enableInstructCallback() {
|
||||
$('#instruct_enabled').prop('checked', true).trigger('change');
|
||||
return '';
|
||||
}
|
||||
|
||||
async function disableInstructCallback() {
|
||||
$('#instruct_enabled').prop('checked', false).trigger('change');
|
||||
return '';
|
||||
}
|
||||
|
||||
/**
|
||||
@@ -8470,23 +8491,25 @@ async function doDeleteChat() {
|
||||
$(currentChatDeleteButton).trigger('click');
|
||||
await delay(1);
|
||||
$('#dialogue_popup_ok').trigger('click', { fromSlashCommand: true });
|
||||
return '';
|
||||
}
|
||||
|
||||
async function doRenameChat(_, chatName) {
|
||||
if (!chatName) {
|
||||
toastr.warning('Name must be provided as an argument to rename this chat.');
|
||||
return;
|
||||
return '';
|
||||
}
|
||||
|
||||
const currentChatName = getCurrentChatId();
|
||||
if (!currentChatName) {
|
||||
toastr.warning('No chat selected that can be renamed.');
|
||||
return;
|
||||
return '';
|
||||
}
|
||||
|
||||
await renameChat(currentChatName, chatName);
|
||||
|
||||
toastr.success(`Successfully renamed chat to: ${chatName}`);
|
||||
return '';
|
||||
}
|
||||
|
||||
/**
|
||||
@@ -8560,6 +8583,7 @@ function doCharListDisplaySwitch() {
|
||||
|
||||
function doCloseChat() {
|
||||
$('#option_close_chat').trigger('click');
|
||||
return '';
|
||||
}
|
||||
|
||||
/**
|
||||
@@ -8655,6 +8679,7 @@ async function removeCharacterFromUI(name, avatar, reloadCharacters = true) {
|
||||
|
||||
function doTogglePanels() {
|
||||
$('#option_settings').trigger('click');
|
||||
return '';
|
||||
}
|
||||
|
||||
function addDebugFunctions() {
|
||||
@@ -8742,6 +8767,7 @@ jQuery(async function () {
|
||||
await saveSettings();
|
||||
await saveChatConditional();
|
||||
toastr.success('Chat and settings saved.');
|
||||
return '';
|
||||
}
|
||||
|
||||
SlashCommandParser.addCommandObject(SlashCommand.fromProps({
|
||||
@@ -8893,7 +8919,10 @@ jQuery(async function () {
|
||||
}));
|
||||
SlashCommandParser.addCommandObject(SlashCommand.fromProps({
|
||||
name: 'chat-manager',
|
||||
callback: () => $('#option_select_chat').trigger('click'),
|
||||
callback: () => {
|
||||
$('#option_select_chat').trigger('click');
|
||||
return '';
|
||||
},
|
||||
aliases: ['chat-history', 'manage-chats'],
|
||||
helpString: 'Opens the chat manager for the current character/group.',
|
||||
}));
|
||||
|
Reference in New Issue
Block a user