逻辑错误发送到飞书
This commit is contained in:
parent
e7ccaf65d2
commit
a1056a5556
48
src/server/GoUtil/feishu.go
Normal file
48
src/server/GoUtil/feishu.go
Normal file
@ -0,0 +1,48 @@
|
||||
package GoUtil
|
||||
|
||||
import (
|
||||
"bytes"
|
||||
"encoding/json"
|
||||
"fmt"
|
||||
"net/http"
|
||||
)
|
||||
|
||||
const (
|
||||
FEISHU_WEBHOOK = "https://open.feishu.cn/open-apis/bot/v2/hook/70e24a79-b019-434a-b4d1-4592bbf7c311"
|
||||
)
|
||||
|
||||
func SendFeishuMsg(msg string) error {
|
||||
// 创建请求体
|
||||
payload := map[string]interface{}{
|
||||
"msg_type": "text",
|
||||
"content": map[string]string{
|
||||
"text": msg,
|
||||
},
|
||||
}
|
||||
payloadBytes, err := json.Marshal(payload)
|
||||
if err != nil {
|
||||
return err
|
||||
}
|
||||
|
||||
// 创建HTTP请求
|
||||
req, err := http.NewRequest("POST", FEISHU_WEBHOOK, bytes.NewBuffer(payloadBytes))
|
||||
if err != nil {
|
||||
return err
|
||||
}
|
||||
req.Header.Set("Content-Type", "application/json")
|
||||
|
||||
// 发送请求
|
||||
client := &http.Client{}
|
||||
resp, err := client.Do(req)
|
||||
if err != nil {
|
||||
return err
|
||||
}
|
||||
defer resp.Body.Close()
|
||||
|
||||
// 检查响应状态码
|
||||
if resp.StatusCode != http.StatusOK {
|
||||
return fmt.Errorf("failed to send message, status code: %d", resp.StatusCode)
|
||||
}
|
||||
|
||||
return nil
|
||||
}
|
||||
@ -1,6 +1,7 @@
|
||||
package game
|
||||
|
||||
import (
|
||||
"fmt"
|
||||
"reflect"
|
||||
"server/GoUtil"
|
||||
"server/MergeConst"
|
||||
@ -159,7 +160,8 @@ func HandleClientReq(args []interface{}) {
|
||||
backup := p.(*Player).BackUp() // 备份当前的 Player 值
|
||||
defer func() {
|
||||
if r := recover(); r != nil {
|
||||
log.Debug("uid : %d, func : %s, fatal : %s", p.(*Player).M_DwUin, m.GetFunc(), r)
|
||||
log.Error("uid : %d, func : %s, fatal : %s", p.(*Player).M_DwUin, m.GetFunc(), r)
|
||||
GoUtil.SendFeishuMsg(fmt.Sprintf("uid : %d, func : %s, fatal : %s", p.(*Player).M_DwUin, m.GetFunc(), r))
|
||||
p.(*Player).Recover(backup) //还原Player的数据
|
||||
}
|
||||
p.(*Player).lock.Unlock() //解锁
|
||||
|
||||
Loading…
Reference in New Issue
Block a user