mirror of
https://github.com/SillyTavern/SillyTavern.git
synced 2025-06-05 21:59:27 +02:00
#1542 Skip system messages in TXT export
This commit is contained in:
@@ -10,9 +10,9 @@ const { DIRECTORIES, UPLOADS_PATH } = require('../constants');
|
|||||||
const { getConfigValue, humanizedISO8601DateTime, tryParse, generateTimestamp, removeOldBackups } = require('../util');
|
const { getConfigValue, humanizedISO8601DateTime, tryParse, generateTimestamp, removeOldBackups } = require('../util');
|
||||||
|
|
||||||
/**
|
/**
|
||||||
*
|
* Saves a chat to the backups directory.
|
||||||
* @param {string} name
|
* @param {string} name The name of the chat.
|
||||||
* @param {string} chat
|
* @param {string} chat The serialized chat to save.
|
||||||
*/
|
*/
|
||||||
function backupChat(name, chat) {
|
function backupChat(name, chat) {
|
||||||
try {
|
try {
|
||||||
@@ -65,7 +65,6 @@ router.post('/get', jsonParser, function (request, response) {
|
|||||||
return response.send({});
|
return response.send({});
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
if (!request.body.file_name) {
|
if (!request.body.file_name) {
|
||||||
return response.send({});
|
return response.send({});
|
||||||
}
|
}
|
||||||
@@ -140,7 +139,6 @@ router.post('/delete', jsonParser, function (request, response) {
|
|||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
return response.send('ok');
|
return response.send('ok');
|
||||||
});
|
});
|
||||||
|
|
||||||
@@ -190,6 +188,10 @@ router.post('/export', jsonParser, async function (request, response) {
|
|||||||
let buffer = '';
|
let buffer = '';
|
||||||
rl.on('line', (line) => {
|
rl.on('line', (line) => {
|
||||||
const data = JSON.parse(line);
|
const data = JSON.parse(line);
|
||||||
|
// Skip non-printable/prompt-hidden messages
|
||||||
|
if (data.is_system) {
|
||||||
|
return;
|
||||||
|
}
|
||||||
if (data.mes) {
|
if (data.mes) {
|
||||||
const name = data.name;
|
const name = data.name;
|
||||||
const message = (data?.extra?.display_text || data?.mes || '').replace(/\r?\n/g, '\n');
|
const message = (data?.extra?.display_text || data?.mes || '').replace(/\r?\n/g, '\n');
|
||||||
|
Reference in New Issue
Block a user