新增一个简易的AI机器人

This commit is contained in:
李寻欢
2023-11-13 13:32:42 +08:00
parent d08937563a
commit 60bfa0e8a0
8 changed files with 81 additions and 2 deletions

View File

@@ -18,18 +18,30 @@ func SendMessage(toId, atId, msg string, retryCount int) {
log.Printf("重试五次失败,停止发送")
return
}
// 组装参数
param := map[string]any{
"wxid": toId, // 群或好友Id
"msg": msg, // 消息
}
// 接口地址
apiUrl := config.Conf.Wechat.GetURL("/api/sendTextMsg")
if atId != "" {
apiUrl = config.Conf.Wechat.GetURL("/api/sendAtText")
param = map[string]any{
"chatRoomId": toId,
"wxids": atId,
"msg": msg, // 消息
}
}
pbs, _ := json.Marshal(param)
res := resty.New()
resp, err := res.R().
SetHeader("Content-Type", "application/json;chartset=utf-8").
SetBody(string(pbs)).
Post(config.Conf.Wechat.GetURL("/api/sendTextMsg"))
Post(apiUrl)
if err != nil {
log.Printf("发送文本消息失败: %s", err.Error())
// 休眠五秒后重新发送