main: fixes downloads cleanup
This commit is contained in:
parent
aefb4ce673
commit
26452d0f53
6 changed files with 20 additions and 112 deletions
|
@ -88,6 +88,15 @@ func SendMedias(
|
|||
for _, chunk := range mediaGroupChunks {
|
||||
var inputMediaList []gotgbot.InputMedia
|
||||
for idx, media := range chunk {
|
||||
// always clean up files, in case of error
|
||||
defer func() {
|
||||
if media.FilePath != "" {
|
||||
os.Remove(media.FilePath)
|
||||
}
|
||||
if media.ThumbnailFilePath != "" {
|
||||
os.Remove(media.ThumbnailFilePath)
|
||||
}
|
||||
}()
|
||||
var caption string
|
||||
|
||||
if idx == 0 {
|
||||
|
@ -114,15 +123,6 @@ func SendMedias(
|
|||
return nil, err
|
||||
}
|
||||
|
||||
for _, media := range chunk {
|
||||
if media.FilePath != "" {
|
||||
os.Remove(media.FilePath)
|
||||
}
|
||||
if media.ThumbnailFilePath != "" {
|
||||
os.Remove(media.ThumbnailFilePath)
|
||||
}
|
||||
}
|
||||
|
||||
sentMessages = append(sentMessages, msgs...)
|
||||
if sentMessages[0].Chat.Type != "private" {
|
||||
if len(mediaGroupChunks) > 1 {
|
||||
|
|
|
@ -20,6 +20,7 @@ func getInstanceMessage() string {
|
|||
"branch: <a href='%s'>%s</a>\n\n" +
|
||||
"public instances\n" +
|
||||
"- @govd_bot | main official instance\n" +
|
||||
"- @govd_pingu_bot | pingu instance\n" +
|
||||
"\nwant to add your own instance? reach us on @govdsupport"
|
||||
}
|
||||
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue