mirror of
https://github.com/FloatTech/ZeroBot-Plugin.git
synced 2025-12-19 13:59:39 +08:00
🦙请求改POST
This commit is contained in:
parent
df1d71b9b2
commit
30301f1aba
@ -6,7 +6,6 @@ import (
|
||||
"encoding/json"
|
||||
"math/rand"
|
||||
"net/http"
|
||||
"net/url"
|
||||
"os"
|
||||
"strconv"
|
||||
"strings"
|
||||
@ -180,15 +179,20 @@ func init() {
|
||||
SetBlock(false).
|
||||
Handle(randreply(sm.K))
|
||||
engine.OnMessage(canmatch(tALPACA), func(ctx *zero.Ctx) bool {
|
||||
return !zero.HasPicture(ctx) && alpacapiurl != "" && alpacatoken != ""
|
||||
return alpacapiurl != "" && alpacatoken != ""
|
||||
}).SetBlock(false).Handle(func(ctx *zero.Ctx) {
|
||||
msg := ctx.ExtractPlainText()
|
||||
if msg != "" {
|
||||
data, err := web.RequestDataWithHeaders(http.DefaultClient, alpacapiurl+"/reply?msg="+url.QueryEscape(msg), "GET",
|
||||
data, err := web.RequestDataWithHeaders(http.DefaultClient, alpacapiurl+"/reply", "POST",
|
||||
func(r *http.Request) error {
|
||||
r.Header.Set("Authorization", alpacatoken)
|
||||
return nil
|
||||
}, nil)
|
||||
}, bytes.NewReader(binary.NewWriterF(func(writer *binary.Writer) {
|
||||
_ = json.NewEncoder(writer).Encode(&alpacamsg{
|
||||
Name: ctx.CardOrNickName(ctx.Event.UserID),
|
||||
Message: msg,
|
||||
})
|
||||
})))
|
||||
if err != nil {
|
||||
logrus.Warnln("[chat] 🦙 err:", err)
|
||||
return
|
||||
@ -235,6 +239,11 @@ type simai struct {
|
||||
K map[string][]string `yaml:"可爱"`
|
||||
}
|
||||
|
||||
type alpacamsg struct {
|
||||
Name string
|
||||
Message string
|
||||
}
|
||||
|
||||
const (
|
||||
tKIMO = iota
|
||||
tDERE
|
||||
|
||||
Loading…
Reference in New Issue
Block a user