Skip to content

Commit

Permalink
修复了一个BUG:受限于 tgbot接口限制,文件过大(20M)时,通过TGbot上传会失败并陷入死循环。感谢TG:159357提醒
Browse files Browse the repository at this point in the history
  • Loading branch information
wzs8 committed Nov 18, 2024
1 parent 199555a commit ea035d6
Showing 1 changed file with 8 additions and 0 deletions.
8 changes: 8 additions & 0 deletions src/controllers/tgbotController.js
Original file line number Diff line number Diff line change
Expand Up @@ -53,6 +53,14 @@ export const tgbotController = {

// 获取文件并上传
const fileInfo = await getFileInfo(c.env.TG_BOT_TOKEN, fileId);

// 添加文件信息检查
if (!fileInfo || !fileInfo.file_path) {
await sendTelegramMessage(c.env.TG_BOT_TOKEN, chatId,
'获取文件链接失败,大概率是文件过大,最大为20MB');
return c.json({ success: true });
}

const fileUrl = `https://api.telegram.org/file/bot${c.env.TG_BOT_TOKEN}/${fileInfo.file_path}`;

const response = await fetch(fileUrl);
Expand Down

0 comments on commit ea035d6

Please sign in to comment.