feat: 增加日报货易通微信群组发送
This commit is contained in:
parent
f1346a604c
commit
11e0982845
|
|
@ -165,7 +165,7 @@ qywx:
|
|||
chat_id_len: 16
|
||||
default_config_id: 1
|
||||
bot_group_id:
|
||||
bbxt: 23
|
||||
bbxt: 37
|
||||
|
||||
default_prompt:
|
||||
img_recognize:
|
||||
|
|
|
|||
|
|
@ -148,6 +148,17 @@ dingtalk:
|
|||
bot_group_id:
|
||||
bbxt: 23
|
||||
|
||||
qywx:
|
||||
corp_id: "ww48151f694fb8ec67"
|
||||
app_secret: "uYqtdwdtdH4Uv_P4is2AChuGzBCoB6cQDyRvpbW0Vmk"
|
||||
token: "zJdukry6"
|
||||
aes_key: "4VLH47qRGUogc2d3QLWuUhvJlk8Y0YuRjXzeBquBq8B"
|
||||
init_account: "les.,FuZhongYun"
|
||||
chat_id_len: 16
|
||||
default_config_id: 1
|
||||
bot_group_id:
|
||||
bbxt: 36
|
||||
|
||||
|
||||
default_prompt:
|
||||
img_recognize:
|
||||
|
|
|
|||
|
|
@ -160,7 +160,7 @@ qywx:
|
|||
chat_id_len: 16
|
||||
default_config_id: 1
|
||||
bot_group_id:
|
||||
bbxt: 35
|
||||
bbxt: 36
|
||||
|
||||
default_prompt:
|
||||
img_recognize:
|
||||
|
|
|
|||
|
|
@ -3,11 +3,14 @@ package biz
|
|||
import (
|
||||
"ai_scheduler/internal/biz/handle/qywx"
|
||||
"ai_scheduler/internal/data/constants"
|
||||
errors "ai_scheduler/internal/data/error"
|
||||
"ai_scheduler/internal/data/impl"
|
||||
"ai_scheduler/internal/data/model"
|
||||
"ai_scheduler/internal/pkg"
|
||||
"ai_scheduler/internal/pkg/l_request"
|
||||
"ai_scheduler/internal/tools/bbxt"
|
||||
"context"
|
||||
"log"
|
||||
"strings"
|
||||
"time"
|
||||
|
||||
|
|
@ -105,3 +108,59 @@ func (q *QywxAppBiz) SendReport(ctx context.Context, groupInfo *model.AiBotGroup
|
|||
}
|
||||
return
|
||||
}
|
||||
|
||||
// SendReportV2 发送到货易通指定的群聊
|
||||
func (q *QywxAppBiz) SendReportHYT(ctx context.Context, groupInfo *model.AiBotGroupQywx, report *bbxt.ReportRes) (err error) {
|
||||
// 文本消息
|
||||
err = q.sendReportHYT(groupInfo, &bbxt.ReportRes{
|
||||
Title: report.Title,
|
||||
})
|
||||
if err != nil {
|
||||
return err
|
||||
}
|
||||
|
||||
time.Sleep(1 * time.Second) // 等待1秒,避免被频控
|
||||
|
||||
// 图片消息
|
||||
err = q.sendReportHYT(groupInfo, &bbxt.ReportRes{
|
||||
ReportName: report.ReportName,
|
||||
Url: report.Url,
|
||||
})
|
||||
if err != nil {
|
||||
return err
|
||||
}
|
||||
|
||||
time.Sleep(1 * time.Second) // 等待1秒,避免被频控
|
||||
|
||||
return nil
|
||||
}
|
||||
|
||||
func (q *QywxAppBiz) sendReportHYT(groupInfo *model.AiBotGroupQywx, report *bbxt.ReportRes) (err error) {
|
||||
req := l_request.Request{
|
||||
Method: "POST",
|
||||
Url: "https://hyt.86698.cn/admin_upload/api/v1/sendWxCommon",
|
||||
Headers: map[string]string{
|
||||
"Content-Type": "application/json",
|
||||
},
|
||||
Json: map[string]interface{}{
|
||||
"room_id": groupInfo.ChatID, // 群ID
|
||||
"oss_url": report.Url, // 图片URL
|
||||
"file_type": 2, // 文件类型,2:图片
|
||||
"file_name": report.ReportName, // 文件名称
|
||||
"content": report.Title, // 输入文本,此处有值就走文本发送,没有就走文件发送
|
||||
},
|
||||
}
|
||||
|
||||
resp, err := req.Send()
|
||||
if err != nil {
|
||||
return err
|
||||
}
|
||||
if resp.StatusCode != 200 {
|
||||
return errors.SysErrf("发送到货易通群聊失败,状态码:%d", resp.StatusCode)
|
||||
}
|
||||
|
||||
// 记录相应结果日志
|
||||
log.Printf("发送到货易通群聊成功,状态码:%d, 响应体:%s", resp.StatusCode, resp.Text)
|
||||
|
||||
return nil
|
||||
}
|
||||
|
|
|
|||
|
|
@ -28,5 +28,6 @@ func run() {
|
|||
botGroupQywxImpl := impl.NewBotGroupQywxImpl(db)
|
||||
qywxAuth := qywx.NewAuth(configConfig, rdb)
|
||||
group := qywx.NewGroup(botGroupQywxImpl, qywxAuth)
|
||||
qywxAppBiz = NewQywxAppBiz(configConfig, botGroupQywxImpl, group)
|
||||
other := qywx.NewOther(qywxAuth)
|
||||
qywxAppBiz = NewQywxAppBiz(configConfig, botGroupQywxImpl, group, other)
|
||||
}
|
||||
|
|
|
|||
Loading…
Reference in New Issue