Files
Message-Push-Nest/service/send_message_service/send_custom.go
T

30 lines
761 B
Go
Raw Normal View History

2024-01-07 00:25:35 +08:00
package send_message_service
import (
"encoding/json"
"fmt"
"message-nest/models"
"message-nest/pkg/message"
"message-nest/service/send_way_service"
"strings"
)
type CustomService struct {
}
// SendCustomMessage 执行发送钉钉
2024-01-08 23:35:10 +08:00
func (s *CustomService) SendCustomMessage(auth send_way_service.WayDetailCustom, ins models.SendTasksIns, typeC string, title string, content string) (string, string) {
2024-01-07 00:25:35 +08:00
errMsg := ""
cli := message.CustomWebhook{}
data, _ := json.Marshal(content)
dataStr := string(data)
dataStr = strings.Trim(dataStr, "\"")
bodyStr := strings.Replace(auth.Body, "TEXT", dataStr, -1)
2024-01-08 23:35:10 +08:00
res, err := cli.Request(auth.Webhook, bodyStr)
2024-01-07 00:25:35 +08:00
if err != nil {
errMsg = fmt.Sprintf("发送失败:%s", err)
}
2024-01-08 23:35:10 +08:00
return string(res), errMsg
2024-01-07 00:25:35 +08:00
}