From b784d6d70b8718f8c7c2201311afe7305d7ea074 Mon Sep 17 00:00:00 2001 From: Will Hunt <will@half-shot.uk> Date: Sun, 19 May 2019 21:35:42 +0100 Subject: [PATCH] Linting --- src/bot.ts | 4 ++-- test/test_discordbot.ts | 18 ++++++++++-------- 2 files changed, 12 insertions(+), 10 deletions(-) diff --git a/src/bot.ts b/src/bot.ts index a44459c..2c7ec05 100644 --- a/src/bot.ts +++ b/src/bot.ts @@ -81,7 +81,7 @@ export class DiscordBot { /* Handles messages queued up to be sent to matrix from discord. */ private discordMessageQueue: { [channelId: string]: Promise<void> }; - private channelLocks: Map<string,{i: NodeJS.Timeout|null, r: (() => void)|null}>; + private channelLocks: Map<string, {i: NodeJS.Timeout|null, r: (() => void)|null}>; private channelLockPromises: Map<string, Promise<{}>>; constructor( private botUserId: string, @@ -445,7 +445,7 @@ export class DiscordBot { try { this.lockChannel(chan); if (!botUser) { - opts.embed = embedSet.replyEmbed; + // NOTE: Don't send replies to discord if we are a puppet. msg = await chan.send(embed.description, opts); } else if (hook) { msg = await hook.send(embed.description, { diff --git a/test/test_discordbot.ts b/test/test_discordbot.ts index 4117d25..769c9ee 100644 --- a/test/test_discordbot.ts +++ b/test/test_discordbot.ts @@ -426,32 +426,34 @@ describe("DiscordBot", () => { ) as DiscordBot; const chan = new MockChannel("123") as any; const t = Date.now(); - await bot.lockChannel(chan); + bot.lockChannel(chan); await bot.waitUnlock(chan); const diff = Date.now() - t; expect(diff).to.be.greaterThan(config.limits.discordSendDelay - 1); }); it("should lock and unlock a channel early, if unlocked", async () => { + const discordSendDelay = 500; + const SHORTDELAY = 100; const bot = new modDiscordBot.DiscordBot( "", - { - limits: { - discordSendDelay: 500, - }, + { bridge: { domain: "localhost", - } + }, + limits: { + discordSendDelay, + }, }, mockBridge, {}, ) as DiscordBot; const chan = new MockChannel("123") as any; - setTimeout(() => bot.unlockChannel(chan), 100); + setTimeout(() => bot.unlockChannel(chan), SHORTDELAY); const t = Date.now(); bot.lockChannel(chan); await bot.waitUnlock(chan); const diff = Date.now() - t; - expect(diff).to.be.lessThan(110); + expect(diff).to.be.greaterThan(SHORTDELAY); }); }); // }); -- GitLab