message

package
v1.7.4 Latest Latest
Warning

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

Go to latest
Published: Jul 28, 2023 License: GPL-3.0 Imports: 10 Imported by: 447

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/botuniverse/onebot-11/tree/master/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/botuniverse/onebot-11/tree/master/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 CQCoder added in v1.6.0

type CQCoder interface {
	CQCode() string
}

CQCoder 用于 log 打印 CQ 码

type Message

type Message []MessageSegment

Message impl the array form of message https://github.com/botuniverse/onebot-11/tree/master/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 interface{}, m ...MessageSegment) Message

ReplyWithMessage returns a reply message

func (Message) CQCode added in v1.6.0

func (m Message) CQCode() string

CQCode 将数组消息转换为CQ码 与 String 不同之处在于,对于 base64 的图片消息会将其哈希 方便 log 打印,不可用作发送

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 MessageID added in v1.5.0

type MessageID struct {
	// contains filtered or unexported fields
}

MessageID 对于 qq 消息, i 与 s 相同 对于 guild 消息, i 为 s 的 ISO crc64

func NewMessageIDFromInteger added in v1.5.0

func NewMessageIDFromInteger(raw int64) (m MessageID)

func NewMessageIDFromString added in v1.5.0

func NewMessageIDFromString(raw string) (m MessageID)

func (MessageID) ID added in v1.5.0

func (m MessageID) ID() int64

func (MessageID) String added in v1.5.0

func (m MessageID) String() string

type MessageSegment

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

MessageSegment impl the single message MessageSegment 消息数组 https://github.com/botuniverse/onebot-11/tree/master/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码 与 String 不同之处在于,对于 base64 的图片消息会将其哈希 方便 log 打印,不可用作发送

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