Skip to content

Commit

Permalink
mediagroup: only resend failed link(media) with backup url
Browse files Browse the repository at this point in the history
  • Loading branch information
makeding committed Nov 4, 2024
1 parent 00aa9dd commit 62bb3ea
Show file tree
Hide file tree
Showing 2 changed files with 27 additions and 0 deletions.
16 changes: 16 additions & 0 deletions app.js
Original file line number Diff line number Diff line change
Expand Up @@ -735,6 +735,22 @@ async function sendMediaGroupWithRetry(chat_id, language_code, mg, extra, mg_typ
return await bot.api.sendMediaGroup(chat_id, await mg_filter([...mg], current_mg_type, has_spoiler, show_caption_above_media), extra)
} catch (e) {
let status = await catchily(e, chat_id, language_code)
// Bad Request: failed to send message #1 with the error message "WEBPAGE_MEDIA_EMPTY"
// Bad Request: failed to send message #2 with the error message "WEBPAGE_CURL_FAILED"
if (e.description && e.description.includes('failed to send message') && e.description.includes('#')) {
status = 'redo'
let mg_index = e.description.split(' ').find(x=>{
return x.startsWith('#')
})
if (mg_index) {
mg_index = parseInt(mg_index.substring(1)) - 1
if (mg[mg_index].invaild) {
mg[mg_index].invaild = [current_mg_type]
}else {
mg[mg_index].invaild.push(current_mg_type)
}
}
}
if (status) {
if (status === 'redo') {
mg_type.unshift(current_mg_type)
Expand Down
11 changes: 11 additions & 0 deletions handlers/telegram/mediagroup.js
Original file line number Diff line number Diff line change
Expand Up @@ -171,6 +171,17 @@ export async function mg_filter(mg, type = 't', has_spoiler = false) {
type = 'dlr'
}
}
if (x.invaild.includes('o') && x.invaild.includes('r')) {
// ?
if(x.invaild.includes('dlo')) {
type = 'dlr'
} else {
type = 'dlo'
}
} else if (type === 'o' && x.invaild.includes(type)) {
type = 'r'
}

if (type.includes('dl') && !x.media_t) {
// dlo => download media_o file
// dlr => download media_r file
Expand Down

0 comments on commit 62bb3ea

Please sign in to comment.