1
0
mirror of https://github.com/Mrs4s/go-cqhttp.git synced 2025-05-07 20:45:53 +08:00

feat: onebot 12 style mention [disabled]

This commit is contained in:
wdvxdr 2021-10-13 22:49:56 +08:00
parent 250c96f2c9
commit 029d3a2c18
No known key found for this signature in database
GPG Key ID: 703F8C071DE7A1B6
3 changed files with 14 additions and 4 deletions

View File

@ -748,8 +748,16 @@ func (bot *CQBot) ToElement(t string, d map[string]string, isGroup bool) (m inte
return nil, err return nil, err
} }
return message.NewFace(int32(id)), nil return message.NewFace(int32(id)), nil
case "mention":
if !base.AcceptOneBot12Message {
return nil, errors.New("unsupported onebot 12 style")
}
fallthrough
case "at": case "at":
qq := d["qq"] qq := d["qq"]
if base.AcceptOneBot12Message && qq == "" {
qq = d["user_id"]
}
if qq == "all" { if qq == "all" {
return message.AtAll(), nil return message.AtAll(), nil
} }

View File

@ -30,8 +30,10 @@ func nocheck(_ io.ReadSeeker) (bool, string) {
return true, "" return true, ""
} }
// todo: enable in v1.1.0 // todo: enable all in v1.1.0
// onebot v12 feature
// onebot 12 feature
const ( const (
AcceptOneBotV12HTTPEndPoint = false AcceptOneBot12HTTPEndPoint = false
AcceptOneBot12Message = false
) )

View File

@ -118,7 +118,7 @@ func (s *httpServer) ServeHTTP(writer http.ResponseWriter, request *http.Request
} }
var response global.MSG var response global.MSG
if base.AcceptOneBotV12HTTPEndPoint && request.URL.Path == "/" { if base.AcceptOneBot12HTTPEndPoint && request.URL.Path == "/" {
action := strings.TrimSuffix(ctx.Get("action").Str, "_async") action := strings.TrimSuffix(ctx.Get("action").Str, "_async")
log.Debugf("HTTPServer接收到API调用: %v", action) log.Debugf("HTTPServer接收到API调用: %v", action)
response = s.api.callAPI(action, ctx.Get("params")) response = s.api.callAPI(action, ctx.Get("params"))