message

package
v1.1.9 Latest Latest
Warning

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

Go to latest
Published: Jul 3, 2022 License: AGPL-3.0 Imports: 8 Imported by: 3

Documentation

Overview

Package message @Description: 用于message转换和封装的一个包

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func BytesToString

func BytesToString(b []byte) string

BytesToString 没有内存开销的转换

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 StringToBytes

func StringToBytes(s string) (b []byte)

StringToBytes 没有内存开销的转换

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 ParseMessageFromStringWithUnsafe

func ParseMessageFromStringWithUnsafe(s string) Message

ParseMessageFromStringWithUnsafe 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 returns the CQEncoded string. All media in the message will be converted to its CQCode. CQString 解码cq字符串

func (Message) ExtractPlainText

func (m Message) ExtractPlainText() string

ExtractPlainText 提取消息中的纯文本

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

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

Add 为 MessageSegment 的 Data 增加一个字段

func (MessageSegment) CQCode

func (m MessageSegment) CQCode() string

CQCode 将数组消息转换为CQ码

func (MessageSegment) Delete

func (m MessageSegment) Delete(key string) MessageSegment

Jump to

Keyboard shortcuts

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