mirror of
https://github.com/FloatTech/ZeroBot-Plugin.git
synced 2025-12-19 13:59:39 +08:00
优化
This commit is contained in:
parent
971c179227
commit
0315718ab7
@ -8,7 +8,9 @@ import (
|
||||
"net/http"
|
||||
"net/url"
|
||||
"os"
|
||||
"strconv"
|
||||
"strings"
|
||||
"time"
|
||||
|
||||
"github.com/FloatTech/floatbox/binary"
|
||||
"github.com/FloatTech/floatbox/ctxext"
|
||||
@ -192,6 +194,7 @@ func init() {
|
||||
return
|
||||
}
|
||||
type reply struct {
|
||||
ID int
|
||||
Msg string
|
||||
}
|
||||
m := reply{}
|
||||
@ -200,8 +203,25 @@ func init() {
|
||||
logrus.Warnln("[chat] 🦙 unmarshal err:", err)
|
||||
return
|
||||
}
|
||||
if len(m.Msg) > 0 {
|
||||
ctx.Send(message.ReplyWithMessage(ctx.Event.MessageID, message.Text(m.Msg)))
|
||||
for i := 0; i < 60; i++ {
|
||||
time.Sleep(time.Second * 4)
|
||||
data, err := web.RequestDataWithHeaders(http.DefaultClient, alpacapiurl+"/get?id="+strconv.Itoa(m.ID), "GET",
|
||||
func(r *http.Request) error {
|
||||
r.Header.Set("Authorization", alpacatoken)
|
||||
return nil
|
||||
}, nil)
|
||||
if err != nil {
|
||||
continue
|
||||
}
|
||||
err = json.Unmarshal(data, &m)
|
||||
if err != nil {
|
||||
logrus.Warnln("[chat] 🦙 unmarshal err:", err)
|
||||
return
|
||||
}
|
||||
if len(m.Msg) > 0 {
|
||||
ctx.Send(message.ReplyWithMessage(ctx.Event.MessageID, message.Text(m.Msg)))
|
||||
}
|
||||
return
|
||||
}
|
||||
}
|
||||
})
|
||||
|
||||
Loading…
Reference in New Issue
Block a user