diff --git a/packages/dota/locales/en/translation.json b/packages/dota/locales/en/translation.json index fa8d8696..c24c9c4f 100644 --- a/packages/dota/locales/en/translation.json +++ b/packages/dota/locales/en/translation.json @@ -90,6 +90,14 @@ "total_one": "", "total_other": "Playing with {{count}} players from last game." }, + "connections": { + "overlay_zero": "No one connected to the overlay right now", + "overlay_one": "{{count}} streamer using the overlay", + "overlay_other": "{{count}} streamers using the overlay", + "gsi_zero": "No one using the Dotabod GSI right now", + "gsi_one": "{{count}} streamer connected to Dotabod GSI", + "gsi_other": "{{count}} streamers connected to Dotabod GSI" + }, "lastgamescore": { "double": "Double down", "duration": "{{minutes}}m long", diff --git a/packages/dota/src/twitch/commandLoader.ts b/packages/dota/src/twitch/commandLoader.ts index d1205b33..30846b1f 100644 --- a/packages/dota/src/twitch/commandLoader.ts +++ b/packages/dota/src/twitch/commandLoader.ts @@ -2,6 +2,7 @@ import './commands/apm.js' import './commands/avg.js' import './commands/beta.js' import './commands/commands.js' +import './commands/count.js' import './commands/d2pt.js' import './commands/delay.js' import './commands/dotabod.js' diff --git a/packages/dota/src/twitch/commands/count.ts b/packages/dota/src/twitch/commands/count.ts new file mode 100644 index 00000000..72dc0f4e --- /dev/null +++ b/packages/dota/src/twitch/commands/count.ts @@ -0,0 +1,25 @@ +import { t } from 'i18next' + +import { server } from '../../dota/index.js' +import { gsiHandlers } from '../../dota/lib/consts.js' +import { chatClient } from '../chatClient.js' +import commandHandler, { MessageType } from '../lib/CommandHandler.js' + +commandHandler.registerCommand('count', { + handler: async (message: MessageType, args: string[]) => { + const sockets = (await server.io.fetchSockets()).length + const gsiSize = gsiHandlers.size + + const bothParts = `${t('connections.gsi', { + lng: message.channel.client.locale, + channel: message.channel.name, + count: gsiSize, + })} ยท ${t('connections.overlay', { + lng: message.channel.client.locale, + channel: message.channel.name, + count: sockets, + })}` + + chatClient.say(message.channel.name, bothParts) + }, +})