增加server酱的微信通知

pull/30/head
taoshihan1991 4 years ago
parent b8ce5a0474
commit b0abaecf08

@ -19,7 +19,7 @@ var(
port string
tcpport string
daemon bool
GoflyConfig config.Config
GoflyConfig *config.Config
)
var serverCmd = &cobra.Command{
Use: "server",

@ -11,6 +11,7 @@ var(
PageSize uint=10
VisitorPageSize uint=8
Version = "0.1.2"
GoflyConfig *Config
)
const Dir = "config/"
const AccountConf = Dir + "account.json"
@ -19,7 +20,11 @@ const MailConf = Dir + "mail.json"
const LangConf=Dir+"language.json"
const MainConf = Dir + "config.json"
const WeixinToken="taoshihan1"
const ServerJiang=""
func init(){
//配置文件
GoflyConfig=CreateConfig()
}
type Mysql struct{
Server string
Port string
@ -32,11 +37,13 @@ type MailServer struct {
}
type Config struct {
Upload string
NoticeServerJiang bool
}
func CreateConfig()*Config{
var configObj Config
c:=&Config{
Upload: "static/upload/",
NoticeServerJiang:false,
}
isExist, _ := tools.IsFileExist(MainConf)
if !isExist {

@ -1,3 +1,4 @@
{
"Upload":"static/upload/"
"Upload":"static/upload/",
"NoticeServerJiang": true
}

@ -257,6 +257,8 @@ func singleBroadcaster(){
kefuConn.WriteMessage(websocket.TextMessage,str)
}
}
//客户上线发微信通知
go SendServerJiang(userInfo["username"])
sendPingOnlineUsers()
//客服上线
case "kfOnline":

@ -0,0 +1,20 @@
package controller
import (
"fmt"
"github.com/taoshihan1991/imaptool/config"
"github.com/taoshihan1991/imaptool/tools"
"log"
)
func SendServerJiang(content string)string{
conf:=config.CreateConfig()
if config.ServerJiang=="" || !conf.NoticeServerJiang{
log.Println("do not notice serverjiang:",config.ServerJiang,conf.NoticeServerJiang)
return ""
}
sendStr:=fmt.Sprintf("%s,访客来了",content)
desp:="[登录](https://gofly.sopans.com/main)";
res:=tools.Get(config.ServerJiang+"?text="+sendStr+"&desp="+desp)
return res
}

@ -148,7 +148,6 @@
chatTitle:"正在连接...",
visitor:{},
face:[],
showKfonline:false,
kfConfig:{
id : "",
name : "",

@ -0,0 +1,19 @@
package tools
import (
"io/ioutil"
"net/http"
)
func Get(url string)string{
res, err :=http.Get(url)
if err != nil {
return ""
}
robots, err := ioutil.ReadAll(res.Body)
res.Body.Close()
if err != nil {
return ""
}
return string(robots)
}
Loading…
Cancel
Save