修改文件类型匹配策略

This commit is contained in:
eatmoreapple 2022-12-09 22:06:47 +08:00
parent 4063e369bd
commit c9e4e842d9
2 changed files with 10 additions and 8 deletions

View File

@ -115,6 +115,7 @@ var (
) )
// ALL 跟search函数搭配 // ALL 跟search函数搭配
//
// friends.Search(openwechat.ALL, ) // friends.Search(openwechat.ALL, )
const ALL = 0 const ALL = 0
@ -137,11 +138,11 @@ const (
const TimeFormat = "Mon Jan 02 2006 15:04:05 GMT+0800 (中国标准时间)" const TimeFormat = "Mon Jan 02 2006 15:04:05 GMT+0800 (中国标准时间)"
var imageType = map[string]bool{ var imageType = map[string]struct{}{
"bmp": true, "bmp": {},
"png": true, "png": {},
"jpeg": true, "jpeg": {},
"jpg": true, "jpg": {},
} }
var videoType = "mp4" var videoType = "mp4"

View File

@ -81,9 +81,10 @@ const (
// 微信匹配文件类型策略 // 微信匹配文件类型策略
func getMessageType(filename string) string { func getMessageType(filename string) string {
ext := getFileExt(filename) ext := getFileExt(filename)
if imageType[ext] { if _, ok := imageType[ext]; ok {
return pic return pic
} else if ext == videoType { }
if ext == videoType {
return video return video
} }
return doc return doc