diff --git a/server/src/configs/default.json b/server/src/configs/default.json index 1c396b3a0..9379317fe 100644 --- a/server/src/configs/default.json +++ b/server/src/configs/default.json @@ -682,8 +682,10 @@ { "name": "telegram", "type": "telegram", - "scanNextLogChannelId": "", - "scanZoneLogChannelId": "", + "logGroupId": "", + "scanNextLogGroupId": "", + "scanZoneLogGroupId": "", + "eventLogGroupId": "", "enabled": false, "botToken": "", "groups": [], diff --git a/server/src/services/EventManager.js b/server/src/services/EventManager.js index e23f03db9..1c3ee3581 100644 --- a/server/src/services/EventManager.js +++ b/server/src/services/EventManager.js @@ -10,6 +10,7 @@ const { generate, read } = require('@rm/masterfile') const PoracleAPI = require('./api/Poracle') const { getCache, setCache } = require('./cache') +const DiscordClient = require('./DiscordClient') class EventManager { constructor() { @@ -116,19 +117,23 @@ class EventManager { /** * - * @param {import('discord.js').APIEmbed} embed + * @param {import('discord.js').APIEmbed | string} embed * @param {string} [clientName] */ async chatLog(embed, clientName) { if (clientName) { const client = this.Clients[clientName] - if ('sendMessage' in client) { + if (client instanceof DiscordClient && typeof embed === 'object') { + await client.sendMessage(embed, 'event') + } else if (typeof embed === 'string') { await client.sendMessage(embed, 'event') } } else { await Promise.allSettled( Object.values(this.Clients).map(async (client) => { - if ('sendMessage' in client) { + if (client instanceof DiscordClient && typeof embed === 'object') { + await client.sendMessage(embed, 'event') + } else if (typeof embed === 'string') { await client.sendMessage(embed, 'event') } }), diff --git a/server/src/services/TelegramClient.js b/server/src/services/TelegramClient.js index fe898f724..80bab455d 100644 --- a/server/src/services/TelegramClient.js +++ b/server/src/services/TelegramClient.js @@ -28,10 +28,10 @@ class TelegramClient { 'authentication.alwaysEnabledPerms', ) this.loggingChannels = { - main: strategy.logChannelId, - event: strategy.eventLogChannelId, - scanNext: strategy.scanNextLogChannelId, - scanZone: strategy.scanZoneLogChannelId, + main: strategy.logGroupId, + event: strategy.eventLogGroupId, + scanNext: strategy.scanNextLogGroupId, + scanZone: strategy.scanZoneLogGroupId, } }