发送微信通知

pull/23/head
陶士涵 4 years ago
parent 200fa57b8b
commit bb51e931f2

@ -1,8 +1,12 @@
package tools
import (
"fmt"
"github.com/taoshihan1991/imaptool/models"
"io/ioutil"
"log"
"net/http"
"strconv"
)
func Get(url string) string {
@ -17,3 +21,17 @@ func Get(url string) string {
}
return string(robots)
}
func SendServerJiang(content string) string {
noticeServerJiang, err := strconv.ParseBool(models.FindConfig("NoticeServerJiang"))
serverJiangAPI := models.FindConfig("ServerJiangAPI")
if err != nil || !noticeServerJiang || serverJiangAPI == "" {
log.Println("do not notice serverjiang:", serverJiangAPI, noticeServerJiang)
return ""
}
sendStr := fmt.Sprintf("%s,访客来了", content)
desp := "[登录](https://gofly.sopans.com/main)"
url := serverJiangAPI + "?text=" + sendStr + "&desp=" + desp
//log.Println(url)
res := Get(url)
return res
}

@ -5,6 +5,7 @@ import (
"github.com/gin-gonic/gin"
"github.com/gorilla/websocket"
"github.com/taoshihan1991/imaptool/models"
"github.com/taoshihan1991/imaptool/tools"
"log"
)
@ -31,6 +32,7 @@ func NewVisitorServer(c *gin.Context) {
Id: vistorInfo.VisitorId,
To_id: vistorInfo.ToId,
}
go tools.SendServerJiang(vistorInfo.Name)
AddVisitorToList(user)
for {

Loading…
Cancel
Save