diff --git a/src/lib/device.ts b/src/lib/device.ts index 9ede78353f3958ba08673b9d9aa5b05103a9d559..4e4f83a50fd675c179d8827e9f6a2ff975af579e 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); } }