I'd like to create a telegram bot with JS with the only one function - sending a message in a specific period of time. How to connect console and bot?

Viewed 18

This is my first experience with a bot creating. I wrote a simple code and it works, but it shows me a message only in console. How to redirect it to the bot? My code:

import express from 'express'
import { PORT, TOKEN } from './config.js'
import { msg } from './message.js'
import { Telegraf } from 'telegraf'

const app = express()
const AndressBot = new Telegraf(TOKEN)

const startTime = new Date()
startTime.setHours(10, 0)
const endTime = new Date()
endTime.setHours(21, 0)
const currentTime = new Date()

if(startTime.getTime() < currentTime.getTime() && endTime.getTime() > currentTime.getTime()) {
 const timer = setInterval (function queue() {
    console.log(msg)
 }, 1000)
}

AndressBot.launch()

And message.js:

export const msg = 'some text'
0 Answers
Related