Skip to content

Commit

Permalink
refactor: rename config vars from channel to group for tg
Browse files Browse the repository at this point in the history
  • Loading branch information
TurtIeSocks committed Jan 27, 2024
1 parent 8c9d08a commit 854a218
Show file tree
Hide file tree
Showing 3 changed files with 16 additions and 9 deletions.
6 changes: 4 additions & 2 deletions server/src/configs/default.json
Original file line number Diff line number Diff line change
Expand Up @@ -682,8 +682,10 @@
{
"name": "telegram",
"type": "telegram",
"scanNextLogChannelId": "",
"scanZoneLogChannelId": "",
"logGroupId": "",
"scanNextLogGroupId": "",
"scanZoneLogGroupId": "",
"eventLogGroupId": "",
"enabled": false,
"botToken": "",
"groups": [],
Expand Down
11 changes: 8 additions & 3 deletions server/src/services/EventManager.js
Original file line number Diff line number Diff line change
Expand Up @@ -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() {
Expand Down Expand Up @@ -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')
}
}),
Expand Down
8 changes: 4 additions & 4 deletions server/src/services/TelegramClient.js
Original file line number Diff line number Diff line change
Expand Up @@ -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,
}
}

Expand Down

0 comments on commit 854a218

Please sign in to comment.