diff --git a/tools/http.go b/tools/http.go index 2d6a224..1e073d9 100644 --- a/tools/http.go +++ b/tools/http.go @@ -1,12 +1,8 @@ package tools import ( - "fmt" - "github.com/taoshihan1991/imaptool/models" "io/ioutil" - "log" "net/http" - "strconv" ) func Get(url string) string { @@ -21,17 +17,3 @@ 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 91171a6..792b2d2 100644 --- a/ws/visitor.go +++ b/ws/visitor.go @@ -5,7 +5,6 @@ import ( "github.com/gin-gonic/gin" "github.com/gorilla/websocket" "github.com/taoshihan1991/imaptool/models" - "github.com/taoshihan1991/imaptool/tools" "log" ) @@ -32,7 +31,7 @@ func NewVisitorServer(c *gin.Context) { Id: vistorInfo.VisitorId, To_id: vistorInfo.ToId, } - go tools.SendServerJiang(vistorInfo.Name) + go SendServerJiang(vistorInfo.Name) AddVisitorToList(user) for { diff --git a/ws/ws.go b/ws/ws.go index 049fc1a..fc92777 100644 --- a/ws/ws.go +++ b/ws/ws.go @@ -1,9 +1,14 @@ package ws import ( + "fmt" "github.com/gin-gonic/gin" "github.com/gorilla/websocket" + "github.com/taoshihan1991/imaptool/models" + "github.com/taoshihan1991/imaptool/tools" + "log" "net/http" + "strconv" "sync" ) @@ -55,3 +60,17 @@ func init() { } } +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 := tools.Get(url) + return res +}