Skip to content

Commit

Permalink
only when channel is live use openai crontab of 30min
Browse files Browse the repository at this point in the history
  • Loading branch information
lluisd committed Nov 17, 2024
1 parent 8eeba6d commit 4c81b49
Showing 1 changed file with 6 additions and 2 deletions.
8 changes: 6 additions & 2 deletions lib/notifier.js
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,7 @@ const TelegramBot = require('node-telegram-bot-api')
const config = require('../config')
const cron = require('node-cron')
const handlers = require('../handlers')
const TwitchService = require('../services/twitch')

class Notifier {
constructor (twitchBot) {
Expand Down Expand Up @@ -36,8 +37,11 @@ class Notifier {
})

cron.schedule('*/30 * * * *', async () => {
const text = 'como si fueras un usuario del chat de forma aleatoria alguna curiosidad del streamer o de su chat anecdótica o de dato curioso para compartir'
await handlers.openAI.askOpenAI(this.target, text, null, this.twitchBot)
const channel = await TwitchService.getChannel()
if (channel.live) {
const text = 'como si fueras un usuario del chat de forma aleatoria alguna curiosidad del streamer o de su chat anecdótica o de dato curioso para compartir'
await handlers.openAI.askOpenAI(this.target, text, null, this.twitchBot)
}
})

return Promise.resolve()
Expand Down

0 comments on commit 4c81b49

Please sign in to comment.