javascript - Telegram Bot API:使用 getUserProfilePhotos() 时服务器关闭
问题描述
语境
我将 telegraf.js 用于 3 个以上的机器人,它们在很多组中运行良好。目前其中一个机器人需要请求没有显示图片的用户的显示图片。
它按预期工作得很好,但不幸的是,机器人抛出了一个错误,服务器宕机了
当前代码
// Request for display picture
const requestDP = async (ctx, next) => {
const { from, chat } = ctx.message;
const { can_delete_messages:canDelete } = await deletePermision(ctx);
let totalDPs = 1;
totalDPs = await ctx.telegram.getUserProfilePhotos(ctx.message.from.id)
.then((result) => result.total_count)
.catch((err) => {
console.log(err);
});
if (totalDPs != 0) return next();
if ((chat.id === -1001341734527 || chat.id === -1001083711103 ) && canDelete) {
await ctx.deleteMessage().then((response) => response, ({ response }) => response.ok);
await ctx.replyWithMarkdown(`[${from.first_name||''} ${from.last_name||''}](tg://user?id=${from.id}), പ്രൊഫൈൽ ഫോട്ടോ ഇല്ലാത്തവർക്ക് ഗ്രൂപിൽ മെസേജ് അയക്കാൻ സാധ്യമല്ല`)
.then(({ message_id }) => setTimeout(() => ctx.deleteMessage(message_id), 5 * 60 * 1000))
.catch((err) => console.log("Error in prevencontacts: " + err));
}
}
module.exports = requestDP;
失败信息(针对错误)
let totalDPs = 1;
totalDPs = await ctx.telegram.getUserProfilePhotos(ctx.message.from.id)
.then((result) => result.total_count)
.catch((err) => {
console.log(err);
});
这些功能似乎运行良好。但不幸的是,有时他们会收到一个错误,然后服务器就宕机了。错误信息
Error: 400: Bad Request: request for new profile photos has already been sent
偶尔刷新服务器真的很难:-(
有什么解决方案来管理这个错误吗?
解决方案
推荐阅读
- regex - ORACLE 查询:当值名称中包含“/”时选择文本
- path - Ansible - 将环境路径设置为库存变量
- php - How a placeholder in a prepared statement calls a value in an associative array?
- vba - excel - 根据图例更改颜色条形图
- javascript - 隐藏当 document.click 时,显示当搜索框点击时(php mysql)
- vba - 带有like语句的OUTLOOK vba过滤器
- laravel - 使用模式窗口更新行后刷新数据表
- php - 将 data-mfp-src 属性添加到图像标签 PHP
- sql - SQL Server:带案例查看
- java - 在 Hybris 中找出模型属性发生变化的地方