mirror of
https://github.com/SillyTavern/SillyTavern.git
synced 2025-03-02 19:07:40 +01:00
add macro for first included message in context
This commit is contained in:
parent
1b11ddc26a
commit
2bdd3672d4
@ -2017,6 +2017,20 @@ function getLastMessageId() {
|
||||
return '';
|
||||
}
|
||||
|
||||
/**
|
||||
* Returns the ID of the first message included in the context.
|
||||
* @returns {string} The ID of the first message in the context.
|
||||
*/
|
||||
function getFirstIncludedMessageId() {
|
||||
const index = document.querySelector('.lastInContext')?.getAttribute('mesid');
|
||||
|
||||
if (!isNaN(index) && index >= 0) {
|
||||
return String(index);
|
||||
}
|
||||
|
||||
return '';
|
||||
}
|
||||
|
||||
/**
|
||||
* Returns the last message in the chat.
|
||||
* @returns {string} The last message in the chat.
|
||||
@ -2119,6 +2133,7 @@ function substituteParams(content, _name1, _name2, _original, _group, _replaceCh
|
||||
content = content.replace(/{{group}}/gi, _group);
|
||||
content = content.replace(/{{lastMessage}}/gi, getLastMessage());
|
||||
content = content.replace(/{{lastMessageId}}/gi, getLastMessageId());
|
||||
content = content.replace(/{{firstIncludedMessageId}}/gi, getFirstIncludedMessageId());
|
||||
content = content.replace(/{{lastSwipeId}}/gi, getLastSwipeId());
|
||||
content = content.replace(/{{currentSwipeId}}/gi, getCurrentSwipeId());
|
||||
|
||||
|
Loading…
x
Reference in New Issue
Block a user