mirror of
https://github.com/SillyTavern/SillyTavern.git
synced 2025-06-05 21:59:27 +02:00
Poe API fixed
This commit is contained in:
24
poe.js
24
poe.js
@@ -252,9 +252,22 @@ class Client {
|
||||
}
|
||||
}
|
||||
|
||||
on_message(ws, msg) {
|
||||
async on_message(ws, msg) {
|
||||
try {
|
||||
const data = JSON.parse(msg);
|
||||
const message = JSON.parse(data["messages"][0])["payload"]["data"]["messageAdded"];
|
||||
|
||||
if (!('messages' in data)) {
|
||||
return;
|
||||
}
|
||||
|
||||
for (const message_str of data["messages"]) {
|
||||
const message_data = JSON.parse(message_str);
|
||||
|
||||
if (message_data["message_type"] != "subscriptionUpdate"){
|
||||
continue;
|
||||
}
|
||||
|
||||
const message = message_data["payload"]["data"]["messageAdded"]
|
||||
|
||||
const copiedDict = Object.assign({}, this.active_messages);
|
||||
for (const [key, value] of Object.entries(copiedDict)) {
|
||||
@@ -271,6 +284,13 @@ class Client {
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
catch (err) {
|
||||
console.log('Error occurred in onMessage', err);
|
||||
this.disconnect_ws();
|
||||
await this.connect_ws();
|
||||
}
|
||||
}
|
||||
|
||||
async *send_message(chatbot, message, with_chat_break = false, timeout = 20) {
|
||||
//if there is another active message, wait until it has finished sending
|
||||
|
Reference in New Issue
Block a user