split matrix sent textwalls into individual messages for ppfun

This commit is contained in:
HF 2022-07-24 00:35:44 +02:00
parent 48f83239ef
commit bb010234e5

View File

@ -188,7 +188,15 @@ class PPfunMatrixBridge {
name = await this.getDisplayName(userId);
}
console.log(`MATRIX ${name}: ${msg}`);
this.sendPPfun(name, parseInt(uid, 10), msg, cid);
msg.split('\n').forEach((part) => {
let msgLine = part;
while (msgLine.length > 190) {
const msgPart = msgLine.slice(0, 190);
msgLine = msgLine.slice(190);
this.sendPPfun(name, parseInt(uid, 10), msgPart, cid);
}
this.sendPPfun(name, parseInt(uid, 10), msgLine, cid);
})
return;
}
@ -221,11 +229,15 @@ class PPfunMatrixBridge {
* uid needs to be a number
*/
sendPPfun(name, uid, msg, cid) {
const msgString = msg.trim();
if (!msgString.length) {
return;
}
this.ppfunSocket.emit(
'sendChatMessage',
(uid) ? name : `[mx] ${name}`,
uid || null,
msg,
msgString,
cid,
);
}