1 Star 0 Fork 0

h79 / gothird

加入 Gitee
与超过 1200万 开发者一起发现、参与优秀开源项目,私有仓库也完全免费 :)
免费加入
克隆/下载
notify.go 986 Bytes
一键复制 编辑 原始数据 按行查看 历史
huqiuyun 提交于 2023-07-28 16:16 . 还是把 token 放在这里
package work
import (
"gitee.com/h79/gothird/config"
"gitee.com/h79/gothird/token"
"gitee.com/h79/gothird/weixin/work/structs"
"gitee.com/h79/goutils/common/result"
)
type FillContentCallback func(*config.Options, interface{}) string
func Notify(option *config.Options, content interface{}, call FillContentCallback) error {
tk, err := token.GetToken(option.Group.CorpId)
if err != nil {
return err
}
api := token.NewApi(tk)
if option.Group.Method == "chat" {
toWho := structs.ToGroup{ChatId: option.Group.ChatId}
msg := NewMessage(&toWho, "text", structs.ExText{Content: call(option, content)})
err = SendMessage(api, msg)
return err
} else if option.Group.Method == "agent" {
toWho := structs.ToAgent{AgentId: option.Group.AgentId, ToUser: option.Group.User}
msg := NewMessage(&toWho, "text", structs.ExText{Content: call(option, content)})
err = SendMessage(api, msg)
return err
}
return result.Error(result.ErrGroupInternal, "Not support method")
}
马建仓 AI 助手
尝试更多
代码解读
代码找茬
代码优化
1
https://gitee.com/h79/gothird.git
git@gitee.com:h79/gothird.git
h79
gothird
gothird
v1.8.106

搜索帮助

344bd9b3 5694891 D2dac590 5694891