You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
When a telegram bot is hosted on Vercel, it cannot respond with a delay to a request. But it works when I run the bot on my computer. I'm assuming Vercel either can't process or is blocking requests nested in setTimeout. Could you give me a hint to help solve this problem?
importTeleBotfrom"telebot";importdotenvfrom"dotenv";dotenv.config();constbot=newTeleBot({token: process.env.BOT_TOKEN});bot.on("/start",async(msg)=>{awaitbot.sendMessage(msg.chat.id,"Hello!");});bot.on("text",async(msg)=>{if(msg.entities){varwasBotMentioned=msg.text.includes("bot_name");}constchatType=msg.chat.type;if(chatType==="private"||(chatType==="supergroup"&&wasBotMentioned)||(chatType==="group"&&wasBotMentioned)){awaitbot.sendMessage(msg.chat.id,"answer instantly");// on Vercel: it works. | In dev mode: it workssetTimeout(async()=>{awaitbot.sendMessage(msg.chat.id,"answer delay");//on Vercel: answer in timeout won't work. Also there are no errors. | In dev mode: it works},2000);}});
reacted with thumbs up emoji reacted with thumbs down emoji reacted with laugh emoji reacted with hooray emoji reacted with confused emoji reacted with heart emoji reacted with rocket emoji reacted with eyes emoji
Uh oh!
There was an error while loading. Please reload this page.
Problem Description
When a telegram bot is hosted on Vercel, it cannot respond with a delay to a request. But it works when I run the bot on my computer. I'm assuming Vercel either can't process or is blocking requests nested in setTimeout. Could you give me a hint to help solve this problem?
All reactions