From 947d165ac53863173990a864d902d8bce925ea3c Mon Sep 17 00:00:00 2001 From: wdvxdr Date: Thu, 3 Dec 2020 20:52:13 +0800 Subject: [PATCH 01/13] :zap: improve event filter --- coolq/bot.go | 9 ++--- global/filter.go | 87 ++++++++++++++++++++++++++---------------------- 2 files changed, 51 insertions(+), 45 deletions(-) diff --git a/coolq/bot.go b/coolq/bot.go index 45d6861..fd196b0 100644 --- a/coolq/bot.go +++ b/coolq/bot.go @@ -392,22 +392,19 @@ func (bot *CQBot) Release() { } func (bot *CQBot) dispatchEventMessage(m MSG) { - payload := gjson.Parse(m.ToJson()) - filter := global.EventFilter - if filter != nil && (*filter).Eval(payload) == false { + if global.EventFilter != nil && global.EventFilter.Eval(gjson.Parse(m.ToJson())) == false { log.Debug("Event filtered!") return } for _, f := range bot.events { - fn := f - go func() { + go func(fn func(MSG)) { start := time.Now() fn(m) end := time.Now() if end.Sub(start) > time.Second*5 { log.Debugf("警告: 事件处理耗时超过 5 秒 (%v), 请检查应用是否有堵塞.", end.Sub(start)) } - }() + }(f) } } diff --git a/global/filter.go b/global/filter.go index f47f62e..344ab13 100644 --- a/global/filter.go +++ b/global/filter.go @@ -13,13 +13,13 @@ type Filter interface { Eval(payload gjson.Result) bool } -type OperationNode struct { +type operationNode struct { key string filter Filter } type NotOperator struct { - operand_ Filter + operand Filter } func notOperatorConstruct(argument gjson.Result) *NotOperator { @@ -27,16 +27,16 @@ func notOperatorConstruct(argument gjson.Result) *NotOperator { panic("the argument of 'not' operator must be an object") } op := new(NotOperator) - op.operand_ = Generate("and", argument) + op.operand = Generate("and", argument) return op } -func (notOperator NotOperator) Eval(payload gjson.Result) bool { - return !(notOperator.operand_).Eval(payload) +func (op *NotOperator) Eval(payload gjson.Result) bool { + return !op.operand.Eval(payload) } type AndOperator struct { - operands []OperationNode + operands []operationNode } func andOperatorConstruct(argument gjson.Result) *AndOperator { @@ -51,19 +51,19 @@ func andOperatorConstruct(argument gjson.Result) *AndOperator { // "bar": "baz" // } opKey := key.Str[1:] - op.operands = append(op.operands, OperationNode{"", Generate(opKey, value)}) + op.operands = append(op.operands, operationNode{"", Generate(opKey, value)}) } else if value.IsObject() { // is an normal key with an object as the value // "foo": { // ".bar": "baz" // } opKey := key.String() - op.operands = append(op.operands, OperationNode{opKey, Generate("and", value)}) + op.operands = append(op.operands, operationNode{opKey, Generate("and", value)}) } else { // is an normal key with a non-object as the value // "foo": "bar" opKey := key.String() - op.operands = append(op.operands, OperationNode{opKey, Generate("eq", value)}) + op.operands = append(op.operands, operationNode{opKey, Generate("eq", value)}) } return true }) @@ -106,11 +106,10 @@ func orOperatorConstruct(argument gjson.Result) *OrOperator { return op } -func (orOperator OrOperator) Eval(payload gjson.Result) bool { +func (op *OrOperator) Eval(payload gjson.Result) bool { res := false - for _, operand := range orOperator.operands { + for _, operand := range op.operands { res = res || operand.Eval(payload) - if res == true { break } @@ -119,35 +118,36 @@ func (orOperator OrOperator) Eval(payload gjson.Result) bool { } type EqualOperator struct { - value gjson.Result + operand string } func equalOperatorConstruct(argument gjson.Result) *EqualOperator { op := new(EqualOperator) - op.value = argument + op.operand = argument.String() return op } -func (equalOperator EqualOperator) Eval(payload gjson.Result) bool { - return payload.String() == equalOperator.value.String() +func (op *EqualOperator) Eval(payload gjson.Result) bool { + return payload.String() == op.operand } type NotEqualOperator struct { - value gjson.Result + operand string } func notEqualOperatorConstruct(argument gjson.Result) *NotEqualOperator { op := new(NotEqualOperator) - op.value = argument + op.operand = argument.String() return op } -func (notEqualOperator NotEqualOperator) Eval(payload gjson.Result) bool { - return !(payload.String() == notEqualOperator.value.String()) +func (op *NotEqualOperator) Eval(payload gjson.Result) bool { + return !(payload.String() == op.operand) } type InOperator struct { - operand gjson.Result + operandString string + operandArray []string } func inOperatorConstruct(argument gjson.Result) *InOperator { @@ -155,20 +155,29 @@ func inOperatorConstruct(argument gjson.Result) *InOperator { panic("the argument of 'in' operator must be an array or a string") } op := new(InOperator) - op.operand = argument + if argument.IsArray() { + op.operandArray = []string{} + argument.ForEach(func(_, value gjson.Result) bool { + op.operandArray = append(op.operandArray, value.String()) + return true + }) + } else { + op.operandString = argument.String() + } return op } -func (inOperator InOperator) Eval(payload gjson.Result) bool { - if inOperator.operand.IsArray() { - res := false - inOperator.operand.ForEach(func(key, value gjson.Result) bool { - res = res || value.String() == payload.String() - return true - }) - return res +func (op *InOperator) Eval(payload gjson.Result) bool { + payloadStr := payload.String() + if op.operandArray != nil { + for _, value := range op.operandArray { + if value == payloadStr { + return true + } + } + return false } - return strings.Contains(inOperator.operand.String(), payload.String()) + return strings.Contains(op.operandString, payloadStr) } type ContainsOperator struct { @@ -184,15 +193,15 @@ func containsOperatorConstruct(argument gjson.Result) *ContainsOperator { return op } -func (containsOperator ContainsOperator) Eval(payload gjson.Result) bool { +func (op *ContainsOperator) Eval(payload gjson.Result) bool { if payload.IsObject() || payload.IsArray() { return false } - return strings.Contains(payload.String(), containsOperator.operand) + return strings.Contains(payload.String(), op.operand) } type RegexOperator struct { - regex string + regex *regexp.Regexp } func regexOperatorConstruct(argument gjson.Result) *RegexOperator { @@ -200,12 +209,12 @@ func regexOperatorConstruct(argument gjson.Result) *RegexOperator { panic("the argument of 'regex' operator must be a string") } op := new(RegexOperator) - op.regex = argument.String() + op.regex = regexp.MustCompile(argument.String()) return op } -func (containsOperator RegexOperator) Eval(payload gjson.Result) bool { - matched, _ := regexp.MatchString(containsOperator.regex, payload.String()) +func (op *RegexOperator) Eval(payload gjson.Result) bool { + matched := op.regex.MatchString(payload.String()) return matched } @@ -232,7 +241,7 @@ func Generate(opName string, argument gjson.Result) Filter { } } -var EventFilter = new(Filter) +var EventFilter Filter = nil func BootFilter() { defer func() { @@ -247,6 +256,6 @@ func BootFilter() { if err != nil { panic(err) } else { - *EventFilter = Generate("and", gjson.ParseBytes(f)) + EventFilter = Generate("and", gjson.ParseBytes(f)) } } From 70e8ea07bd081934d3d530e54c16c384531d75d5 Mon Sep 17 00:00:00 2001 From: wdvxdr Date: Thu, 3 Dec 2020 22:19:46 +0800 Subject: [PATCH 02/13] remove convert --- coolq/bot.go | 3 +-- global/filter.go | 42 ++++++++++++++++++++++++++++++------------ 2 files changed, 31 insertions(+), 14 deletions(-) diff --git a/coolq/bot.go b/coolq/bot.go index fd196b0..4a10ffa 100644 --- a/coolq/bot.go +++ b/coolq/bot.go @@ -18,7 +18,6 @@ import ( jsoniter "github.com/json-iterator/go" log "github.com/sirupsen/logrus" - "github.com/tidwall/gjson" ) var json = jsoniter.ConfigCompatibleWithStandardLibrary @@ -392,7 +391,7 @@ func (bot *CQBot) Release() { } func (bot *CQBot) dispatchEventMessage(m MSG) { - if global.EventFilter != nil && global.EventFilter.Eval(gjson.Parse(m.ToJson())) == false { + if global.EventFilter != nil && global.EventFilter.Eval(global.MSG(m)) == false { log.Debug("Event filtered!") return } diff --git a/global/filter.go b/global/filter.go index 344ab13..44f25a4 100644 --- a/global/filter.go +++ b/global/filter.go @@ -1,6 +1,7 @@ package global import ( + "fmt" "io/ioutil" "regexp" "strings" @@ -9,8 +10,28 @@ import ( "github.com/tidwall/gjson" ) +type MSG map[string]interface{} + +func (m MSG) Get(s string) MSG { + if v,ok := m[s];ok { + if msg,ok := v.(MSG);ok { + return msg + } + return MSG{"__str__": v} // 用这个名字应该没问题吧 + } + return MSG{} +} + +func (m MSG) String() string { + if str,ok:=m["__str__"];ok { + return fmt.Sprint(str) + } + str, _ := json.MarshalToString(m) + return str +} + type Filter interface { - Eval(payload gjson.Result) bool + Eval(payload MSG) bool } type operationNode struct { @@ -31,7 +52,7 @@ func notOperatorConstruct(argument gjson.Result) *NotOperator { return op } -func (op *NotOperator) Eval(payload gjson.Result) bool { +func (op *NotOperator) Eval(payload MSG) bool { return !op.operand.Eval(payload) } @@ -70,7 +91,7 @@ func andOperatorConstruct(argument gjson.Result) *AndOperator { return op } -func (andOperator *AndOperator) Eval(payload gjson.Result) bool { +func (andOperator *AndOperator) Eval(payload MSG) bool { res := true for _, operand := range andOperator.operands { @@ -106,7 +127,7 @@ func orOperatorConstruct(argument gjson.Result) *OrOperator { return op } -func (op *OrOperator) Eval(payload gjson.Result) bool { +func (op *OrOperator) Eval(payload MSG) bool { res := false for _, operand := range op.operands { res = res || operand.Eval(payload) @@ -127,7 +148,7 @@ func equalOperatorConstruct(argument gjson.Result) *EqualOperator { return op } -func (op *EqualOperator) Eval(payload gjson.Result) bool { +func (op *EqualOperator) Eval(payload MSG) bool { return payload.String() == op.operand } @@ -141,7 +162,7 @@ func notEqualOperatorConstruct(argument gjson.Result) *NotEqualOperator { return op } -func (op *NotEqualOperator) Eval(payload gjson.Result) bool { +func (op *NotEqualOperator) Eval(payload MSG) bool { return !(payload.String() == op.operand) } @@ -167,7 +188,7 @@ func inOperatorConstruct(argument gjson.Result) *InOperator { return op } -func (op *InOperator) Eval(payload gjson.Result) bool { +func (op *InOperator) Eval(payload MSG) bool { payloadStr := payload.String() if op.operandArray != nil { for _, value := range op.operandArray { @@ -193,10 +214,7 @@ func containsOperatorConstruct(argument gjson.Result) *ContainsOperator { return op } -func (op *ContainsOperator) Eval(payload gjson.Result) bool { - if payload.IsObject() || payload.IsArray() { - return false - } +func (op *ContainsOperator) Eval(payload MSG) bool { return strings.Contains(payload.String(), op.operand) } @@ -213,7 +231,7 @@ func regexOperatorConstruct(argument gjson.Result) *RegexOperator { return op } -func (op *RegexOperator) Eval(payload gjson.Result) bool { +func (op *RegexOperator) Eval(payload MSG) bool { matched := op.regex.MatchString(payload.String()) return matched } From cc6c042516df4f39065de24270171474b2095e16 Mon Sep 17 00:00:00 2001 From: Mrs4s Date: Fri, 4 Dec 2020 09:36:03 +0800 Subject: [PATCH 03/13] feature pprof service. --- go.mod | 1 + go.sum | 3 +++ main.go | 4 ++++ server/apiAdmin.go | 7 +++++++ server/http.go | 8 +------- 5 files changed, 16 insertions(+), 7 deletions(-) diff --git a/go.mod b/go.mod index 6a9cdf0..67c87d4 100644 --- a/go.mod +++ b/go.mod @@ -8,6 +8,7 @@ require ( github.com/fastly/go-utils v0.0.0-20180712184237-d95a45783239 // indirect github.com/getlantern/go-update v0.0.0-20190510022740-79c495ab728c github.com/getlantern/golog v0.0.0-20201105130739-9586b8bde3a9 // indirect + github.com/gin-contrib/pprof v1.3.0 github.com/gin-gonic/gin v1.6.3 github.com/gorilla/websocket v1.4.2 github.com/guonaihong/gout v0.1.3 diff --git a/go.sum b/go.sum index 6d8a37a..6fa1266 100644 --- a/go.sum +++ b/go.sum @@ -29,9 +29,12 @@ github.com/getlantern/hidden v0.0.0-20190325191715-f02dbb02be55 h1:XYzSdCbkzOC0F github.com/getlantern/hidden v0.0.0-20190325191715-f02dbb02be55/go.mod h1:6mmzY2kW1TOOrVy+r41Za2MxXM+hhqTtY3oBKd2AgFA= github.com/getlantern/ops v0.0.0-20190325191751-d70cb0d6f85f h1:wrYrQttPS8FHIRSlsrcuKazukx/xqO/PpLZzZXsF+EA= github.com/getlantern/ops v0.0.0-20190325191751-d70cb0d6f85f/go.mod h1:D5ao98qkA6pxftxoqzibIBBrLSUli+kYnJqrgBf9cIA= +github.com/gin-contrib/pprof v1.3.0 h1:G9eK6HnbkSqDZBYbzG4wrjCsA4e+cvYAHUZw6W+W9K0= +github.com/gin-contrib/pprof v1.3.0/go.mod h1:waMjT1H9b179t3CxuG1cV3DHpga6ybizwfBaM5OXaB0= github.com/gin-contrib/sse v0.1.0 h1:Y/yl/+YNO8GZSjAhjMsSuLt29uWRFHdHYUb5lYOV9qE= github.com/gin-contrib/sse v0.1.0/go.mod h1:RHrZQHXnP2xjPF+u1gW/2HnVO7nvIa9PG3Gm+fLHvGI= github.com/gin-gonic/gin v1.5.0/go.mod h1:Nd6IXA8m5kNZdNEHMBd93KT+mdY3+bewLgRvmCsR2Do= +github.com/gin-gonic/gin v1.6.2/go.mod h1:75u5sXoLsGZoRN5Sgbi1eraJ4GU3++wFwWzhwvtwp4M= github.com/gin-gonic/gin v1.6.3 h1:ahKqKTFpO5KTPHxWZjEdPScmYaGtLo8Y4DMHoEsnp14= github.com/gin-gonic/gin v1.6.3/go.mod h1:75u5sXoLsGZoRN5Sgbi1eraJ4GU3++wFwWzhwvtwp4M= github.com/go-playground/assert/v2 v2.0.1 h1:MsBgLAaY856+nPRTKrp3/OZK38U/wa0CcBYNjji3q3A= diff --git a/main.go b/main.go index 0972ba4..77e317f 100644 --- a/main.go +++ b/main.go @@ -214,6 +214,10 @@ func main() { log.SetLevel(log.DebugLevel) log.Warnf("已开启Debug模式.") log.Debugf("开发交流群: 192548878") + server.Debug = true + if conf.WebUi == nil || !conf.WebUi.Enabled { + log.Warnf("警告: 在Debug模式下未启用WebUi服务, 将无法进行性能分析.") + } } if !global.PathExists("device.json") { log.Warn("虚拟设备信息不存在, 将自动生成随机设备.") diff --git a/server/apiAdmin.go b/server/apiAdmin.go index 704f738..226a437 100644 --- a/server/apiAdmin.go +++ b/server/apiAdmin.go @@ -5,6 +5,7 @@ import ( "bytes" "encoding/base64" "fmt" + "github.com/gin-contrib/pprof" "image" "io/ioutil" "net/http" @@ -75,6 +76,12 @@ func (s *webServer) Run(addr string, cli *client.QQClient) *coolq.CQBot { //通用路由 s.engine.Any("/admin/:action", s.admin) + if Debug { + pprof.Register(s.engine) + log.Debugf("pprof 性能分析服务已启动在 http://%v/debug/pprof, 如果有任何性能问题请下载报告并提交给开发者", addr) + time.Sleep(time.Second * 3) + } + go func() { //开启端口监听 if s.Conf.WebUi != nil && s.Conf.WebUi.Enabled { diff --git a/server/http.go b/server/http.go index 1778a6a..2275d47 100644 --- a/server/http.go +++ b/server/http.go @@ -35,6 +35,7 @@ type httpClient struct { } var HttpServer = &httpServer{} +var Debug = false func (s *httpServer) Run(addr, authToken string, bot *coolq.CQBot) { gin.SetMode(gin.ReleaseMode) @@ -93,13 +94,6 @@ func (s *httpServer) Run(addr, authToken string, bot *coolq.CQBot) { time.Sleep(time.Second * 5) os.Exit(1) } - //err := s.engine.Run(addr) - //if err != nil { - // log.Error(err) - // log.Infof("请检查端口是否被占用.") - // time.Sleep(time.Second * 5) - // os.Exit(1) - //} }() } From 14278190e34410ad0379b120b562f80737437d79 Mon Sep 17 00:00:00 2001 From: Mrs4s Date: Fri, 4 Dec 2020 09:39:53 +0800 Subject: [PATCH 04/13] fix msg. --- server/apiAdmin.go | 11 +++++------ 1 file changed, 5 insertions(+), 6 deletions(-) diff --git a/server/apiAdmin.go b/server/apiAdmin.go index 226a437..c4ac28e 100644 --- a/server/apiAdmin.go +++ b/server/apiAdmin.go @@ -76,15 +76,14 @@ func (s *webServer) Run(addr string, cli *client.QQClient) *coolq.CQBot { //通用路由 s.engine.Any("/admin/:action", s.admin) - if Debug { - pprof.Register(s.engine) - log.Debugf("pprof 性能分析服务已启动在 http://%v/debug/pprof, 如果有任何性能问题请下载报告并提交给开发者", addr) - time.Sleep(time.Second * 3) - } - go func() { //开启端口监听 if s.Conf.WebUi != nil && s.Conf.WebUi.Enabled { + if Debug { + pprof.Register(s.engine) + log.Debugf("pprof 性能分析服务已启动在 http://%v/debug/pprof, 如果有任何性能问题请下载报告并提交给开发者", addr) + time.Sleep(time.Second * 3) + } log.Infof("Admin API 服务器已启动: %v", addr) err := s.engine.Run(addr) if err != nil { From 469054e5a377357f17182ed4eefcd113b9b817f9 Mon Sep 17 00:00:00 2001 From: Mrs4s Date: Fri, 4 Dec 2020 14:29:12 +0800 Subject: [PATCH 05/13] =?UTF-8?q?more=20info=20for=20=E5=BD=93=E5=89=8D?= =?UTF-8?q?=E4=B8=8A=E7=BD=91=E7=8E=AF=E5=A2=83=E5=BC=82=E5=B8=B8.=20close?= =?UTF-8?q?=20#465.?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- server/apiAdmin.go | 2 ++ 1 file changed, 2 insertions(+) diff --git a/server/apiAdmin.go b/server/apiAdmin.go index c4ac28e..96e7e26 100644 --- a/server/apiAdmin.go +++ b/server/apiAdmin.go @@ -204,6 +204,8 @@ func (s *webServer) Dologin() { cli.Disconnect() rsp, err = cli.Login() count++ + log.Warnf("错误: 当前上网环境异常. 将更换服务器并重试. 如果频繁遇到此问题请打开设备锁.") + time.Sleep(time.Second) continue } log.Warnf("登录失败: %v", msg) From b3c4cecdacce9671ba1100830b6044d758d8c337 Mon Sep 17 00:00:00 2001 From: shirokurakana Date: Fri, 4 Dec 2020 22:01:50 +0800 Subject: [PATCH 06/13] =?UTF-8?q?=E8=A1=A5=E5=85=85=E5=B9=B6=E6=95=B4?= =?UTF-8?q?=E7=90=86=E6=96=87=E6=A1=A3?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- README.md | 238 +++++++++++++++++++++++++++++++++++++------------ docs/cqhttp.md | 147 ++++++------------------------ 2 files changed, 209 insertions(+), 176 deletions(-) diff --git a/README.md b/README.md index 68f8add..670cca3 100644 --- a/README.md +++ b/README.md @@ -26,75 +26,199 @@
已实现CQ码 -- [CQ:image] -- [CQ:record] -- [CQ:video] -- [CQ:face] -- [CQ:at] -- [CQ:share] -- [CQ:reply] -- [CQ:forward] -- [CQ:node] -- [CQ:gift] -- [CQ:redbag] -- [CQ:tts] -- [CQ:music] +##### 符合Onebot标准的CQ码 +| CQ码 | 功能 | +| ------------ | ---------------------------- | +| [CQ:face] | [QQ表情] | +| [CQ:record] | [语音] | +| [CQ:video] | [短视频] | +| [CQ:at] | [@某人] | +| [CQ:share] | [链接分享] | +| [CQ:music] | [音乐分享] [音乐自定义分享] | +| [CQ:reply] | [回复] | +| [CQ:forward] | [合并转发] | +| [CQ:node] | [合并转发节点] | +| [CQ:xml] | [XML消息] | +| [CQ:json] | [JSON消息] | + +[QQ表情]: https://github.com/howmanybots/onebot/blob/master/v11/specs/message/segment.md#qq-%E8%A1%A8%E6%83%85 +[语音]: https://github.com/howmanybots/onebot/blob/master/v11/specs/message/segment.md#%E8%AF%AD%E9%9F%B3 +[短视频]: https://github.com/howmanybots/onebot/blob/master/v11/specs/message/segment.md#%E7%9F%AD%E8%A7%86%E9%A2%91 +[@某人]: https://github.com/howmanybots/onebot/blob/master/v11/specs/message/segment.md#%E6%9F%90%E4%BA%BA +[链接分享]: https://github.com/howmanybots/onebot/blob/master/v11/specs/message/segment.md#%E9%93%BE%E6%8E%A5%E5%88%86%E4%BA%AB +[音乐分享]: https://github.com/howmanybots/onebot/blob/master/v11/specs/message/segment.md#%E9%9F%B3%E4%B9%90%E5%88%86%E4%BA%AB- +[音乐自定义分享]: https://github.com/howmanybots/onebot/blob/master/v11/specs/message/segment.md#%E9%9F%B3%E4%B9%90%E8%87%AA%E5%AE%9A%E4%B9%89%E5%88%86%E4%BA%AB- +[回复]: https://github.com/howmanybots/onebot/blob/master/v11/specs/message/segment.md#%E5%9B%9E%E5%A4%8D +[合并转发]: https://github.com/howmanybots/onebot/blob/master/v11/specs/message/segment.md#%E5%90%88%E5%B9%B6%E8%BD%AC%E5%8F%91- +[合并转发节点]: https://github.com/howmanybots/onebot/blob/master/v11/specs/message/segment.md#%E5%90%88%E5%B9%B6%E8%BD%AC%E5%8F%91%E8%8A%82%E7%82%B9- +[XML消息]: https://github.com/howmanybots/onebot/blob/master/v11/specs/message/segment.md#xml-%E6%B6%88%E6%81%AF +[JSON消息]: https://github.com/howmanybots/onebot/blob/master/v11/specs/message/segment.md#json-%E6%B6%88%E6%81%AF + +##### 拓展CQ码及与Onebot标准有略微差异的CQ码 +| 拓展CQ码 | 功能 | +| -------------- | ------------------------------- | +| [CQ:image] | [图片] | +| [CQ:redbag] | [红包] | +| [CQ:poke] | [戳一戳] | +| [CQ:gift] | [礼物] | +| [CQ:node] | [合并转发消息节点] | +| [CQ:cardimage] | [一种xml的图片消息(装逼大图)] | +| [CQ:tts] | [文本转语音] | + +[图片]: docs/cqhttp.md#%E5%9B%BE%E7%89%87 +[红包]: docs/cqhttp.md#%E7%BA%A2%E5%8C%85 +[戳一戳]: docs/cqhttp.md#%E6%88%B3%E4%B8%80%E6%88%B3 +[礼物]: docs/cqhttp.md#%E7%A4%BC%E7%89%A9 +[合并转发消息节点]: docs/cqhttp.md#%E5%90%88%E5%B9%B6%E8%BD%AC%E5%8F%91%E6%B6%88%E6%81%AF%E8%8A%82%E7%82%B9 +[一种xml的图片消息(装逼大图)]: docs/cqhttp.md#cardimage-%E4%B8%80%E7%A7%8Dxml%E7%9A%84%E5%9B%BE%E7%89%87%E6%B6%88%E6%81%AF%E8%A3%85%E9%80%BC%E5%A4%A7%E5%9B%BE +[文本转语音]: docs/cqhttp.md#%E6%96%87%E6%9C%AC%E8%BD%AC%E8%AF%AD%E9%9F%B3
已实现API -##### 注意: 部分API实现与CQHTTP原版略有差异,请参考文档 -| API | 功能 | -| ------------------------ | ------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------ | -| /get_login_info | [获取登录号信息](https://github.com/howmanybots/onebot/blob/master/v11/specs/api/public.md#get_login_info-%E8%8E%B7%E5%8F%96%E7%99%BB%E5%BD%95%E5%8F%B7%E4%BF%A1%E6%81%AF) | -| /get_friend_list | [获取好友列表](https://github.com/howmanybots/onebot/blob/master/v11/specs/api/public.md#get_friend_list-%E8%8E%B7%E5%8F%96%E5%A5%BD%E5%8F%8B%E5%88%97%E8%A1%A8) | -| /get_group_list | [获取群列表](https://github.com/howmanybots/onebot/blob/master/v11/specs/api/public.md#get_group_list-%E8%8E%B7%E5%8F%96%E7%BE%A4%E5%88%97%E8%A1%A8) | -| /get_group_info | [获取群信息](https://github.com/howmanybots/onebot/blob/master/v11/specs/api/public.md#get_group_info-%E8%8E%B7%E5%8F%96%E7%BE%A4%E4%BF%A1%E6%81%AF) | -| /get_group_member_list | [获取群成员列表](https://github.com/howmanybots/onebot/blob/master/v11/specs/api/public.md#get_group_member_list-%E8%8E%B7%E5%8F%96%E7%BE%A4%E6%88%90%E5%91%98%E5%88%97%E8%A1%A8) | -| /get_group_member_info | [获取群成员信息](https://github.com/howmanybots/onebot/blob/master/v11/specs/api/public.md#get_group_member_info-%E8%8E%B7%E5%8F%96%E7%BE%A4%E6%88%90%E5%91%98%E4%BF%A1%E6%81%AF) | -| /send_msg | [发送消息](https://github.com/howmanybots/onebot/blob/master/v11/specs/api/public.md#send_msg-%E5%8F%91%E9%80%81%E6%B6%88%E6%81%AF) | -| /send_group_msg | [发送群消息](https://github.com/howmanybots/onebot/blob/master/v11/specs/api/public.md#send_group_msg-%E5%8F%91%E9%80%81%E7%BE%A4%E6%B6%88%E6%81%AF) | -| /send_private_msg | [发送私聊消息](https://github.com/howmanybots/onebot/blob/master/v11/specs/api/public.md#send_private_msg-%E5%8F%91%E9%80%81%E7%A7%81%E8%81%8A%E6%B6%88%E6%81%AF) | -| /delete_msg | [撤回信息](https://github.com/howmanybots/onebot/blob/master/v11/specs/api/public.md#delete_msg-%E6%92%A4%E5%9B%9E%E6%B6%88%E6%81%AF) | -| /set_friend_add_request | [处理加好友请求](https://github.com/howmanybots/onebot/blob/master/v11/specs/api/public.md#set_friend_add_request-%E5%A4%84%E7%90%86%E5%8A%A0%E5%A5%BD%E5%8F%8B%E8%AF%B7%E6%B1%82) | -| /set_group_add_request | [处理加群请求/邀请](https://github.com/howmanybots/onebot/blob/master/v11/specs/api/public.md#set_group_add_request-%E5%A4%84%E7%90%86%E5%8A%A0%E7%BE%A4%E8%AF%B7%E6%B1%82%E9%82%80%E8%AF%B7) | -| /set_group_card | [设置群名片(群备注)](https://github.com/howmanybots/onebot/blob/master/v11/specs/api/public.md#set_group_card-%E8%AE%BE%E7%BD%AE%E7%BE%A4%E5%90%8D%E7%89%87%E7%BE%A4%E5%A4%87%E6%B3%A8) | -| /set_group_special_title | [设置群组专属头衔](https://github.com/howmanybots/onebot/blob/master/v11/specs/api/public.md#set_group_special_title-%E8%AE%BE%E7%BD%AE%E7%BE%A4%E7%BB%84%E4%B8%93%E5%B1%9E%E5%A4%B4%E8%A1%94) | -| /set_group_kick | [群组T人](https://github.com/howmanybots/onebot/blob/master/v11/specs/api/public.md#set_group_kick-%E7%BE%A4%E7%BB%84%E8%B8%A2%E4%BA%BA) | -| /set_group_ban | [群组单人禁言](https://github.com/howmanybots/onebot/blob/master/v11/specs/api/public.md#set_group_ban-%E7%BE%A4%E7%BB%84%E5%8D%95%E4%BA%BA%E7%A6%81%E8%A8%80) | -| /set_group_whole_ban | [群组全员禁言](https://github.com/howmanybots/onebot/blob/master/v11/specs/api/public.md#set_group_whole_ban-%E7%BE%A4%E7%BB%84%E5%85%A8%E5%91%98%E7%A6%81%E8%A8%80) | -| /set_group_leave | [退出群组](https://github.com/howmanybots/onebot/blob/master/v11/specs/api/public.md#set_group_leave-%E9%80%80%E5%87%BA%E7%BE%A4%E7%BB%84) | -| /set_group_name | [设置群组名](https://github.com/howmanybots/onebot/blob/master/v11/specs/api/public.md#set_group_name-%E8%AE%BE%E7%BD%AE%E7%BE%A4%E5%90%8D) | -| /set_restart | [重启go-cqhttp](https://github.com/howmanybots/onebot/blob/master/v11/specs/api/public.md#set_restart-%E9%87%8D%E5%90%AF-onebot-%E5%AE%9E%E7%8E%B0) | -| /get_image | [获取图片信息](https://github.com/howmanybots/onebot/blob/master/v11/specs/api/public.md#get_image-%E8%8E%B7%E5%8F%96%E5%9B%BE%E7%89%87) | -| /get_msg | [获取消息](https://github.com/howmanybots/onebot/blob/master/v11/specs/api/public.md#get_msg-%E8%8E%B7%E5%8F%96%E6%B6%88%E6%81%AF) | -| /can_send_image | [检查是否可以发送图片](https://github.com/howmanybots/onebot/blob/master/v11/specs/api/public.md#can_send_image-%E6%A3%80%E6%9F%A5%E6%98%AF%E5%90%A6%E5%8F%AF%E4%BB%A5%E5%8F%91%E9%80%81%E5%9B%BE%E7%89%87) | -| /can_send_record | [检查是否可以发送语音](https://github.com/howmanybots/onebot/blob/master/v11/specs/api/public.md#can_send_record-%E6%A3%80%E6%9F%A5%E6%98%AF%E5%90%A6%E5%8F%AF%E4%BB%A5%E5%8F%91%E9%80%81%E8%AF%AD%E9%9F%B3) | -| /get_status | [获取插件运行状态](https://github.com/howmanybots/onebot/blob/master/v11/specs/api/public.md#get_status-%E8%8E%B7%E5%8F%96%E8%BF%90%E8%A1%8C%E7%8A%B6%E6%80%81) | -| /get_version_info | [获取 酷Q 及 CQHTTP插件的版本信息](https://github.com/howmanybots/onebot/blob/master/v11/specs/api/public.md#get_version_info-%E8%8E%B7%E5%8F%96%E7%89%88%E6%9C%AC%E4%BF%A1%E6%81%AF) | +##### 符合Onebot标准的API +| API | 功能 | +| ------------------------ | ---------------------- | +| /send_private_msg | [发送私聊消息] | +| /send_group_msg | [发送群消息] | +| /send_msg | [发送消息] | +| /delete_msg | [撤回信息] | +| /set_group_kick | [群组踢人] | +| /set_group_ban | [群组单人禁言] | +| /set_group_whole_ban | [群组全员禁言] | +| /set_group_admin | [群组设置管理员] | +| /set_group_card | [设置群名片(群备注)] | +| /set_group_name | [设置群名] | +| /set_group_leave | [退出群组] | +| /set_group_special_title | [设置群组专属头衔] | +| /set_friend_add_request | [处理加好友请求] | +| /set_group_add_request | [处理加群请求/邀请] | +| /get_login_info | [获取登录号信息] | +| /get_stranger_info | [获取陌生人信息] | +| /get_friend_list | [获取好友列表] | +| /get_group_info | [获取群信息] | +| /get_group_list | [获取群列表] | +| /get_group_member_info | [获取群成员信息] | +| /get_group_member_list | [获取群成员列表] | +| /get_group_honor_info | [获取群荣誉信息] | +| /can_send_image | [检查是否可以发送图片] | +| /can_send_record | [检查是否可以发送语音] | +| /get_version_info | [获取版本信息] | +| /set_restart | [重启go-cqhttp] | +| /.handle_quick_operation | [对事件执行快速操作] | + + +[发送私聊消息]: https://github.com/howmanybots/onebot/blob/master/v11/specs/api/public.md#send_private_msg-%E5%8F%91%E9%80%81%E7%A7%81%E8%81%8A%E6%B6%88%E6%81%AF +[发送群消息]: https://github.com/howmanybots/onebot/blob/master/v11/specs/api/public.md#send_group_msg-%E5%8F%91%E9%80%81%E7%BE%A4%E6%B6%88%E6%81%AF +[发送消息]: https://github.com/howmanybots/onebot/blob/master/v11/specs/api/public.md#send_msg-%E5%8F%91%E9%80%81%E6%B6%88%E6%81%AF +[撤回信息]: https://github.com/howmanybots/onebot/blob/master/v11/specs/api/public.md#delete_msg-%E6%92%A4%E5%9B%9E%E6%B6%88%E6%81%AF +[群组踢人]: https://github.com/howmanybots/onebot/blob/master/v11/specs/api/public.md#set_group_kick-%E7%BE%A4%E7%BB%84%E8%B8%A2%E4%BA%BA +[群组单人禁言]: https://github.com/howmanybots/onebot/blob/master/v11/specs/api/public.md#set_group_ban-%E7%BE%A4%E7%BB%84%E5%8D%95%E4%BA%BA%E7%A6%81%E8%A8%80 +[群组全员禁言]: https://github.com/howmanybots/onebot/blob/master/v11/specs/api/public.md#set_group_whole_ban-%E7%BE%A4%E7%BB%84%E5%85%A8%E5%91%98%E7%A6%81%E8%A8%80 +[群组设置管理员]: https://github.com/howmanybots/onebot/blob/master/v11/specs/api/public.md#set_group_admin-%E7%BE%A4%E7%BB%84%E8%AE%BE%E7%BD%AE%E7%AE%A1%E7%90%86%E5%91%98 +[设置群名片(群备注)]: https://github.com/howmanybots/onebot/blob/master/v11/specs/api/public.md#set_group_card-%E8%AE%BE%E7%BD%AE%E7%BE%A4%E5%90%8D%E7%89%87%E7%BE%A4%E5%A4%87%E6%B3%A8 +[设置群名]: https://github.com/howmanybots/onebot/blob/master/v11/specs/api/public.md#set_group_name-%E8%AE%BE%E7%BD%AE%E7%BE%A4%E5%90%8D +[退出群组]: https://github.com/howmanybots/onebot/blob/master/v11/specs/api/public.md#set_group_leave-%E9%80%80%E5%87%BA%E7%BE%A4%E7%BB%84 +[设置群组专属头衔]: https://github.com/howmanybots/onebot/blob/master/v11/specs/api/public.md#set_group_special_title-%E8%AE%BE%E7%BD%AE%E7%BE%A4%E7%BB%84%E4%B8%93%E5%B1%9E%E5%A4%B4%E8%A1%94 +[处理加好友请求]: https://github.com/howmanybots/onebot/blob/master/v11/specs/api/public.md#set_friend_add_request-%E5%A4%84%E7%90%86%E5%8A%A0%E5%A5%BD%E5%8F%8B%E8%AF%B7%E6%B1%82 +[处理加群请求/邀请]: https://github.com/howmanybots/onebot/blob/master/v11/specs/api/public.md#set_group_add_request-%E5%A4%84%E7%90%86%E5%8A%A0%E7%BE%A4%E8%AF%B7%E6%B1%82%E9%82%80%E8%AF%B7 +[获取登录号信息]: https://github.com/howmanybots/onebot/blob/master/v11/specs/api/public.md#get_login_info-%E8%8E%B7%E5%8F%96%E7%99%BB%E5%BD%95%E5%8F%B7%E4%BF%A1%E6%81%AF +[获取陌生人信息]: https://github.com/howmanybots/onebot/blob/master/v11/specs/api/public.md#get_stranger_info-%E8%8E%B7%E5%8F%96%E9%99%8C%E7%94%9F%E4%BA%BA%E4%BF%A1%E6%81%AF +[获取好友列表]: https://github.com/howmanybots/onebot/blob/master/v11/specs/api/public.md#get_friend_list-%E8%8E%B7%E5%8F%96%E5%A5%BD%E5%8F%8B%E5%88%97%E8%A1%A8 +[获取群信息]: https://github.com/howmanybots/onebot/blob/master/v11/specs/api/public.md#get_group_info-%E8%8E%B7%E5%8F%96%E7%BE%A4%E4%BF%A1%E6%81%AF +[获取群列表]: https://github.com/howmanybots/onebot/blob/master/v11/specs/api/public.md#get_group_list-%E8%8E%B7%E5%8F%96%E7%BE%A4%E5%88%97%E8%A1%A8 +[获取群成员信息]: https://github.com/howmanybots/onebot/blob/master/v11/specs/api/public.md#get_group_member_info-%E8%8E%B7%E5%8F%96%E7%BE%A4%E6%88%90%E5%91%98%E4%BF%A1%E6%81%AF +[获取群成员列表]: https://github.com/howmanybots/onebot/blob/master/v11/specs/api/public.md#get_group_member_list-%E8%8E%B7%E5%8F%96%E7%BE%A4%E6%88%90%E5%91%98%E5%88%97%E8%A1%A8 +[获取群荣誉信息]: https://github.com/howmanybots/onebot/blob/master/v11/specs/api/public.md#get_group_honor_info-%E8%8E%B7%E5%8F%96%E7%BE%A4%E8%8D%A3%E8%AA%89%E4%BF%A1%E6%81%AF +[检查是否可以发送图片]: https://github.com/howmanybots/onebot/blob/master/v11/specs/api/public.md#can_send_image-%E6%A3%80%E6%9F%A5%E6%98%AF%E5%90%A6%E5%8F%AF%E4%BB%A5%E5%8F%91%E9%80%81%E5%9B%BE%E7%89%87 +[检查是否可以发送语音]: https://github.com/howmanybots/onebot/blob/master/v11/specs/api/public.md#can_send_record-%E6%A3%80%E6%9F%A5%E6%98%AF%E5%90%A6%E5%8F%AF%E4%BB%A5%E5%8F%91%E9%80%81%E8%AF%AD%E9%9F%B3 +[获取版本信息]: https://github.com/howmanybots/onebot/blob/master/v11/specs/api/public.md#get_version_info-%E8%8E%B7%E5%8F%96%E7%89%88%E6%9C%AC%E4%BF%A1%E6%81%AF +[重启go-cqhttp]: https://github.com/howmanybots/onebot/blob/master/v11/specs/api/public.md#set_restart-%E9%87%8D%E5%90%AF-onebot-%E5%AE%9E%E7%8E%B0 +[对事件执行快速操作]: https://github.com/howmanybots/onebot/blob/master/v11/specs/api/hidden.md#handle_quick_operation-%E5%AF%B9%E4%BA%8B%E4%BB%B6%E6%89%A7%E8%A1%8C%E5%BF%AB%E9%80%9F%E6%93%8D%E4%BD%9C + +##### 拓展API及与Onebot标准有略微差异的API +| 拓展API | 功能 | +| --------------------------- | ---------------------- | +| /set_group_portrait | [设置群头像] | +| /get_image | [获取图片信息] | +| /get_msg | [获取消息] | +| /get_forward_msg | [获取合并转发内容] | +| /send_group_forward_msg | [发送合并转发(群)] | +| /.get_word_slices | [获取中文分词] | +| /.ocr_image | [图片OCR] | +| /get_group_system_msg | [获取群系统消息] | +| /get_group_file_system_info | [获取群文件系统信息] | +| /get_group_root_files | [获取群根目录文件列表] | +| /get_group_files_by_folder | [获取群子目录文件列表] | +| /get_group_file_url | [获取群文件资源链接] | +| /get_status | [获取状态] | + +[设置群头像]: docs/cqhttp.md#%E8%AE%BE%E7%BD%AE%E7%BE%A4%E5%A4%B4%E5%83%8F +[获取图片信息]: docs/cqhttp.md#%E8%8E%B7%E5%8F%96%E5%9B%BE%E7%89%87%E4%BF%A1%E6%81%AF +[获取消息]: docs/cqhttp.md#%E8%8E%B7%E5%8F%96%E6%B6%88%E6%81%AF +[获取合并转发内容]: docs/cqhttp.md#%E8%8E%B7%E5%8F%96%E5%90%88%E5%B9%B6%E8%BD%AC%E5%8F%91%E5%86%85%E5%AE%B9 +[发送合并转发(群)]: docs/cqhttp.md#%E5%8F%91%E9%80%81%E5%90%88%E5%B9%B6%E8%BD%AC%E5%8F%91%E7%BE%A4 +[获取中文分词]: docs/cqhttp.md#%E8%8E%B7%E5%8F%96%E4%B8%AD%E6%96%87%E5%88%86%E8%AF%8D +[图片OCR]: docs/cqhttp.md#%E5%9B%BE%E7%89%87ocr +[获取群系统消息]: docs/cqhttp.md#%E8%8E%B7%E5%8F%96%E7%BE%A4%E7%B3%BB%E7%BB%9F%E6%B6%88%E6%81%AF +[获取群文件系统信息]: docs/cqhttp.md#%E8%8E%B7%E5%8F%96%E7%BE%A4%E6%96%87%E4%BB%B6%E7%B3%BB%E7%BB%9F%E4%BF%A1%E6%81%AF +[获取群根目录文件列表]: docs/cqhttp.md#%E8%8E%B7%E5%8F%96%E7%BE%A4%E6%A0%B9%E7%9B%AE%E5%BD%95%E6%96%87%E4%BB%B6%E5%88%97%E8%A1%A8 +[获取群子目录文件列表]: docs/cqhttp.md#%E8%8E%B7%E5%8F%96%E7%BE%A4%E5%AD%90%E7%9B%AE%E5%BD%95%E6%96%87%E4%BB%B6%E5%88%97%E8%A1%A8 +[获取群文件资源链接]: docs/cqhttp.md#%E8%8E%B7%E5%8F%96%E7%BE%A4%E6%96%87%E4%BB%B6%E8%B5%84%E6%BA%90%E9%93%BE%E6%8E%A5 +[获取状态]: docs/cqhttp.md#%E8%8E%B7%E5%8F%96%E7%8A%B6%E6%80%81
已实现Event -##### 注意: 部分Event数据与CQHTTP原版略有差异,请参考文档 -| Event | -| ---------------------------------------------------------------------------------------------------------------------------------------------------- | -| [私聊信息](https://github.com/howmanybots/onebot/blob/master/v11/specs/event/message.md#%E7%A7%81%E8%81%8A%E6%B6%88%E6%81%AF) | -| [群消息](https://github.com/howmanybots/onebot/blob/master/v11/specs/event/message.md#%E7%BE%A4%E6%B6%88%E6%81%AF) | -| [群消息撤回(拓展Event)](docs/cqhttp.md#群消息撤回) | -| [好友消息撤回(拓展Event)](docs/cqhttp.md#好友消息撤回) | -| [群内提示事件(拓展Event)(龙王等事件)](docs/cqhttp.md#群内戳一戳) | -| [群管理员变动](https://github.com/howmanybots/onebot/blob/master/v11/specs/event/notice.md#%E7%BE%A4%E7%AE%A1%E7%90%86%E5%91%98%E5%8F%98%E5%8A%A8) | -| [群成员减少](https://github.com/howmanybots/onebot/blob/master/v11/specs/event/notice.md#%E7%BE%A4%E6%88%90%E5%91%98%E5%87%8F%E5%B0%91) | -| [群成员增加](https://github.com/howmanybots/onebot/blob/master/v11/specs/event/notice.md#%E7%BE%A4%E6%88%90%E5%91%98%E5%A2%9E%E5%8A%A0) | -| [群禁言](https://github.com/howmanybots/onebot/blob/master/v11/specs/event/notice.md#%E7%BE%A4%E7%A6%81%E8%A8%80) | -| [群文件上传](https://github.com/howmanybots/onebot/blob/master/v11/specs/event/notice.md#%E7%BE%A4%E6%96%87%E4%BB%B6%E4%B8%8A%E4%BC%A0) | -| [加好友请求](https://github.com/howmanybots/onebot/blob/master/v11/specs/event/request.md#%E5%8A%A0%E5%A5%BD%E5%8F%8B%E8%AF%B7%E6%B1%82) | -| [加群请求/邀请](https://github.com/howmanybots/onebot/blob/master/v11/specs/event/request.md#%E5%8A%A0%E7%BE%A4%E8%AF%B7%E6%B1%82%E9%82%80%E8%AF%B7) | +##### 符合Onebot标准的Event(部分Event比Onebot标准多上报几个字段,不影响使用) +| 事件类型 | Event | +| -------- | ---------------- | +| 消息事件 | [私聊信息] | +| 消息事件 | [群消息] | +| 通知事件 | [群文件上传] | +| 通知事件 | [群管理员变动] | +| 通知事件 | [群成员减少] | +| 通知事件 | [群成员增加] | +| 通知事件 | [群禁言] | +| 通知事件 | [好友添加] | +| 通知事件 | [群消息撤回] | +| 通知事件 | [好友消息撤回] | +| 通知事件 | [群内戳一戳] | +| 通知事件 | [群红包运气王] | +| 通知事件 | [群成员荣誉变更] | +| 请求事件 | [加好友请求] | +| 请求事件 | [加群请求/邀请] | + +[私聊信息]: https://github.com/howmanybots/onebot/blob/master/v11/specs/event/message.md#%E7%A7%81%E8%81%8A%E6%B6%88%E6%81%AF +[群消息]: https://github.com/howmanybots/onebot/blob/master/v11/specs/event/message.md#%E7%BE%A4%E6%B6%88%E6%81%AF +[群文件上传]: https://github.com/howmanybots/onebot/blob/master/v11/specs/event/notice.md#%E7%BE%A4%E6%96%87%E4%BB%B6%E4%B8%8A%E4%BC%A0 +[群管理员变动]: https://github.com/howmanybots/onebot/blob/master/v11/specs/event/notice.md#%E7%BE%A4%E7%AE%A1%E7%90%86%E5%91%98%E5%8F%98%E5%8A%A8 +[群成员减少]: https://github.com/howmanybots/onebot/blob/master/v11/specs/event/notice.md#%E7%BE%A4%E6%88%90%E5%91%98%E5%87%8F%E5%B0%91 +[群成员增加]: https://github.com/howmanybots/onebot/blob/master/v11/specs/event/notice.md#%E7%BE%A4%E6%88%90%E5%91%98%E5%A2%9E%E5%8A%A0 +[群禁言]: https://github.com/howmanybots/onebot/blob/master/v11/specs/event/notice.md#%E7%BE%A4%E7%A6%81%E8%A8%80 +[好友添加]: https://github.com/howmanybots/onebot/blob/master/v11/specs/event/notice.md#%E5%A5%BD%E5%8F%8B%E6%B7%BB%E5%8A%A0 +[群消息撤回]: https://github.com/howmanybots/onebot/blob/master/v11/specs/event/notice.md#%E7%BE%A4%E6%B6%88%E6%81%AF%E6%92%A4%E5%9B%9E +[好友消息撤回]: https://github.com/howmanybots/onebot/blob/master/v11/specs/event/notice.md#%E5%A5%BD%E5%8F%8B%E6%B6%88%E6%81%AF%E6%92%A4%E5%9B%9E +[群内戳一戳]: https://github.com/howmanybots/onebot/blob/master/v11/specs/event/notice.md#%E7%BE%A4%E5%86%85%E6%88%B3%E4%B8%80%E6%88%B3 +[群红包运气王]: https://github.com/howmanybots/onebot/blob/master/v11/specs/event/notice.md#%E7%BE%A4%E7%BA%A2%E5%8C%85%E8%BF%90%E6%B0%94%E7%8E%8B +[群成员荣誉变更]: https://github.com/howmanybots/onebot/blob/master/v11/specs/event/notice.md#%E7%BE%A4%E6%88%90%E5%91%98%E8%8D%A3%E8%AA%89%E5%8F%98%E6%9B%B4 +[加好友请求]: https://github.com/howmanybots/onebot/blob/master/v11/specs/event/request.md#%E5%8A%A0%E5%A5%BD%E5%8F%8B%E8%AF%B7%E6%B1%82 +[加群请求/邀请]: https://github.com/howmanybots/onebot/blob/master/v11/specs/event/request.md#%E5%8A%A0%E7%BE%A4%E8%AF%B7%E6%B1%82%E9%82%80%E8%AF%B7 + +##### 拓展Event +| 事件类型 | 拓展Event | +| -------- | ---------------- | +| 通知事件 | [好友戳一戳] | +| 通知事件 | [群成员名片更新] | +| 通知事件 | [接收到离线文件] | + +[好友戳一戳]: docs/cqhttp.md#%E5%A5%BD%E5%8F%8B%E6%88%B3%E4%B8%80%E6%88%B3 +[群成员名片更新]: docs/cqhttp.md#%E7%BE%A4%E6%88%90%E5%91%98%E5%90%8D%E7%89%87%E6%9B%B4%E6%96%B0 +[接收到离线文件]: docs/cqhttp.md#%E6%8E%A5%E6%94%B6%E5%88%B0%E7%A6%BB%E7%BA%BF%E6%96%87%E4%BB%B6
diff --git a/docs/cqhttp.md b/docs/cqhttp.md index 5f51c32..d250d5d 100644 --- a/docs/cqhttp.md +++ b/docs/cqhttp.md @@ -25,21 +25,6 @@ | 40004 | 爱你 | | 40005 | 征友 | - -### 回复 - -Type : `reply` - -范围: **发送/接收** - -参数: - -| 参数名 | 类型 | 说明 | -| ------ | ---- | ------------------------------------- | -| id | int | 回复时所引用的消息id, 必须为本群消息. | - -示例: `[CQ:reply,id=123456]` - ### 红包 Type: `redbag` @@ -108,20 +93,6 @@ Type: `gift` 示例: `[CQ:gift,qq=123456,id=8]` - ### 合并转发 - -Type: `forward` - -范围: **接收** - -参数: - -| 参数名 | 类型 | 说明 | -| ------ | ------ | ------------------------------------------------------------- | -| id | string | 合并转发ID, 需要通过 `/get_forward_msg` API获取转发的具体内容 | - -示例: `[CQ:forward,id=xxxx]` - ### 合并转发消息节点 Type: `node` @@ -333,17 +304,6 @@ Type: `tts` ## API -### 设置群名 - -终结点: `/set_group_name` - -**参数** - -| 字段 | 类型 | 说明 | -| ---------- | ------ | ---- | -| group_id | int64 | 群号 | -| group_name | string | 新名 | - ### 设置群头像 终结点: `/set_group_portrait` @@ -681,74 +641,19 @@ Type: `tts` ## 事件 -#### 群消息撤回 +#### 好友戳一戳 **上报数据** -| 字段 | 类型 | 可能的值 | 说明 | -| ------------- | ------ | -------------- | -------------- | -| `post_type` | string | `notice` | 上报类型 | -| `notice_type` | string | `group_recall` | 消息类型 | -| `group_id` | int64 | | 群号 | -| `user_id` | int64 | | 消息发送者id | -| `operator_id` | int64 | | 操作者id | -| `message_id` | int64 | | 被撤回的消息id | - -#### 好友消息撤回 - -**上报数据** - -| 字段 | 类型 | 可能的值 | 说明 | -| ------------- | ------ | --------------- | -------------- | -| `post_type` | string | `notice` | 上报类型 | -| `notice_type` | string | `friend_recall` | 消息类型 | -| `user_id` | int64 | | 好友id | -| `message_id` | int64 | | 被撤回的消息id | - -#### 群内戳一戳 - -> 注意:此事件无法在平板和手表协议上触发 - -**上报数据** - -| 字段 | 类型 | 可能的值 | 说明 | -| ------------- | ------ | -------- | -------- | -| `post_type` | string | `notice` | 上报类型 | -| `notice_type` | string | `notify` | 消息类型 | -| `group_id` | int64 | | 群号 | -| `sub_type` | string | `poke` | 提示类型 | -| `user_id` | int64 | | 发送者id | -| `target_id` | int64 | | 被戳者id | - -#### 群红包运气王提示 - -> 注意:此事件无法在平板和手表协议上触发 - -**上报数据** - -| 字段 | 类型 | 可能的值 | 说明 | -| ------------- | ------ | ------------ | ------------ | -| `post_type` | string | `notice` | 上报类型 | -| `notice_type` | string | `notify` | 消息类型 | -| `group_id` | int64 | | 群号 | -| `sub_type` | string | `lucky_king` | 提示类型 | -| `user_id` | int64 | | 红包发送者id | -| `target_id` | int64 | | 运气王id | - -#### 群成员荣誉变更提示 - -> 注意:此事件无法在平板和手表协议上触发 - -**上报数据** - -| 字段 | 类型 | 可能的值 | 说明 | -| ------------- | ------ | -------------------------------------------------------- | -------- | -| `post_type` | string | `notice` | 上报类型 | -| `notice_type` | string | `notify` | 消息类型 | -| `group_id` | int64 | | 群号 | -| `sub_type` | string | `honor` | 提示类型 | -| `user_id` | int64 | | 成员id | -| `honor_type` | string | `talkative:龙王` `performer:群聊之火` `emotion:快乐源泉` | 荣誉类型 | +| 字段 | 类型 | 可能的值 | 说明 | +| ------------- | ------ | ------------ | --------------------- | +| `post_type` | string | `notice` | 上报类型 | +| `notice_type` | string | `group_card` | 通知类型 | +| `sub_type` | string | `poke` | 事件子类型 | +| `self_id` | int64 | | 收到事件的机器人QQ 号 | +| `user_id` | int64 | | 发送者QQ号 | +| `target_id` | int64 | | 被戳者QQ号 | +| `time` | int64 | | 事件发生的时间戳 | #### 群成员名片更新 @@ -756,14 +661,16 @@ Type: `tts` **上报数据** -| 字段 | 类型 | 可能的值 | 说明 | -| ------------- | ------ | ------------ | -------- | -| `post_type` | string | `notice` | 上报类型 | -| `notice_type` | string | `group_card` | 消息类型 | -| `group_id` | int64 | | 群号 | -| `user_id` | int64 | | 成员id | -| `card_new` | int64 | | 新名片 | -| `card_old` | int64 | | 旧名片 | +| 字段 | 类型 | 可能的值 | 说明 | +| ------------- | ------ | ------------ | --------------------- | +| `post_type` | string | `notice` | 上报类型 | +| `notice_type` | string | `group_card` | 消息类型 | +| `group_id` | int64 | | 群号 | +| `user_id` | int64 | | 成员id | +| `card_new` | int64 | | 新名片 | +| `card_old` | int64 | | 旧名片 | +| `self_id` | int64 | | 收到事件的机器人QQ 号 | +| `time` | int64 | | 事件发生的时间戳 | > PS: 当名片为空时 `card_xx` 字段为空字符串, 并不是昵称 @@ -771,12 +678,14 @@ Type: `tts` **上报数据** -| 字段 | 类型 | 可能的值 | 说明 | -| ------------- | ------ | -------------- | -------- | -| `post_type` | string | `notice` | 上报类型 | -| `notice_type` | string | `offline_file` | 消息类型 | -| `user_id` | int64 | | 发送者id | -| `file` | object | | 文件数据 | +| 字段 | 类型 | 可能的值 | 说明 | +| ------------- | ------ | -------------- | --------------------- | +| `post_type` | string | `notice` | 上报类型 | +| `notice_type` | string | `offline_file` | 消息类型 | +| `user_id` | int64 | | 发送者id | +| `self_id` | int64 | | 收到事件的机器人QQ 号 | +| `time` | int64 | | 事件发生的时间戳 | +| `file` | object | | 文件数据 | **file object** From 35a1a0f8b5be7cac3c74ae5914ce563c06053a5d Mon Sep 17 00:00:00 2001 From: Mrs4s <1844812067@qq.com> Date: Sat, 5 Dec 2020 18:17:37 +0800 Subject: [PATCH 07/13] update MiraiGo. --- go.mod | 6 +----- go.sum | 29 +++-------------------------- 2 files changed, 4 insertions(+), 31 deletions(-) diff --git a/go.mod b/go.mod index 67c87d4..8382409 100644 --- a/go.mod +++ b/go.mod @@ -3,9 +3,8 @@ module github.com/Mrs4s/go-cqhttp go 1.15 require ( - github.com/Mrs4s/MiraiGo v0.0.0-20201203010528-a1ecf84cac2b + github.com/Mrs4s/MiraiGo v0.0.0-20201204063549-4d6459e1de6d github.com/dustin/go-humanize v1.0.0 - github.com/fastly/go-utils v0.0.0-20180712184237-d95a45783239 // indirect github.com/getlantern/go-update v0.0.0-20190510022740-79c495ab728c github.com/getlantern/golog v0.0.0-20201105130739-9586b8bde3a9 // indirect github.com/gin-contrib/pprof v1.3.0 @@ -13,8 +12,6 @@ require ( github.com/gorilla/websocket v1.4.2 github.com/guonaihong/gout v0.1.3 github.com/hjson/hjson-go v3.1.0+incompatible - github.com/jehiah/go-strftime v0.0.0-20171201141054-1d33003b3869 // indirect - github.com/jonboulle/clockwork v0.2.2 // indirect github.com/json-iterator/go v1.1.10 github.com/kardianos/osext v0.0.0-20190222173326-2bc1f35cddc0 // indirect github.com/kr/binarydist v0.1.0 // indirect @@ -24,7 +21,6 @@ require ( github.com/sirupsen/logrus v1.7.0 github.com/syndtr/goleveldb v1.0.0 github.com/t-tomalak/logrus-easy-formatter v0.0.0-20190827215021-c074f06c5816 - github.com/tebeka/strftime v0.1.5 // indirect github.com/tidwall/gjson v1.6.3 github.com/wdvxdr1123/go-silk v0.0.0-20201203155442-67728040c843 github.com/yinghau76/go-ascii-art v0.0.0-20190517192627-e7f465a30189 diff --git a/go.sum b/go.sum index 6fa1266..811a384 100644 --- a/go.sum +++ b/go.sum @@ -1,19 +1,15 @@ cloud.google.com/go v0.26.0/go.mod h1:aQUYkXzVsufM+DwF1aE+0xfcU+56JwCaLick0ClmMTw= github.com/BurntSushi/toml v0.3.1/go.mod h1:xHWCNGjB5oqiDr8zfno3MHue2Ht5sIBksp03qcyfWMU= -github.com/Mrs4s/MiraiGo v0.0.0-20201203010528-a1ecf84cac2b h1:CUzjI0hmu4sbjm0E13hNVXubNr8fbRB99mAwuJ3l1JE= -github.com/Mrs4s/MiraiGo v0.0.0-20201203010528-a1ecf84cac2b/go.mod h1:J1zaJWyeX7hQIPpOobqb8opxTNPbguotudPPrHJMoDM= +github.com/Mrs4s/MiraiGo v0.0.0-20201204063549-4d6459e1de6d h1:fD7QubAbdP1tu4jTTLFD2BkTLD45uPH7UwSXJm+D3oA= +github.com/Mrs4s/MiraiGo v0.0.0-20201204063549-4d6459e1de6d/go.mod h1:J1zaJWyeX7hQIPpOobqb8opxTNPbguotudPPrHJMoDM= github.com/census-instrumentation/opencensus-proto v0.2.1/go.mod h1:f6KPmirojxKA12rnyqOA5BBL4O983OfeGPqjHWSTneU= github.com/client9/misspell v0.3.4/go.mod h1:qj6jICC3Q7zFZvVWo7KLAzC3yx5G7kyvSDkc90ppPyw= github.com/davecgh/go-spew v1.1.0/go.mod h1:J7Y8YcW2NihsgmVo/mv3lAwl/skON4iLHjSsI+c5H38= -github.com/davecgh/go-spew v1.1.1 h1:vj9j/u1bqnvCEfJOwUhtlOARqs3+rkHYY13jYWTU97c= github.com/davecgh/go-spew v1.1.1/go.mod h1:J7Y8YcW2NihsgmVo/mv3lAwl/skON4iLHjSsI+c5H38= github.com/dustin/go-humanize v1.0.0 h1:VSnTsYCnlFHaM2/igO1h6X3HA71jcobQuxemgkq4zYo= github.com/dustin/go-humanize v1.0.0/go.mod h1:HtrtbFcZ19U5GC7JDqmcUSB87Iq5E25KnS6fMYU6eOk= github.com/envoyproxy/go-control-plane v0.9.1-0.20191026205805-5f8ba28d4473/go.mod h1:YTl/9mNaCwkRvm6d1a2C3ymFceY/DCBVvsKhRF0iEA4= github.com/envoyproxy/protoc-gen-validate v0.1.0/go.mod h1:iSmxcyjqTsJpI2R4NaDN7+kN2VEUnK/pcBlmesArF7c= -github.com/fastly/go-utils v0.0.0-20180712184237-d95a45783239 h1:Ghm4eQYC0nEPnSJdVkTrXpu9KtoVCSo1hg7mtI7G9KU= -github.com/fastly/go-utils v0.0.0-20180712184237-d95a45783239/go.mod h1:Gdwt2ce0yfBxPvZrHkprdPPTTS3N5rwmLE8T22KBXlw= -github.com/fsnotify/fsnotify v1.4.7 h1:IXs+QLmnXW2CcXuY+8Mzv/fWEsPGWxqefPtCP5CnV9I= github.com/fsnotify/fsnotify v1.4.7/go.mod h1:jwhsz4b93w/PPRr/qN1Yymfu8t87LnFCMoQvtojpjFo= github.com/getlantern/context v0.0.0-20190109183933-c447772a6520 h1:NRUJuo3v3WGC/g5YiyF790gut6oQr5f3FBI88Wv0dx4= github.com/getlantern/context v0.0.0-20190109183933-c447772a6520/go.mod h1:L+mq6/vvYHKjCX2oez0CgEAJmbq1fbb/oNJIWQkBybY= @@ -37,7 +33,6 @@ github.com/gin-gonic/gin v1.5.0/go.mod h1:Nd6IXA8m5kNZdNEHMBd93KT+mdY3+bewLgRvmC github.com/gin-gonic/gin v1.6.2/go.mod h1:75u5sXoLsGZoRN5Sgbi1eraJ4GU3++wFwWzhwvtwp4M= github.com/gin-gonic/gin v1.6.3 h1:ahKqKTFpO5KTPHxWZjEdPScmYaGtLo8Y4DMHoEsnp14= github.com/gin-gonic/gin v1.6.3/go.mod h1:75u5sXoLsGZoRN5Sgbi1eraJ4GU3++wFwWzhwvtwp4M= -github.com/go-playground/assert/v2 v2.0.1 h1:MsBgLAaY856+nPRTKrp3/OZK38U/wa0CcBYNjji3q3A= github.com/go-playground/assert/v2 v2.0.1/go.mod h1:VDjEfimB/XKnb+ZQfWdccd7VUvScMdVu0Titje2rxJ4= github.com/go-playground/locales v0.12.1/go.mod h1:IUMDtCfWo/w/mtMfIE/IG2K+Ey3ygWanZIBtBW0W2TM= github.com/go-playground/locales v0.13.0 h1:HyWk6mgj5qFqCT5fjGBuRArbVDfE4hi8+e8ceBS/t7Q= @@ -68,23 +63,17 @@ github.com/google/go-cmp v0.2.0/go.mod h1:oXzfMopK8JAjlY9xF4vHSVASa0yLyX7SntLO5a github.com/google/go-cmp v0.3.0/go.mod h1:8QqcDgzrUqlUb/G2PQTWiueGozuR1884gddMywk6iLU= github.com/google/go-cmp v0.3.1/go.mod h1:8QqcDgzrUqlUb/G2PQTWiueGozuR1884gddMywk6iLU= github.com/google/go-cmp v0.4.0/go.mod h1:v8dTdLbMG2kIc/vJvl+f65V22dbkXbowE6jgT/gNBxE= -github.com/google/go-cmp v0.5.0 h1:/QaMHBdZ26BB3SSst0Iwl10Epc+xhTquomWX0oZEB6w= github.com/google/go-cmp v0.5.0/go.mod h1:v8dTdLbMG2kIc/vJvl+f65V22dbkXbowE6jgT/gNBxE= github.com/google/gofuzz v1.0.0/go.mod h1:dBl0BpW6vV/+mYPU4Po3pmUjxk6FQPldtuIdl/M65Eg= -github.com/google/uuid v1.1.1 h1:Gkbcsh/GbpXz7lPftLA3P6TYMwjCLYm83jiFQZF/3gY= github.com/google/uuid v1.1.1/go.mod h1:TIyPZe4MgqvfeYDBFedMoGGpEw/LqOeaOT+nhxU+yHo= github.com/gorilla/websocket v1.4.2 h1:+/TMaTYc4QFitKJxsQ7Yye35DkWvkdLcvGKqM+x0Ufc= github.com/gorilla/websocket v1.4.2/go.mod h1:YR8l580nyteQvAITg2hZ9XVh4b55+EU/adAjf1fMHhE= github.com/guonaihong/gout v0.1.3 h1:BIiV6nnsA+R6dIB1P33uhCM8+TVAG3zHrXGZad7hDc8= github.com/guonaihong/gout v0.1.3/go.mod h1:vXvv5Kxr70eM5wrp4F0+t9lnLWmq+YPW2GByll2f/EA= +github.com/hjson/hjson-go v0.2.3 h1:KhG7/PSxTibbYOzFso5FoiX2gWePcANaCsvM1WE/bTo= github.com/hjson/hjson-go v3.1.0+incompatible h1:DY/9yE8ey8Zv22bY+mHV1uk2yRy0h8tKhZ77hEdi0Aw= github.com/hjson/hjson-go v3.1.0+incompatible/go.mod h1:qsetwF8NlsTsOTwZTApNlTCerV+b2GjYRRcIk4JMFio= -github.com/hpcloud/tail v1.0.0 h1:nfCOvKYfkgYP8hkirhJocXT2+zOD8yUNjXaWfTlyFKI= github.com/hpcloud/tail v1.0.0/go.mod h1:ab1qPbhIpdTxEkNHXyeSf5vhxWSCs/tWer42PpOxQnU= -github.com/jehiah/go-strftime v0.0.0-20171201141054-1d33003b3869 h1:IPJ3dvxmJ4uczJe5YQdrYB16oTJlGSC/OyZDqUk9xX4= -github.com/jehiah/go-strftime v0.0.0-20171201141054-1d33003b3869/go.mod h1:cJ6Cj7dQo+O6GJNiMx+Pa94qKj+TG8ONdKHgMNIyyag= -github.com/jonboulle/clockwork v0.2.2 h1:UOGuzwb1PwsrDAObMuhUnj0p5ULPj8V/xJ7Kx9qUBdQ= -github.com/jonboulle/clockwork v0.2.2/go.mod h1:Pkfl5aHPm1nk2H9h0bjmnJD/BcgbGXUBGnn1kMkgxc8= github.com/json-iterator/go v1.1.7/go.mod h1:KdQUCv79m/52Kvf8AW2vK1V8akMuk1QjK/uOdHXbAo4= github.com/json-iterator/go v1.1.9/go.mod h1:KdQUCv79m/52Kvf8AW2vK1V8akMuk1QjK/uOdHXbAo4= github.com/json-iterator/go v1.1.10 h1:Kz6Cvnvv2wGdaG/V8yMvfkmNiXq9Ya2KUv4rouJJr68= @@ -97,7 +86,6 @@ github.com/kr/binarydist v0.1.0/go.mod h1:DY7S//GCoz1BCd0B0EVrinCKAZN3pXe+MDaIZb github.com/leodido/go-urn v1.1.0/go.mod h1:+cyI34gQWZcE1eQU7NVgKkkzdXDQHr1dBMtdAPozLkw= github.com/leodido/go-urn v1.2.0 h1:hpXL4XnriNwQ/ABnpepYM/1vCLWNDfUNts8dX3xTG6Y= github.com/leodido/go-urn v1.2.0/go.mod h1:+8+nEpDfqqsY+g338gtMEUOtuK+4dEMhiQEgxpxOKII= -github.com/lestrrat-go/envload v0.0.0-20180220234015-a3eb8ddeffcc h1:RKf14vYWi2ttpEmkA4aQ3j4u9dStX2t4M8UM6qqNsG8= github.com/lestrrat-go/envload v0.0.0-20180220234015-a3eb8ddeffcc/go.mod h1:kopuH9ugFRkIXf3YoqHKyrJ9YfUFsckUU9S7B+XP+is= github.com/lestrrat-go/file-rotatelogs v2.4.0+incompatible h1:Y6sqxHMyB1D2YSzWkLibYKgg+SwmyFU9dF2hn6MdTj4= github.com/lestrrat-go/file-rotatelogs v2.4.0+incompatible/go.mod h1:ZQnN8lSECaebrkQytbHj4xNgtg8CR7RYXnPok8e0EHA= @@ -113,16 +101,13 @@ github.com/modern-go/reflect2 v0.0.0-20180701023420-4b7aa43c6742/go.mod h1:bx2lN github.com/nfnt/resize v0.0.0-20180221191011-83c6a9932646 h1:zYyBkD/k9seD2A7fsi6Oo2LfFZAehjjQMERAvZLEDnQ= github.com/nfnt/resize v0.0.0-20180221191011-83c6a9932646/go.mod h1:jpp1/29i3P1S/RLdc7JQKbRpFeM1dOBd8T9ki5s+AY8= github.com/onsi/ginkgo v1.6.0/go.mod h1:lLunBs/Ym6LB5Z9jYTR76FiuTmxDTDusOGeTQH+WWjE= -github.com/onsi/ginkgo v1.7.0 h1:WSHQ+IS43OoUrWtD1/bbclrwK8TTH5hzp+umCiuxHgs= github.com/onsi/ginkgo v1.7.0/go.mod h1:lLunBs/Ym6LB5Z9jYTR76FiuTmxDTDusOGeTQH+WWjE= -github.com/onsi/gomega v1.4.3 h1:RE1xgDvH7imwFD45h+u2SgIfERHlS2yNG4DObb5BSKU= github.com/onsi/gomega v1.4.3/go.mod h1:ex+gbHU/CVuBBDIJjb2X0qEXbFg53c61hWP/1CpauHY= github.com/oxtoacart/bpool v0.0.0-20190530202638-03653db5a59c h1:rp5dCmg/yLR3mgFuSOe4oEnDDmGLROTvMragMUXpTQw= github.com/oxtoacart/bpool v0.0.0-20190530202638-03653db5a59c/go.mod h1:X07ZCGwUbLaax7L0S3Tw4hpejzu63ZrrQiUe6W0hcy0= github.com/pkg/errors v0.8.1/go.mod h1:bwawxfHBFNV+L2hUp1rHADufV3IMtnDRdf1r5NINEl0= github.com/pkg/errors v0.9.1 h1:FEBLx1zS214owpjy7qsBeixbURkuhQAwrK5UwLGTwt4= github.com/pkg/errors v0.9.1/go.mod h1:bwawxfHBFNV+L2hUp1rHADufV3IMtnDRdf1r5NINEl0= -github.com/pmezard/go-difflib v1.0.0 h1:4DBwDE0NGyQoBHbLQYPwSUPoCMWR5BEzIk/f1lZbAQM= github.com/pmezard/go-difflib v1.0.0/go.mod h1:iKH77koFhYxTK1pcRnkKkqfTogsbg7gZNVY4sRDYZ/4= github.com/prometheus/client_model v0.0.0-20190812154241-14fe0d1b01d4/go.mod h1:xMI15A0UPsDsEKsMN9yxemIoYk6Tm2C1GtYGdfGttqA= github.com/rifflock/lfshook v0.0.0-20180920164130-b9218ef580f5 h1:mZHayPoR0lNmnHyvtYjDeq0zlVHn9K/ZXoy17ylucdo= @@ -134,14 +119,11 @@ github.com/stretchr/objx v0.1.0/go.mod h1:HFkY916IF+rwdDfMAkV7OtwuqBVzrE8GR6GFx+ github.com/stretchr/objx v0.1.1/go.mod h1:HFkY916IF+rwdDfMAkV7OtwuqBVzrE8GR6GFx+wExME= github.com/stretchr/testify v1.2.2/go.mod h1:a8OnRcib4nhh0OaRAV+Yts87kKdq0PP7pXfy6kDkUVs= github.com/stretchr/testify v1.3.0/go.mod h1:M5WIy9Dh21IEIfnGCwXGc5bZfKNJtfHm1UVUgZn+9EI= -github.com/stretchr/testify v1.4.0 h1:2E4SXV/wtOkTonXsotYi4li6zVWxYlZuYNCXe9XRJyk= github.com/stretchr/testify v1.4.0/go.mod h1:j7eGeouHqKxXV5pUuKE4zz7dFj8WfuZ+81PSLYec5m4= github.com/syndtr/goleveldb v1.0.0 h1:fBdIW9lB4Iz0n9khmH8w27SJ3QEJ7+IgjPEwGSZiFdE= github.com/syndtr/goleveldb v1.0.0/go.mod h1:ZVVdQEZoIme9iO1Ch2Jdy24qqXrMMOU6lpPAyBWyWuQ= github.com/t-tomalak/logrus-easy-formatter v0.0.0-20190827215021-c074f06c5816 h1:J6v8awz+me+xeb/cUTotKgceAYouhIB3pjzgRd6IlGk= github.com/t-tomalak/logrus-easy-formatter v0.0.0-20190827215021-c074f06c5816/go.mod h1:tzym/CEb5jnFI+Q0k4Qq3+LvRF4gO3E2pxS8fHP8jcA= -github.com/tebeka/strftime v0.1.5 h1:1NQKN1NiQgkqd/2moD6ySP/5CoZQsKa1d3ZhJ44Jpmg= -github.com/tebeka/strftime v0.1.5/go.mod h1:29/OidkoWHdEKZqzyDLUyC+LmgDgdHo4WAFCDT7D/Ig= github.com/tidwall/gjson v1.6.3 h1:aHoiiem0dr7GHkW001T1SMTJ7X5PvyekH5WX0whWGnI= github.com/tidwall/gjson v1.6.3/go.mod h1:BaHyNc5bjzYkPqgLq7mdVzeiRtULKULXLgZFKsxEHI0= github.com/tidwall/match v1.0.1 h1:PnKP62LPNxHKTwvHHZZzdOAOCtsJTjo6dZLCwpKm5xc= @@ -181,7 +163,6 @@ golang.org/x/sys v0.0.0-20191026070338-33540a1f6037/go.mod h1:h1NjWce9XRLGQEsW7w golang.org/x/sys v0.0.0-20200116001909-b77594299b42 h1:vEOn+mP2zCOVzKckCZy6YsCtDblrpj/w7B9nxGNELpg= golang.org/x/sys v0.0.0-20200116001909-b77594299b42/go.mod h1:h1NjWce9XRLGQEsW7wpKNCjG9DtNlClVuFLEZdDNbEs= golang.org/x/text v0.3.0/go.mod h1:NqM8EUOU14njkJ3fqMW+pc6Ldnwhi/IjpwHt7yyuwOQ= -golang.org/x/text v0.3.2 h1:tW2bmiBqwgJj/UpqtC8EpXEZVYOwU0yG4iWbprSVAcs= golang.org/x/text v0.3.2/go.mod h1:bEr9sfX3Q8Zfm5fL9x+3itogRgK3+ptLWKqgva+5dAk= golang.org/x/time v0.0.0-20200630173020-3af7569d3a1e h1:EHBhcS0mlXEAVwNyO2dLfjToGsyY4j24pTs2ScHnX7s= golang.org/x/time v0.0.0-20200630173020-3af7569d3a1e/go.mod h1:tRJNPiyCQ0inRvYxbN9jk5I+vvW/OXSQhTDSoE431IQ= @@ -190,7 +171,6 @@ golang.org/x/tools v0.0.0-20190114222345-bf090417da8b/go.mod h1:n7NCudcB/nEzxVGm golang.org/x/tools v0.0.0-20190226205152-f727befe758c/go.mod h1:9Yl7xja0Znq3iFh3HoIrodX9oNMXvdceNzlUR8zjMvY= golang.org/x/tools v0.0.0-20190311212946-11955173bddd/go.mod h1:LCzVGOaR6xXOjkQ3onu1FJEFr0SW1gC7cKk1uF8kGRs= golang.org/x/tools v0.0.0-20190524140312-2c0ae7006135/go.mod h1:RgjU9mgBXZiqYHBnxXauZ1Gv1EHHAz9KjViQ78xBX0Q= -golang.org/x/xerrors v0.0.0-20191204190536-9bdfabe68543 h1:E7g+9GITq07hpfrRu66IVDexMakfv52eLZ2CXBWiKr4= golang.org/x/xerrors v0.0.0-20191204190536-9bdfabe68543/go.mod h1:I/5z698sn9Ka8TeJc9MKroUUfqBBauWjQqLJ2OPfmY0= google.golang.org/appengine v1.1.0/go.mod h1:EbEs0AVv82hx2wNQdGPgUI5lhzA/G0D9YwlJXL52JkM= google.golang.org/appengine v1.4.0/go.mod h1:xpcJRLb0r/rnEns0DIKYYv+WjYCduHsrkT7/EB5XEv4= @@ -210,13 +190,10 @@ google.golang.org/protobuf v1.23.0/go.mod h1:EGpADcykh3NcUnDUJcl1+ZksZNG86OlYog2 google.golang.org/protobuf v1.23.1-0.20200526195155-81db48ad09cc/go.mod h1:EGpADcykh3NcUnDUJcl1+ZksZNG86OlYog2l/sGQquU= google.golang.org/protobuf v1.25.0 h1:Ejskq+SyPohKW+1uil0JJMtmHCgJPJ/qWTxr8qp+R4c= google.golang.org/protobuf v1.25.0/go.mod h1:9JNX74DMeImyA3h4bdi1ymwjUzf21/xIlbajtzgsN7c= -gopkg.in/check.v1 v0.0.0-20161208181325-20d25e280405 h1:yhCVgyC4o1eVCa2tZl7eS0r+SDo693bJlVdllGtEeKM= gopkg.in/check.v1 v0.0.0-20161208181325-20d25e280405/go.mod h1:Co6ibVJAznAaIkqp8huTwlJQCZ016jof/cbN4VW5Yz0= -gopkg.in/fsnotify.v1 v1.4.7 h1:xOHLXZwVvI9hhs+cLKq5+I5onOuwQLhQwiu63xxlHs4= gopkg.in/fsnotify.v1 v1.4.7/go.mod h1:Tz8NjZHkW78fSQdbUxIjBTcgA1z1m8ZHf0WmKUhAMys= gopkg.in/go-playground/assert.v1 v1.2.1/go.mod h1:9RXL0bg/zibRAgZUYszZSwO/z8Y/a8bDuhia5mkpMnE= gopkg.in/go-playground/validator.v9 v9.29.1/go.mod h1:+c9/zcJMFNgbLvly1L1V+PpxWdVbfP1avr/N00E2vyQ= -gopkg.in/tomb.v1 v1.0.0-20141024135613-dd632973f1e7 h1:uRGJdciOHaEIrze2W8Q3AKkepLTh2hOroT7a+7czfdQ= gopkg.in/tomb.v1 v1.0.0-20141024135613-dd632973f1e7/go.mod h1:dt/ZhP58zS4L8KSrWDmTeBkI65Dw0HsyUHuEVlX15mw= gopkg.in/yaml.v2 v2.2.1/go.mod h1:hI93XBmqTisBFMUTm0b8Fm+jr3Dg1NNxqwp+5A1VGuI= gopkg.in/yaml.v2 v2.2.2/go.mod h1:hI93XBmqTisBFMUTm0b8Fm+jr3Dg1NNxqwp+5A1VGuI= From d8b9eb611f1ef15eaacfa210599df2ca337ab845 Mon Sep 17 00:00:00 2001 From: Mrs4s Date: Mon, 7 Dec 2020 10:51:30 +0800 Subject: [PATCH 08/13] add stacktrace on panic. --- server/websocket.go | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/server/websocket.go b/server/websocket.go index ebcc657..dddbeec 100644 --- a/server/websocket.go +++ b/server/websocket.go @@ -4,6 +4,7 @@ import ( "context" "fmt" "net/http" + "runtime/debug" "strconv" "strings" "sync" @@ -316,7 +317,7 @@ func (s *websocketServer) listenApi(c *websocketConn) { func (c *websocketConn) handleRequest(bot *coolq.CQBot, payload []byte) { defer func() { if err := recover(); err != nil { - log.Printf("处置WS命令时发生无法恢复的异常:%v", err) + log.Printf("处置WS命令时发生无法恢复的异常:%v\n%s", err, debug.Stack()) c.Close() } }() From 302ae89a756b8a3ecb6523746395fd55f8e82cb4 Mon Sep 17 00:00:00 2001 From: Mrs4s Date: Mon, 7 Dec 2020 10:53:18 +0800 Subject: [PATCH 09/13] fix pprof. --- server/apiAdmin.go | 4 ++++ 1 file changed, 4 insertions(+) diff --git a/server/apiAdmin.go b/server/apiAdmin.go index 96e7e26..15f3e00 100644 --- a/server/apiAdmin.go +++ b/server/apiAdmin.go @@ -318,6 +318,10 @@ func AuthMiddleWare() gin.HandlerFunc { if c.Request.Method == "OPTIONS" { c.AbortWithStatus(http.StatusNoContent) } + if strings.Contains(c.Request.URL.Path, "debug") { + c.Next() + return + } // 处理请求 if c.Request.Method != "GET" && c.Request.Method != "POST" { log.Warnf("已拒绝客户端 %v 的请求: 方法错误", c.Request.RemoteAddr) From e6de0c33cd9163210f273e5c23dba56a0854b6d2 Mon Sep 17 00:00:00 2001 From: Yiwen-Chan Date: Tue, 8 Dec 2020 20:24:48 +0800 Subject: [PATCH 10/13] improve doc --- docs/cqhttp.md | 207 +++++++++++++++++++++++++++++++------------------ 1 file changed, 132 insertions(+), 75 deletions(-) diff --git a/docs/cqhttp.md b/docs/cqhttp.md index 5f51c32..d08eaf8 100644 --- a/docs/cqhttp.md +++ b/docs/cqhttp.md @@ -2,10 +2,64 @@ 由于部分 api 原版 CQHTTP 并未实现,go-cqhttp 修改并增加了一些拓展 api . +
+目录 +

+ +##### CQCode +- [图片](#图片) +- [回复](#回复) +- [红包](#红包) +- [戳一戳](#戳一戳) +- [礼物](#礼物) +- [合并转发](#合并转发) +- [合并转发消息节点](#合并转发消息节点) +- [XML 消息](#XML 消息) +- [JSON 消息](#JSON 消息) +- [cardimage](#cardimage) +- [文本转语音](#文本转语音) +- [图片](#图片) + +##### API +- [设置群名](#设置群名) +- [设置群头像](#设置群头像) +- [获取图片信息](#获取图片信息) +- [获取消息](#获取消息) +- [获取合并转发内容](#获取合并转发内容) +- [发送合并转发(群)](#发送合并转发(群)) +- [获取中文分词](#获取中文分词) +- [图片OCR](#图片OCR) +- [获取中文分词](#获取中文分词) +- [获取群系统消息](#获取群文件系统信息) +- [获取群文件系统信息](#获取群文件系统信息) +- [获取群根目录文件列表](#获取群根目录文件列表) +- [获取群子目录文件列表](#获取群子目录文件列表) +- [获取群文件资源链接](#获取群文件资源链接) +- [获取状态](#获取状态) +- [获取群子目录文件列表](#设置群名) + +##### 事件 +- [群消息撤回](#群消息撤回) +- [好友消息撤回](#好友消息撤回) +- [群内戳一戳](#群内戳一戳) +- [群红包运气王提示](#群红包运气王提示) +- [群成员荣誉变更提示](#群成员荣誉变更提示) +- [群成员名片更新](#群成员名片更新) +- [接收到离线文件](#接收到离线文件) + +

+
+ ## CQCode ### 图片 +Type : `image` + +范围: **发送/接收** + +参数: + | 参数名 | 可能的值 | 说明 | | ------- | --------------- | --------------------------------------------------------------- | | `file` | - | 图片文件名 | @@ -25,6 +79,8 @@ | 40004 | 爱你 | | 40005 | 征友 | +示例: `[CQ:image,file=http://baidu.com/1.jpg,type=show,id=40004]` + ### 回复 @@ -36,7 +92,7 @@ Type : `reply` | 参数名 | 类型 | 说明 | | ------ | ---- | ------------------------------------- | -| id | int | 回复时所引用的消息id, 必须为本群消息. | +| `id` | int | 回复时所引用的消息id, 必须为本群消息. | 示例: `[CQ:reply,id=123456]` @@ -48,9 +104,9 @@ Type: `redbag` 参数: -| 参数名 | 类型 | 说明 | -| ------ | ------ | ----------- | -| title | string | 祝福语/口令 | +| 参数名 | 类型 | 说明 | +| ------- | ------ | ----------- | +| `title` | string | 祝福语/口令 | 示例: `[CQ:redbag,title=恭喜发财]` @@ -66,7 +122,7 @@ Type: `poke` | 参数名 | 类型 | 说明 | | ------ | ----- | ------------ | -| qq | int64 | 需要戳的成员 | +| `qq` | int64 | 需要戳的成员 | 示例: `[CQ:poke,qq=123456]` @@ -82,8 +138,8 @@ Type: `gift` | 参数名 | 类型 | 说明 | | ------ | ----- | -------------- | -| qq | int64 | 接收礼物的成员 | -| id | int | 礼物的类型 | +| `qq` | int64 | 接收礼物的成员 | +| `id` | int | 礼物的类型 | 目前支持的礼物ID: @@ -116,9 +172,9 @@ Type: `forward` 参数: -| 参数名 | 类型 | 说明 | -| ------ | ------ | ------------------------------------------------------------- | -| id | string | 合并转发ID, 需要通过 `/get_forward_msg` API获取转发的具体内容 | +| 参数名 | 类型 | 说明 | +| ------ | ------ | ------------------------------------------------------------ | +| `id` | string | 合并转发ID, 需要通过 `/get_forward_msg` API获取转发的具体内容 | 示例: `[CQ:forward,id=xxxx]` @@ -130,12 +186,12 @@ Type: `node` 参数: -| 参数名 | 类型 | 说明 | 特殊说明 | -| ------- | ------- | -------------- | -------------------------------------------------------------------------------------- | -| id | int32 | 转发消息id | 直接引用他人的消息合并转发, 实际查看顺序为原消息发送顺序 **与下面的自定义消息二选一** | -| name | string | 发送者显示名字 | 用于自定义消息 (自定义消息并合并转发,实际查看顺序为自定义消息段顺序) | -| uin | int64 | 发送者QQ号 | 用于自定义消息 | -| content | message | 具体消息 | 用于自定义消息 **不支持转发套娃,不支持引用回复** | +| 参数名 | 类型 | 说明 | 特殊说明 | +| --------- | ------- | -------------- | ------------------------------------------------------------ | +| `id` | int32 | 转发消息id | 直接引用他人的消息合并转发, 实际查看顺序为原消息发送顺序 **与下面的自定义消息二选一** | +| `name` | string | 发送者显示名字 | 用于自定义消息 (自定义消息并合并转发,实际查看顺序为自定义消息段顺序) | +| `uin` | int64 | 发送者QQ号 | 用于自定义消息 | +| `content` | message | 具体消息 | 用于自定义消息 **不支持转发套娃,不支持引用回复** | 特殊说明: **需要使用单独的API `/send_group_forward_msg` 发送,并且由于消息段较为复杂,仅支持Array形式入参。 如果引用消息和自定义消息同时出现,实际查看顺序将取消息段顺序. 另外按 [CQHTTP](https://cqhttp.cc/docs/4.15/#/Message?id=格式) 文档说明, `data` 应全为字符串, 但由于需要接收`message` 类型的消息, 所以 *仅限此Type的content字段* 支持Array套娃** @@ -209,7 +265,7 @@ Type: `node` ] ```` -### xml支持 +### xml 消息 Type: `xml` @@ -217,10 +273,10 @@ Type: `xml` 参数: -| 参数名 | 类型 | 说明 | -| ------ | ------ | ----------------------------------------- | -| data | string | xml内容,xml中的value部分,记得实体化处理 | -| resid | int32 | 可以不填 | +| 参数名 | 类型 | 说明 | +| ------- | ------ | ----------------------------------------- | +| `data` | string | xml内容,xml中的value部分,记得实体化处理 | +| `resid` | int32 | 可以不填 | 示例: `[CQ:xml,data=xxxx]` @@ -258,7 +314,7 @@ Type: `xml` ``` -### json消息支持 +### JSON 消息 Type: `json` @@ -266,20 +322,20 @@ Type: `json` 参数: -| 参数名 | 类型 | 说明 | -| ------ | ------ | ----------------------------------------------- | -| data | string | json内容,json的所有字符串记得实体化处理 | -| resid | int32 | 默认不填为0,走小程序通道,填了走富文本通道发送 | +| 参数名 | 类型 | 说明 | +| ------- | ------ | ----------------------------------------------- | +| `data` | string | json内容,json的所有字符串记得实体化处理 | +| `resid` | int32 | 默认不填为0,走小程序通道,填了走富文本通道发送 | json中的字符串需要进行转义: ->","=>`,`、 +>","=> `,` ->"&"=> `&`、 +>"&"=> `&` ->"["=>`[`、 +>"["=> `[` ->"]"=>`]`、 +>"]"=> `]` 否则无法正确得到解析 @@ -289,7 +345,8 @@ json中的字符串需要进行转义: ``` -### cardimage 一种xml的图片消息(装逼大图) +### cardimage +一种xml的图片消息(装逼大图) ps: xml 接口的消息都存在风控风险,请自行兼容发送失败后的处理(可以失败后走普通图片模式) @@ -299,15 +356,15 @@ Type: `cardimage` 参数: -| 参数名 | 类型 | 说明 | -| --------- | ------ | ------------------------------------- | -| file | string | 和image的file字段对齐,支持也是一样的 | -| minwidth | int64 | 默认不填为400,最小width | -| minheight | int64 | 默认不填为400,最小height | -| maxwidth | int64 | 默认不填为500,最大width | -| maxheight | int64 | 默认不填为1000,最大height | -| source | string | 分享来源的名称,可以留空 | -| icon | string | 分享来源的icon图标url,可以留空 | +| 参数名 | 类型 | 说明 | +| ----------- | ------ | ------------------------------------- | +| `file` | string | 和image的file字段对齐,支持也是一样的 | +| `minwidth` | int64 | 默认不填为400,最小width | +| `minheight` | int64 | 默认不填为400,最小height | +| `maxwidth` | int64 | 默认不填为500,最大width | +| `maxheight` | int64 | 默认不填为1000,最大height | +| `source` | string | 分享来源的名称,可以留空 | +| `icon` | string | 分享来源的icon图标url,可以留空 | 示例cardimage 的cq码: @@ -327,7 +384,7 @@ Type: `tts` | 参数名 | 类型 | 说明 | | ------ | ------ | ---- | -| text | string | 内容 | +| `text` | string | 内容 | 示例: `[CQ:tts,text=这是一条测试消息]` @@ -339,10 +396,10 @@ Type: `tts` **参数** -| 字段 | 类型 | 说明 | -| ---------- | ------ | ---- | -| group_id | int64 | 群号 | -| group_name | string | 新名 | +| 字段 | 类型 | 说明 | +| ------------ | ------ | ---- | +| `group_id` | int64 | 群号 | +| `group_name` | string | 新名 | ### 设置群头像 @@ -350,11 +407,11 @@ Type: `tts` **参数** -| 字段 | 类型 | 说明 | -| -------- | ------ | ------------------------ | -| group_id | int64 | 群号 | -| file | string | 图片文件名 | -| cache | int | 表示是否使用已缓存的文件 | +| 字段 | 类型 | 说明 | +| ---------- | ------ | ------------------------ | +| `group_id` | int64 | 群号 | +| `file` | string | 图片文件名 | +| `cache` | int | 表示是否使用已缓存的文件 | [1]`file` 参数支持以下几种格式: @@ -654,34 +711,34 @@ Type: `tts` **响应数据** -| 字段 | 类型 | 说明 | -| --------------- | ---------- | ------------------------------- | -| app_initialized | bool | 原 `CQHTTP` 字段, 恒定为 `true` | -| app_enabled | bool | 原 `CQHTTP` 字段, 恒定为 `true` | -| plugins_good | bool | 原 `CQHTTP` 字段, 恒定为 `true` | -| app_good | bool | 原 `CQHTTP` 字段, 恒定为 `true` | -| online | bool | 表示BOT是否在线 | -| goold | bool | 同 `online` | -| stat | Statistics | 运行统计 | +| 字段 | 类型 | 说明 | +| ----------------- | ---------- | ------------------------------- | +| `app_initialized` | bool | 原 `CQHTTP` 字段, 恒定为 `true` | +| `app_enabled` | bool | 原 `CQHTTP` 字段, 恒定为 `true` | +| `plugins_good` | bool | 原 `CQHTTP` 字段, 恒定为 `true` | +| `app_good` | bool | 原 `CQHTTP` 字段, 恒定为 `true` | +| `online` | bool | 表示BOT是否在线 | +| `goold` | bool | 同 `online` | +| `stat` | Statistics | 运行统计 | **Statistics** -| 字段 | 类型 | 说明 | -| ---------------- | ------ | ---------------- | -| packet_received | uint64 | 收到的数据包总数 | -| packet_sent | uint64 | 发送的数据包总数 | -| packet_lost | uint32 | 数据包丢失总数 | -| message_received | uint64 | 接受信息总数 | -| message_sent | uint64 | 发送信息总数 | -| disconnect_times | uint32 | TCP链接断开次数 | -| lost_times | uint32 | 账号掉线次数 | +| 字段 | 类型 | 说明 | +| ------------------ | ------ | ---------------- | +| `packet_received` | uint64 | 收到的数据包总数 | +| `packet_sent` | uint64 | 发送的数据包总数 | +| `packet_lost` | uint32 | 数据包丢失总数 | +| `message_received` | uint64 | 接受信息总数 | +| `message_sent` | uint64 | 发送信息总数 | +| `disconnect_times` | uint32 | TCP链接断开次数 | +| `lost_times` | uint32 | 账号掉线次数 | > 注意: 所有统计信息都将在重启后重制 ## 事件 -#### 群消息撤回 +### 群消息撤回 **上报数据** @@ -694,7 +751,7 @@ Type: `tts` | `operator_id` | int64 | | 操作者id | | `message_id` | int64 | | 被撤回的消息id | -#### 好友消息撤回 +### 好友消息撤回 **上报数据** @@ -705,7 +762,7 @@ Type: `tts` | `user_id` | int64 | | 好友id | | `message_id` | int64 | | 被撤回的消息id | -#### 群内戳一戳 +### 群内戳一戳 > 注意:此事件无法在平板和手表协议上触发 @@ -720,7 +777,7 @@ Type: `tts` | `user_id` | int64 | | 发送者id | | `target_id` | int64 | | 被戳者id | -#### 群红包运气王提示 +### 群红包运气王提示 > 注意:此事件无法在平板和手表协议上触发 @@ -735,7 +792,7 @@ Type: `tts` | `user_id` | int64 | | 红包发送者id | | `target_id` | int64 | | 运气王id | -#### 群成员荣誉变更提示 +### 群成员荣誉变更提示 > 注意:此事件无法在平板和手表协议上触发 @@ -750,7 +807,7 @@ Type: `tts` | `user_id` | int64 | | 成员id | | `honor_type` | string | `talkative:龙王` `performer:群聊之火` `emotion:快乐源泉` | 荣誉类型 | -#### 群成员名片更新 +### 群成员名片更新 > 注意: 此事件不保证时效性,仅在收到消息时校验卡片 @@ -767,7 +824,7 @@ Type: `tts` > PS: 当名片为空时 `card_xx` 字段为空字符串, 并不是昵称 -#### 接收到离线文件 +### 接收到离线文件 **上报数据** From 26372c0939ef885e74978b8a3447c9d25ff38f1d Mon Sep 17 00:00:00 2001 From: Kanri Date: Tue, 8 Dec 2020 20:28:10 +0800 Subject: [PATCH 11/13] improve doc --- docs/cqhttp.md | 8 ++++---- 1 file changed, 4 insertions(+), 4 deletions(-) diff --git a/docs/cqhttp.md b/docs/cqhttp.md index d08eaf8..9243b4f 100644 --- a/docs/cqhttp.md +++ b/docs/cqhttp.md @@ -14,8 +14,8 @@ - [礼物](#礼物) - [合并转发](#合并转发) - [合并转发消息节点](#合并转发消息节点) -- [XML 消息](#XML 消息) -- [JSON 消息](#JSON 消息) +- [XML 消息](#xml-消息) +- [JSON 消息](#json-消息) - [cardimage](#cardimage) - [文本转语音](#文本转语音) - [图片](#图片) @@ -265,7 +265,7 @@ Type: `node` ] ```` -### xml 消息 +### XML 消息 Type: `xml` @@ -841,4 +841,4 @@ Type: `tts` | ------ | ------ | -------- | -------- | | `name` | string | | 文件名 | | `size` | int64 | | 文件大小 | -| `url` | string | | 下载链接 | \ No newline at end of file +| `url` | string | | 下载链接 | From 950011b6947434640e0e96c7f69fbef234aec5fa Mon Sep 17 00:00:00 2001 From: wdvxdr Date: Tue, 8 Dec 2020 22:12:58 +0800 Subject: [PATCH 12/13] update docs --- docs/EventFilter.md | 14 ++++++++++++-- 1 file changed, 12 insertions(+), 2 deletions(-) diff --git a/docs/EventFilter.md b/docs/EventFilter.md index 2eb5f38..7f23406 100644 --- a/docs/EventFilter.md +++ b/docs/EventFilter.md @@ -1,12 +1,22 @@ # 事件过滤器 -在go-cqhttp同级目录下新建`filter.json`文件即可开启事件过滤器,启动时会读取该文件中定义的过滤规则(使用 JSON 编写),若文件不存在,或过滤规则语法错误,则会暂停所有上报。 +在go-cqhttp同级目录下新建`filter.json`文件即可开启事件过滤器,启动时会读取该文件中定义的过滤规则(使用 JSON 编写),若文件不存在,或过滤规则语法错误,则不会启用事件过滤器。 事件过滤器会处理所有事件(包括心跳事件在内的元事件),请谨慎使用!! +注意: 与客户端建立连接的握手事件**不会**经过事件过滤器 + ## 示例 这节首先给出一些示例,演示过滤器的基本用法,下一节将给出具体语法说明。 +### 过滤所有事件 + +```json +{ + ".not": {} +} +``` + ### 只上报以「!!」开头的消息 ```json @@ -128,5 +138,5 @@ 这里有几点需要注意: -- `message` 字段在运行过滤器时是消息段数组的形式(见 [消息格式]( https://github.com/howmanybots/onebot/blob/master/v11/specs/message/array.md )) +- `message` 字段在运行过滤器时和上报信息类型相同(见 [消息格式]( https://github.com/howmanybots/onebot/blob/master/v11/specs/message/array.md )) - `raw_message` 字段为未经**CQ码**处理的原始消息字符串,这意味着其中可能会出现形如 `[CQ:face,id=123]` 的 CQ 码 From e694e8b4824d5a100b86d14c1574fd312f877ba7 Mon Sep 17 00:00:00 2001 From: Mrs4s Date: Wed, 9 Dec 2020 14:24:39 +0800 Subject: [PATCH 13/13] support event recover. --- coolq/bot.go | 6 ++++++ 1 file changed, 6 insertions(+) diff --git a/coolq/bot.go b/coolq/bot.go index 4a10ffa..6277201 100644 --- a/coolq/bot.go +++ b/coolq/bot.go @@ -6,6 +6,7 @@ import ( "fmt" "hash/crc32" "path" + "runtime/debug" "sync" "time" @@ -397,6 +398,11 @@ func (bot *CQBot) dispatchEventMessage(m MSG) { } for _, f := range bot.events { go func(fn func(MSG)) { + defer func() { + if pan := recover(); pan != nil { + log.Warnf("处理事件 %v 时出现错误: %v \n%s", m, pan, debug.Stack()) + } + }() start := time.Now() fn(m) end := time.Now()