Skip to content

Commit

Permalink
chore: info messages on stream
Browse files Browse the repository at this point in the history
  • Loading branch information
hmbanan666 committed Dec 19, 2024
1 parent 46f1dfa commit b2e18db
Show file tree
Hide file tree
Showing 3 changed files with 21 additions and 4 deletions.
2 changes: 1 addition & 1 deletion apps/website/server/plugins/start.ts
Original file line number Diff line number Diff line change
Expand Up @@ -12,7 +12,7 @@ export default defineNitroPlugin(() => {
void twitchAddonController.serve()
void twitchWoodlandController.serve()

setTimeout(checkIfStreamingNow, 5000)
setTimeout(checkIfStreamingNow, 8000)

logger.info('Twitch server started')
})
Expand Down
18 changes: 18 additions & 0 deletions apps/website/server/utils/twitch/twitch.controller.ts
Original file line number Diff line number Diff line change
Expand Up @@ -92,6 +92,13 @@ class TwitchController {
setInterval(() => {
void this.#repository.updateManaOnProfiles()
}, 1000 * 60 * 60)

// Every 5 min info message
setInterval(() => {
if (twitchProvider.isStreaming === true) {
this.#bot.announce(this.#channel, this.getRandomInfoMessage())
}
}, 1000 * 60 * 5)
}

async serveStreamOnline() {
Expand All @@ -110,6 +117,17 @@ class TwitchController {
twitchProvider.isStreaming = false
})
}

getRandomInfoMessage(): string {
const messages = [
`Присоединяйся к рубке деревьев на стриме! Запусти приложение в Telegram: https://t.me/ChatGameSpaceBot`,
`Поддержи стримера: прямой донат с озвучкой сообщения https://www.donationalerts.com/r/hmbanan666`,
`Приобретай Монеты в ChatGame: https://chatgame.space/shop. Разблокируй вручную созданных персонажей. Спасибо за поддержку!`,
`Еще не подписан? Стань фолловером, подпишись на канал! Чем вас больше, тем больше интерактива создадим.`,
]

return messages[Math.floor(Math.random() * messages.length)] as string
}
}

export const twitchController = new TwitchController()
5 changes: 2 additions & 3 deletions apps/website/server/utils/twitch/twitch.provider.ts
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,6 @@ import type { AuthProvider } from '@twurple/auth'
import { createId } from '@paralleldrive/cuid2'
import { RefreshingAuthProvider } from '@twurple/auth'
import { DBRepository } from '../repository'
import { twitchAddonController } from './twitch.addon.controller'
import { twitchController } from './twitch.controller'

class TwitchProvider {
Expand Down Expand Up @@ -45,10 +44,10 @@ class TwitchProvider {

if (value) {
twitchController.startCouponGenerator()
void twitchAddonController.startCharacters()
// void twitchAddonController.startCharacters()
} else {
twitchController.stopCouponGenerator()
twitchAddonController.stopCharacters()
// twitchAddonController.stopCharacters()
}
}

Expand Down

0 comments on commit b2e18db

Please sign in to comment.