feat(internal/sendMail): 邮件报警

This commit is contained in:
mei
2025-10-06 17:14:54 +08:00
parent bbb726f98a
commit 6c14ad207f
7 changed files with 94 additions and 28 deletions
+5 -5
View File
@@ -12,26 +12,26 @@ import (
"github.com/ssdomei232/goodBaby/configs"
)
func SendQQMsg() {
func SendQQ() {
config, err := configs.GetConfig()
if err != nil {
log.Printf("获取配置文件失败: %v", err)
}
url := fmt.Sprintf("%s/%s", config.CatBotUrl, config.CatBotKey)
url := fmt.Sprintf("%s/?secret=%s", config.CatBotUrl, config.CatBotKey)
for _, groupId := range config.QQSendGroup {
sendMsg(url, groupId, config.QQMsg)
sendQQMsg(url, groupId, config.QQMsg)
}
}
func sendMsg(url string, groupId int, msg string) {
func sendQQMsg(url string, groupId int, msg string) {
method := "POST"
payload := &bytes.Buffer{}
writer := multipart.NewWriter(payload)
_ = writer.WriteField("group_id", strconv.Itoa(groupId))
_ = writer.WriteField("message", msg)
_ = writer.WriteField("message", msg) //TODO: 发送死亡区间
err := writer.Close()
if err != nil {
log.Println(err)