diff --git a/public/script.js b/public/script.js index 2f95ad786..cef4028d1 100644 --- a/public/script.js +++ b/public/script.js @@ -1527,7 +1527,6 @@ function scrollChatToBottom() { function substituteParams(content, _name1, _name2, _original) { _name1 = _name1 ?? name1; _name2 = _name2 ?? name2; - _original = _original || ''; if (!content) { return ''; @@ -1536,7 +1535,9 @@ function substituteParams(content, _name1, _name2, _original) { // Replace {{original}} with the original message // Note: only replace the first instance of {{original}} // This will hopefully prevent the abuse - content = content.replace(/{{original}}/i, _original); + if (typeof _original === 'string') { + content = content.replace(/{{original}}/i, _original); + } content = content.replace(/{{input}}/gi, $('#send_textarea').val()); content = content.replace(/{{user}}/gi, _name1); content = content.replace(/{{char}}/gi, _name2); diff --git a/public/scripts/stats.js b/public/scripts/stats.js index 3629178e3..7a60df89f 100644 --- a/public/scripts/stats.js +++ b/public/scripts/stats.js @@ -256,6 +256,19 @@ async function statMesProcess(line, type, characters, this_chid, oldMesssage) { let stat = charStats[characters[this_chid].avatar]; + if (!stat) { + stat = { + total_gen_time: 0, + user_word_count: 0, + non_user_msg_count: 0, + user_msg_count: 0, + non_user_msg_count: 0, + total_swipe_count: 0, + date_first_chat: Date.now(), + date_last_chat: Date.now(), + }; + } + stat.total_gen_time += calculateGenTime( line.gen_started, line.gen_finished