From bebeb2e3a66ed340169cf007db6e1f8ff6ebc4e8 Mon Sep 17 00:00:00 2001 From: Will Hunt <half-shot@molrams.com> Date: Mon, 18 Sep 2017 00:22:06 +0100 Subject: [PATCH] Add config item for presence interval. --- config/config.sample.yaml | 1 + config/config.schema.yaml | 2 ++ src/bot.ts | 6 ++++-- src/config.ts | 1 + 4 files changed, 8 insertions(+), 2 deletions(-) diff --git a/config/config.sample.yaml b/config/config.sample.yaml index 9d83ddd..99a86e7 100644 --- a/config/config.sample.yaml +++ b/config/config.sample.yaml @@ -1,6 +1,7 @@ bridge: domain: "localhost" homeserverUrl: "http://localhost:8008" + presenceInterval: 500, disablePresence: false disableTypingNotifications: false disableDiscordMentions: false diff --git a/config/config.schema.yaml b/config/config.schema.yaml index 8862531..1f587bd 100644 --- a/config/config.schema.yaml +++ b/config/config.schema.yaml @@ -10,6 +10,8 @@ properties: type: "string" homeserverUrl: type: "string" + presenceInterval: + type: "number" disablePresence: type: "boolean" disableTypingNotifications: diff --git a/src/bot.ts b/src/bot.ts index 59e4099..a66964c 100644 --- a/src/bot.ts +++ b/src/bot.ts @@ -16,7 +16,7 @@ import * as path from "path"; // Due to messages often arriving before we get a response from the send call, // messages get delayed from discord. const MSG_PROCESS_DELAY = 750; -const PRESENCE_UPDATE_DELAY = 3000; +const MIN_PRESENCE_UPDATE_DELAY = 250; class ChannelLookupResult { public channel: Discord.TextChannel; public botUser: boolean; @@ -86,7 +86,9 @@ export class DiscordBot { this.presenceHandler.EnqueueMember(member); }) }) - this.presenceHandler.Start(PRESENCE_UPDATE_DELAY); + this.presenceHandler.Start( + Math.max(this.config.bridge.presenceInterval, MIN_PRESENCE_UPDATE_DELAY) + ); } }); } diff --git a/src/config.ts b/src/config.ts index 2b11892..b105e16 100644 --- a/src/config.ts +++ b/src/config.ts @@ -11,6 +11,7 @@ export class DiscordBridgeConfig { class DiscordBridgeConfigBridge { public domain: string; public homeserverUrl: string; + public presenceInterval: number = 500; public disablePresence: boolean; public disableTypingNotifications: boolean; public disableDiscordMentions: boolean; -- GitLab