|
|
|
@ -2,6 +2,7 @@ package serviceGame
|
|
|
|
|
|
|
|
|
|
import ( |
|
|
|
|
"context" |
|
|
|
|
"errors" |
|
|
|
|
"fmt" |
|
|
|
|
"github.com/gogf/gf/v2/encoding/gcharset" |
|
|
|
|
"github.com/gogf/gf/v2/encoding/gjson" |
|
|
|
@ -33,6 +34,7 @@ type IGameLoginUrl interface {
|
|
|
|
|
GetRouter(ctx context.Context, req *game.GetRouterReq) (res *game.GetRouterRes, err error) |
|
|
|
|
GetServerVersionList(ctx context.Context, req *game.GetServerVersionListReq) (res *game.GetServerVersionListRes, err error) |
|
|
|
|
UpdateRouter(ctx context.Context, req *game.AddRouterReq) (res *game.AddRouterRes, err error) |
|
|
|
|
ServerUpdateMsg(ctx context.Context, req *game.ServerUpdateMsgReq) (res *game.ServerUpdateMsgRes, err error) |
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
type gameLoginUrlImpl struct { |
|
|
|
@ -233,6 +235,7 @@ func (c *gameLoginUrlImpl) ReConfigServer(ctx context.Context, req *game.ReConfi
|
|
|
|
|
service.Email().ConfigInit() |
|
|
|
|
service.TencentSms().ConfigInit() |
|
|
|
|
internal.InitChannel(ctx) |
|
|
|
|
internal.WebHookInit(ctx) |
|
|
|
|
} else { |
|
|
|
|
internal.InitServer(ctx) |
|
|
|
|
internal.InitRechargeServer(ctx) |
|
|
|
@ -348,3 +351,49 @@ func (c *gameLoginUrlImpl) GetServerVersionList(ctx context.Context, req *game.G
|
|
|
|
|
} |
|
|
|
|
return |
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
func (c *gameLoginUrlImpl) ServerUpdateMsg(ctx context.Context, req *game.ServerUpdateMsgReq) (res *game.ServerUpdateMsgRes, err error) { |
|
|
|
|
//url := "https://open.feishu.cn/open-apis/bot/v2/hook/4033c60d-08b4-4d28-8eab-1d4159df98ed"
|
|
|
|
|
//url := "https://open.feishu.cn/open-apis/bot/v2/hook/6c2ebace-6815-49a8-9964-eb580ec0a56b"
|
|
|
|
|
url := internal.Webhook |
|
|
|
|
if len(url) == 0 { |
|
|
|
|
return nil, errors.New("地址为空!") |
|
|
|
|
} |
|
|
|
|
normal_v2 := map[string]interface{}{"default": "normal", "pc": "normal", "mobile": "heading"} |
|
|
|
|
text_size := map[string]interface{}{"normal_v2": normal_v2} |
|
|
|
|
style := map[string]interface{}{"text_size": text_size} |
|
|
|
|
config := map[string]interface{}{"update_multi": true, "style": style} |
|
|
|
|
elements := []map[string]interface{}{ |
|
|
|
|
{ |
|
|
|
|
"tag": "markdown", |
|
|
|
|
"content": req.Content, |
|
|
|
|
"text_align": "left", |
|
|
|
|
"text_size": "normal_v2", |
|
|
|
|
"margin": "0px 0px 0px 0px", |
|
|
|
|
}, |
|
|
|
|
} |
|
|
|
|
body1 := map[string]interface{}{"direction": "vertical", "padding": "12px 12px 12px 12px", "elements": elements} |
|
|
|
|
title := map[string]interface{}{"tag": "plain_text", "content": req.Title} |
|
|
|
|
subtitle := map[string]interface{}{"tag": "plain_text", "content": req.Subtitle} |
|
|
|
|
header := map[string]interface{}{"title": title, "template": "blue", "subtitle": subtitle, "padding": "12px 12px 12px 12px"} |
|
|
|
|
card := map[string]interface{}{"schema": "2.0", "config": config, "body": body1, "header": header} |
|
|
|
|
body := map[string]interface{}{"msg_type": "interactive", "card": card} |
|
|
|
|
fmt.Println("GetOnlineList - body: ", gjson.MustEncodeString(body)) |
|
|
|
|
bytes := g.Client().PostBytes(ctx, url, gjson.MustEncodeString(body)) |
|
|
|
|
src := string(bytes) |
|
|
|
|
if g.IsEmpty(src) { |
|
|
|
|
return |
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
srcCharset := "UTF-8" |
|
|
|
|
tmp, _ := gcharset.ToUTF8(srcCharset, src) |
|
|
|
|
json, err := gjson.DecodeToJson(tmp) |
|
|
|
|
if err != nil { |
|
|
|
|
return |
|
|
|
|
} |
|
|
|
|
fmt.Println("GetOnlineList - json: ", tmp) |
|
|
|
|
if json.Get("code").Int() != 0 { |
|
|
|
|
err = errors.New(json.Get("msg").String()) |
|
|
|
|
} |
|
|
|
|
return |
|
|
|
|
} |
|
|
|
|