Skip to content

Commit

Permalink
new: add !count command
Browse files Browse the repository at this point in the history
  • Loading branch information
Geczy committed Sep 19, 2023
1 parent 3cbd9ed commit 8b56453
Show file tree
Hide file tree
Showing 3 changed files with 34 additions and 0 deletions.
8 changes: 8 additions & 0 deletions packages/dota/locales/en/translation.json
Original file line number Diff line number Diff line change
Expand Up @@ -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",
Expand Down
1 change: 1 addition & 0 deletions packages/dota/src/twitch/commandLoader.ts
Original file line number Diff line number Diff line change
Expand Up @@ -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'
Expand Down
25 changes: 25 additions & 0 deletions packages/dota/src/twitch/commands/count.ts
Original file line number Diff line number Diff line change
@@ -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)
},
})

0 comments on commit 8b56453

Please sign in to comment.