diff --git a/config/config.sample.yaml b/config/config.sample.yaml index 9d83ddd4a084a0798becb6cfc41e0ee4d2ad8051..99a86e78f3f092807b342f1bbe17d3dcc4f92e98 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 8862531c66e8ba441b907e2b94acf79757856984..1f587bd0c9a579cbb7abe3bf39d1c94d80c225ef 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 59e4099de4f1d4c00d961e873aa017599ad1f66b..a66964c2f47a03aa17f229d84b4aab50397af691 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 2b118924725f3e774fd7c1d56cfd9302900038e8..b105e16c48affd8c71b605b29c90e0c3af40e928 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;