Auto-balance quotes on streaming

This commit is contained in:
Cohee
2023-06-17 20:23:03 +03:00
parent 64fcb4b1f0
commit 2edebec52c

View File

@@ -1631,10 +1631,13 @@ class StreamingProcessor {
let isName = result.this_mes_is_name;
processedText = result.getMessage;
// Predict unbalanced asterisks during streaming
if (!isFinal && isOdd(countOccurrences(processedText, '*'))) {
// Add asterisk at the end to balance it
processedText = processedText.trimEnd() + '*';
// Predict unbalanced asterisks / quotes during streaming
const charsToBalance = ['*', '"'];
for (const char of charsToBalance) {
if (!isFinal && isOdd(countOccurrences(processedText, char))) {
// Add character at the end to balance it
processedText = processedText.trimEnd() + char;
}
}
if (isImpersonate) {