1
0
mirror of https://github.com/Mrs4s/go-cqhttp.git synced 2025-05-05 03:23:49 +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数组以用于消息上报 // toElements 将消息元素数组转为MSG数组以用于消息上报
//
// nolint:govet
func toElements(e []message.IMessageElement, source message.Source, raw bool) (r []cqcode.Element) { func toElements(e []message.IMessageElement, source message.Source, raw bool) (r []cqcode.Element) {
type pair = cqcode.Pair // simplify code type pair = cqcode.Pair // simplify code
type pairs = []pair type pairs = []pair

View File

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