Skip to content

Commit 30301f1

Browse files
committed
🦙请求改POST
1 parent df1d71b commit 30301f1

1 file changed

Lines changed: 13 additions & 4 deletions

File tree

plugin/thesaurus/chat.go

Lines changed: 13 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -6,7 +6,6 @@ import (
66
"encoding/json"
77
"math/rand"
88
"net/http"
9-
"net/url"
109
"os"
1110
"strconv"
1211
"strings"
@@ -180,15 +179,20 @@ func init() {
180179
SetBlock(false).
181180
Handle(randreply(sm.K))
182181
engine.OnMessage(canmatch(tALPACA), func(ctx *zero.Ctx) bool {
183-
return !zero.HasPicture(ctx) && alpacapiurl != "" && alpacatoken != ""
182+
return alpacapiurl != "" && alpacatoken != ""
184183
}).SetBlock(false).Handle(func(ctx *zero.Ctx) {
185184
msg := ctx.ExtractPlainText()
186185
if msg != "" {
187-
data, err := web.RequestDataWithHeaders(http.DefaultClient, alpacapiurl+"/reply?msg="+url.QueryEscape(msg), "GET",
186+
data, err := web.RequestDataWithHeaders(http.DefaultClient, alpacapiurl+"/reply", "POST",
188187
func(r *http.Request) error {
189188
r.Header.Set("Authorization", alpacatoken)
190189
return nil
191-
}, nil)
190+
}, bytes.NewReader(binary.NewWriterF(func(writer *binary.Writer) {
191+
_ = json.NewEncoder(writer).Encode(&alpacamsg{
192+
Name: ctx.CardOrNickName(ctx.Event.UserID),
193+
Message: msg,
194+
})
195+
})))
192196
if err != nil {
193197
logrus.Warnln("[chat] 🦙 err:", err)
194198
return
@@ -235,6 +239,11 @@ type simai struct {
235239
K map[string][]string `yaml:"可爱"`
236240
}
237241

242+
type alpacamsg struct {
243+
Name string
244+
Message string
245+
}
246+
238247
const (
239248
tKIMO = iota
240249
tDERE

0 commit comments

Comments
 (0)