1
0
mirror of https://github.com/Mrs4s/go-cqhttp.git synced 2025-05-04 19:17:37 +08:00

coolq: make linter happy

This commit is contained in:
wdvxdr 2022-05-25 15:31:26 +08:00
parent 296668441f
commit 7dbda5cec7
No known key found for this signature in database
GPG Key ID: 703F8C071DE7A1B6
2 changed files with 6 additions and 0 deletions

View File

@ -93,6 +93,8 @@ func replyID(r *message.ReplyElement, source message.Source) int32 {
}
// toElements 将消息元素数组转为MSG数组以用于消息上报
//
// nolint:govet
func toElements(e []message.IMessageElement, source message.Source, raw bool) (r []cqcode.Element) {
type pair = cqcode.Pair // simplify code
type pairs = []pair

View File

@ -7,16 +7,19 @@ import (
"github.com/Mrs4s/go-cqhttp/global"
)
// Element single message
type Element struct {
Type string
Data []Pair
}
// Pair key value pair
type Pair struct {
K string
V string
}
// CQCode convert to cqcode
func (e *Element) CQCode() string {
if e.Type == "text" {
return EscapeText(e.Data[0].V) // must be {"text": value}
@ -34,6 +37,7 @@ func (e *Element) CQCode() string {
return sb.String()
}
// MarshalJSON see encoding/json.Marshaler
func (e *Element) MarshalJSON() ([]byte, error) {
buf := global.NewBuffer()
defer global.PutBuffer(buf)