13 Star 100 Fork 25

RACHEL/fastsearch

加入 Gitee
与超过 1400万 开发者一起发现、参与优秀开源项目,私有仓库也完全免费 :)
免费加入
文件
克隆/下载
notice.go 1.06 KB
一键复制 编辑 原始数据 按行查看 历史
hkingsoftcn 提交于 2024-08-27 16:41 +08:00 . 消息通知接口/api/notice
package service
import (
"errors"
"gitee.com/rachel_os/fastsearch/global"
"gitee.com/rachel_os/fastsearch/notice"
)
type Notice struct {
Text string `json:"text"`
ToUser string `json:"to_user"`
ToUserID string `json:"to_user_id"`
}
func NewNotice() *Notice {
return &Notice{}
}
// 消息通知
func (noc *Notice) Notice(w Notice) ([]string, error) {
notice := notice.NewNotice()
notice.Msg.MsgType = "text"
notice.Msg.AgentID = w.ToUserID
notice.Msg.User = w.ToUser
notice.Msg.Text.Content = w.Text
// 微信配置
notice.WxConfig.CorpID = global.CONFIG.Notice.QyWeixin.CorpID
notice.WxConfig.CorpSecret = global.CONFIG.Notice.QyWeixin.CorpSecret
// 钉钉配置
notice.DingConfig.WebhookURL = global.CONFIG.Notice.DingTalk.WebHook
var (
rel []string
)
if !global.CONFIG.Notice.Enable {
return nil, errors.New("未开启消息通知")
}
if global.CONFIG.Notice.DingTalk.Enable {
v, _ := notice.DingTalk()
rel = append(rel, v)
}
if global.CONFIG.Notice.QyWeixin.Enable {
v, _ := notice.Qweixin()
rel = append(rel, v)
}
return rel, nil
}
Loading...
马建仓 AI 助手
尝试更多
代码解读
代码找茬
代码优化
Go
1
https://gitee.com/rachel_os/fastsearch.git
git@gitee.com:rachel_os/fastsearch.git
rachel_os
fastsearch
fastsearch
98a29f8d6bf9

搜索帮助