我想在电报中使用 webHook,但我不知道如何正确使用它。
这是我的简单代码。但它仍然使用轮询。
const Telegraf = require('telegraf');
const bot = new Telegraf('123:ABC');
bot.telegram.setWebhook('https://myaddress.com');
bot.startWebhook(`/`, null, 4000);
bot.use(function(ctx, next){
try{
if(ctx.chat == undefined) return;
console.log("Hello World");
}catch (e){
console.log("Error");
}
});
bot.launch();