From 1d951b02a203ad2f8c044ea313b9e0517ea37ada Mon Sep 17 00:00:00 2001 From: echicken <echicken@bbs.electronicchicken.com> Date: Mon, 29 Apr 2024 05:15:18 +0000 Subject: [PATCH] 'Fix' for string split w/regex, debug log, temporary crappy delay. --- src/lib/device.ts | 4 +++- 1 file changed, 3 insertions(+), 1 deletion(-) diff --git a/src/lib/device.ts b/src/lib/device.ts index 9ede783..4e4f83a 100644 --- a/src/lib/device.ts +++ b/src/lib/device.ts @@ -15,7 +15,7 @@ export function getRandomId(): number { } function chunkText(str: string): string[] { - const arr = str.trim().split(/(\s+)/); + const arr = str.trim().split(/(\s+)/.source); // .source as hack to work around some polyfill shenanigans w/RegExp & String.split const ret: string[] = []; let s: string = ''; // @ts-expect-error shut up @@ -399,12 +399,14 @@ export default abstract class Device extends js.global.EventEmitter { }: ITextMessageParams): void { const msgs = chunkText(text); for (const msg of msgs) { + if (this.debug) this.log(sbbsdefs.LOG_DEBUG, `Sending text: ${msg}`); // @ts-expect-error It's fucken ambient okay? const enc = new TextEncoder(); const payload = enc.encode(msg); if (payload.length > MAX_PAYLOAD) this.error(`sendText: payload length ${payload.length} exceeds maximum (${MAX_PAYLOAD})`); const res = this.sendPacket({ payload, portNum: protobuf.Portnums.PortNum.TEXT_MESSAGE_APP, to, channel, wantAck, ackHandler, replyId, hopLimit }); if (!res) this.error(`failed to send text message`); + js.global.mswait(100); } } -- GitLab