Closed y0unghe closed 2 months ago
Hello, @y0unghe. What's in the logs?
Could be an issue related to location. It was mine too. i see you are from china. still i cant say for sure without seeing the logs. But try using a vpn and set it to any country like US. I'm from india and it worked for me
I am following the tutorial on how to create a telegram bot. I got the token and am listening to messages. But when I was typing in my bot, nothing happened. I am wondering how the telegram bot connects to my computer.
import TelegramBot from 'node-telegram-bot-api'; const token = '6588289377:AAGENT2zoM-19hCIlgE2Woss2RQXsB5-nOM'; const bot = new TelegramBot(token, { polling: true }); bot.on('message', (msg) => { console.log(msg); var Hi = "hi"; if (msg.text.toString().toLowerCase().indexOf(Hi) === 0) { bot.sendMessage(msg.chat.id, "Hello dear user"); } });
If you have a error you can get more information adding this code:
bot.on('polling_error', (error) => {
// console.log(error)
console.log("Polling error code: ",error.code);
console.log("Error Message: ", error.message);
console.log("Stack trace: ", error.stack);
});
The problem could be that you are in a country or under an internet provider that has the domain "https://api.telegram.org" blocked, so your bot cannot communicate with the Telegram servers to receive updates.
I am following the tutorial on how to create a telegram bot. I got the token and am listening to messages. But when I was typing in my bot, nothing happened. I am wondering how the telegram bot connects to my computer.