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/http"
|
||||||
"net/url"
|
"net/url"
|
||||||
"os"
|
"os"
|
||||||
|
"strconv"
|
||||||
"strings"
|
"strings"
|
||||||
|
"time"
|
||||||
|
|
||||||
"github.com/FloatTech/floatbox/binary"
|
"github.com/FloatTech/floatbox/binary"
|
||||||
"github.com/FloatTech/floatbox/ctxext"
|
"github.com/FloatTech/floatbox/ctxext"
|
||||||
@ -192,6 +194,7 @@ func init() {
|
|||||||
return
|
return
|
||||||
}
|
}
|
||||||
type reply struct {
|
type reply struct {
|
||||||
|
ID int
|
||||||
Msg string
|
Msg string
|
||||||
}
|
}
|
||||||
m := reply{}
|
m := reply{}
|
||||||
@ -200,9 +203,26 @@ func init() {
|
|||||||
logrus.Warnln("[chat] 🦙 unmarshal err:", err)
|
logrus.Warnln("[chat] 🦙 unmarshal err:", err)
|
||||||
return
|
return
|
||||||
}
|
}
|
||||||
|
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 {
|
if len(m.Msg) > 0 {
|
||||||
ctx.Send(message.ReplyWithMessage(ctx.Event.MessageID, message.Text(m.Msg)))
|
ctx.Send(message.ReplyWithMessage(ctx.Event.MessageID, message.Text(m.Msg)))
|
||||||
}
|
}
|
||||||
|
return
|
||||||
|
}
|
||||||
}
|
}
|
||||||
})
|
})
|
||||||
}()
|
}()
|
||||||
|
|||||||
Loading…
Reference in New Issue
Block a user