diff --git a/ppfun-bridge/src/ppfunMatrixBridge.js b/ppfun-bridge/src/ppfunMatrixBridge.js index d3612db..5388afc 100644 --- a/ppfun-bridge/src/ppfunMatrixBridge.js +++ b/ppfun-bridge/src/ppfunMatrixBridge.js @@ -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, ); }