diff --git a/config.yaml b/config.yaml index b5a93a7e..c4b519be 100644 --- a/config.yaml +++ b/config.yaml @@ -6,6 +6,7 @@ wechat: autoSetCallback: false # 回调IP,如果是Docker运行,本参数必填(填auto表示自动,不适用于 docker 环境),如果Docker修改了映射,格式为 ip:port callback: 10.0.0.51 + imgPath: /data/ # 转发到其他地址 forward: # - 10.0.0.247:4299 diff --git a/config/wechat.go b/config/wechat.go index 7e6ec347..02f5a7f4 100644 --- a/config/wechat.go +++ b/config/wechat.go @@ -9,6 +9,7 @@ type wechat struct { AutoSetCallback bool `json:"autoSetCallback" yaml:"autoSetCallback"` // 是否自动设置回调地址 Callback string `json:"callback" yaml:"callback"` // 回调地址 Forward []string `json:"forward" yaml:"forward"` // 转发地址 + ImgPath string `json:"imgPath" yaml:"imgPath"` // 图片存储位置 } // Check diff --git a/docker-compose.yaml b/docker-compose.yaml index 92a04bf3..eaf3efb3 100644 --- a/docker-compose.yaml +++ b/docker-compose.yaml @@ -44,5 +44,6 @@ services: volumes: # 配置文件请参阅项目根目录的config.yaml文件 - ./config/config.yaml:/app/config.yaml + - ./imgData:/data ports: - "19099:19099" diff --git a/tasks/watergroup/month.go b/tasks/watergroup/month.go index aad80892..c0eca4db 100644 --- a/tasks/watergroup/month.go +++ b/tasks/watergroup/month.go @@ -2,6 +2,7 @@ package watergroup import ( "fmt" + "go-wechat/config" "go-wechat/service" "go-wechat/utils" "log" @@ -25,7 +26,7 @@ func Month() { yd := time.Now().Local().AddDate(0, 0, -1).Format("200601") // 发送词云 fileName := fmt.Sprintf("%s_%s.png", yd, group.Wxid) - utils.SendImage(group.Wxid, "D:\\Share\\wordcloud\\"+fileName, 0) + utils.SendImage(group.Wxid, config.Conf.Wechat.ImgPath+fileName, 0) } } diff --git a/tasks/watergroup/week.go b/tasks/watergroup/week.go index 7db3f54d..e95ae458 100644 --- a/tasks/watergroup/week.go +++ b/tasks/watergroup/week.go @@ -2,6 +2,7 @@ package watergroup import ( "fmt" + "go-wechat/config" "go-wechat/service" "go-wechat/utils" "log" @@ -25,7 +26,7 @@ func Week() { year, weekNo := time.Now().Local().AddDate(0, 0, -1).ISOWeek() // 发送词云 fileName := fmt.Sprintf("%d%d_%s.png", year, weekNo, group.Wxid) - utils.SendImage(group.Wxid, "D:\\Share\\wordcloud\\"+fileName, 0) + utils.SendImage(group.Wxid, config.Conf.Wechat.ImgPath+fileName, 0) } } diff --git a/tasks/watergroup/yesterday.go b/tasks/watergroup/yesterday.go index 42612374..5168a468 100644 --- a/tasks/watergroup/yesterday.go +++ b/tasks/watergroup/yesterday.go @@ -2,6 +2,7 @@ package watergroup import ( "fmt" + "go-wechat/config" "go-wechat/service" "go-wechat/utils" "log" @@ -27,7 +28,7 @@ func Yesterday() { yd := time.Now().Local().AddDate(0, 0, -1).Format("20060102") // 发送词云 fileName := fmt.Sprintf("%s_%s.png", yd, group.Wxid) - utils.SendImage(group.Wxid, "D:\\Share\\wordcloud\\"+fileName, 0) + utils.SendImage(group.Wxid, config.Conf.Wechat.ImgPath+fileName, 0) } }