【发布时间】:2019-06-18 08:11:41
【问题描述】:
请帮我解决这个问题,我得到了 polling_error
我要在电报中创建一个机器人并为我自己定制它
但是当我运行程序时,我遇到了一些这样的错误:
node-telegram-bot-api 已弃用 自动启用取消承诺已弃用。
还有一个像这样的错误:
错误:[polling_error] {"code":"ETELEGRAM","message":"ETELEGRAM: 401 Unauthorized"}
我该如何解决这个问题?
完整的代码在这里:
const TelegramBot = require('node-telegram-bot-api');
const token = '***';
const bot = new TelegramBot(token, {polling: true});
bot.on('message', (msg) => {
let Hi = "hi";
if (msg.text.toString().toLowerCase().indexOf(Hi) === 0) {
bot.sendMessage(msg.chat.id,"Hello dear user");
}
});
【问题讨论】:
-
401表示Unauthorized。令牌有效吗?可以尝试使用新生成的令牌吗? -
是的。确切地。解决这个问题,谢谢,但“polling_error”还存在
标签: node.js