增加发消息提醒

pull/23/head
taoshihan1991 5 years ago
parent 5bfa5c5d3c
commit dadd4c8e01

@ -207,6 +207,7 @@ func SendMessageV2(c *gin.Context) {
} }
str, _ := json.Marshal(msg) str, _ := json.Marshal(msg)
ws.OneKefuMessage(kefuInfo.Name, str) ws.OneKefuMessage(kefuInfo.Name, str)
go ws.SendServerJiang(vistorInfo.Name+"说", content, c.GetHeader("Host"))
} }
c.JSON(200, gin.H{ c.JSON(200, gin.H{
"code": 200, "code": 200,

@ -32,7 +32,7 @@ func NewVisitorServer(c *gin.Context) {
To_id: vistorInfo.ToId, To_id: vistorInfo.ToId,
} }
go models.UpdateVisitorStatus(vistorInfo.VisitorId, 1) go models.UpdateVisitorStatus(vistorInfo.VisitorId, 1)
go SendServerJiang(vistorInfo.Name) go SendServerJiang(vistorInfo.Name, "来了", c.GetHeader("Host"))
AddVisitorToList(user) AddVisitorToList(user)

@ -64,15 +64,15 @@ func init() {
} }
go UpdateVisitorStatusCron() go UpdateVisitorStatusCron()
} }
func SendServerJiang(content string) string { func SendServerJiang(title string, content string, domain string) string {
noticeServerJiang, err := strconv.ParseBool(models.FindConfig("NoticeServerJiang")) noticeServerJiang, err := strconv.ParseBool(models.FindConfig("NoticeServerJiang"))
serverJiangAPI := models.FindConfig("ServerJiangAPI") serverJiangAPI := models.FindConfig("ServerJiangAPI")
if err != nil || !noticeServerJiang || serverJiangAPI == "" { if err != nil || !noticeServerJiang || serverJiangAPI == "" {
log.Println("do not notice serverjiang:", serverJiangAPI, noticeServerJiang) log.Println("do not notice serverjiang:", serverJiangAPI, noticeServerJiang)
return "" return ""
} }
sendStr := fmt.Sprintf("%s,访客来了", content) sendStr := fmt.Sprintf("%s%s", title, content)
desp := "[登录](https://gofly.sopans.com/main)" desp := title + ":" + content + "[登录](http://" + domain + "/main)"
url := serverJiangAPI + "?text=" + sendStr + "&desp=" + desp url := serverJiangAPI + "?text=" + sendStr + "&desp=" + desp
//log.Println(url) //log.Println(url)
res := tools.Get(url) res := tools.Get(url)

Loading…
Cancel
Save