message

package
v1.3.1 Latest Latest
Warning

This package is not in the latest version of its module.

Go to latest
Published: Oct 16, 2021 License: GPL-3.0 Imports: 6 Imported by: 521

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func EscapeCQCodeText

func EscapeCQCodeText(str string) string

EscapeCQCodeText escapes special characters in a cqcode value.

https://github.com/howmanybots/onebot/blob/master/v11/specs/message/string.md#%E8%BD%AC%E4%B9%89

cq码字符转换

func EscapeCQText

func EscapeCQText(str string) string

EscapeCQText escapes special characters in a non-media plain message.\

CQ码字符转换

func UnescapeCQCodeText

func UnescapeCQCodeText(str string) string

UnescapeCQCodeText unescapes special characters in a cqcode value. https://github.com/howmanybots/onebot/blob/master/v11/specs/message/string.md#%E8%BD%AC%E4%B9%89

cq码反解析

func UnescapeCQText

func UnescapeCQText(str string) string

UnescapeCQText unescapes special characters in a non-media plain message.

CQ码反解析

Types

type Message

type Message []MessageSegment

Message impl the array form of message https://github.com/howmanybots/onebot/blob/master/v11/specs/message/array.md#%E6%95%B0%E7%BB%84%E6%A0%BC%E5%BC%8F

func ParseMessage

func ParseMessage(msg []byte) Message

ParseMessage parses msg, which might have 2 types, string or array, depending on the configuration of cqhttp, to a Message. msg is the value of key "message" of the data unmarshalled from the API response JSON.

func ParseMessageFromArray

func ParseMessageFromArray(msgs gjson.Result) Message

ParseMessageFromArray parses msg as type array to a Message. msg is the value of key "message" of the data unmarshalled from the API response JSON. ParseMessageFromArray cq字符串转化为json对象

func ParseMessageFromString

func ParseMessageFromString(raw string) (m Message)

ParseMessageFromString parses msg as type string to a sort of MessageSegment. msg is the value of key "message" of the data unmarshalled from the API response JSON.

CQ字符串转为消息

func ReplyWithMessage

func ReplyWithMessage(messageID int64, m ...MessageSegment) Message

ReplyWithMessage returns a reply message

func (Message) CQString

func (m Message) CQString() string

CQString 转为CQ字符串 Deprecated: use method String instead

func (Message) ExtractPlainText

func (m Message) ExtractPlainText() string

ExtractPlainText 提取消息中的纯文本

func (Message) String added in v1.2.1

func (m Message) String() string

String impls the interface fmt.Stringer

type MessageSegment

type MessageSegment struct {
	Type string            `json:"type"`
	Data map[string]string `json:"data"`
}

MessageSegment impl the single message MessageSegment 消息数组 https://github.com/howmanybots/onebot/blob/master/v11/specs/message/array.md#%E6%95%B0%E7%BB%84%E6%A0%BC%E5%BC%8F

func Gift deprecated

func Gift(userID string, giftID string) MessageSegment

Gift 群礼物 https://github.com/Mrs4s/go-cqhttp/blob/master/docs/cqhttp.md#%E7%A4%BC%E7%89%A9

Deprecated: 群礼物改版

func (MessageSegment) Add added in v1.1.0

func (m MessageSegment) Add(key string, val interface{}) MessageSegment

Add 为 MessageSegment 的 Data 增加一个字段

func (MessageSegment) CQCode

func (m MessageSegment) CQCode() string

CQCode 将数组消息转换为CQ码 Deprecated: use String instead.

func (MessageSegment) Chain added in v1.2.1

func (m MessageSegment) Chain(data map[string]string) MessageSegment

Chain 将两个 Data 合并

func (MessageSegment) String added in v1.2.1

func (m MessageSegment) String() string

String impls the interface fmt.Stringer

Jump to

Keyboard shortcuts

? : This menu
/ : Search site
f or F : Jump to
y or Y : Canonical URL