fix: mimetype nil pointer

This commit is contained in:
krau
2025-06-20 22:42:57 +08:00
parent 336309fad0
commit 3b85911e3d
2 changed files with 4 additions and 4 deletions

View File

@@ -27,11 +27,11 @@ func GenFileNameFromMessage(message tg.Message) string {
if !ok {
return ""
}
ext := mimetype.Lookup(doc.MimeType).Extension()
if ext == "" {
mmt := mimetype.Lookup(doc.MimeType)
if mmt == nil || mmt.Extension() == "" {
return ""
}
return ext
return mmt.Extension()
case *tg.MessageMediaPhoto:
return ".jpg"
}