From bb51e931f26b3e529415854a796fba7d81df7d3b Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?=E9=99=B6=E5=A3=AB=E6=B6=B5?= <630892807@qq.com> Date: Sat, 24 Oct 2020 14:57:03 +0800 Subject: [PATCH] =?UTF-8?q?=E5=8F=91=E9=80=81=E5=BE=AE=E4=BF=A1=E9=80=9A?= =?UTF-8?q?=E7=9F=A5?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- tools/http.go | 18 ++++++++++++++++++ ws/visitor.go | 2 ++ 2 files changed, 20 insertions(+) diff --git a/tools/http.go b/tools/http.go index 1e073d9..2d6a224 100644 --- a/tools/http.go +++ b/tools/http.go @@ -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 +} diff --git a/ws/visitor.go b/ws/visitor.go index ac2523c..91171a6 100644 --- a/ws/visitor.go +++ b/ws/visitor.go @@ -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 {