Skip to content

Commit

Permalink
fix: , in beginning of the text
Browse files Browse the repository at this point in the history
  • Loading branch information
crazywoola committed Sep 21, 2023
1 parent 8e55cdb commit ae2fa9c
Showing 1 changed file with 9 additions and 3 deletions.
12 changes: 9 additions & 3 deletions src/util.ts
Original file line number Diff line number Diff line change
Expand Up @@ -25,10 +25,16 @@ export function streamParser(data: string): any {
const json = JSON.parse(message.slice(6).trim());
if (json.event === 'ping') continue;
if (json.event === 'message') {
const parsedMessage = unicodeToChar(json['answer']);
if (parsedMessage.trim() !== ',') {
results.push(parsedMessage);
const answer = json['answer'];
let parsedMessage = '';

if (Array.isArray(answer)) {
parsedMessage = answer.map(item => unicodeToChar(item)).join(' '); // adjust the join character as needed
} else {
parsedMessage = unicodeToChar(answer);
}

results.push(parsedMessage);
}
} catch (e) {
error(`Error parsing: ${message}`);
Expand Down

0 comments on commit ae2fa9c

Please sign in to comment.