message

package
v1.2.3 Latest Latest
Warning

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

Go to latest
Published: Sep 14, 2024 License: GPL-3.0 Imports: 16 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

View Source
var Emoji = map[int]rune{
	0:   128558,
	1:   128556,
	2:   128525,
	4:   128526,
	5:   128557,
	6:   129402,
	7:   129296,
	8:   128554,
	9:   128557,
	10:  128517,
	11:  128545,
	12:  128539,
	13:  128513,
	14:  128578,
	15:  128577,
	16:  128526,
	19:  129326,
	20:  129325,
	21:  128522,
	23:  128533,
	24:  128523,
	25:  129393,
	26:  128561,
	27:  128531,
	28:  128516,
	29:  128524,
	30:  128170,
	31:  129324,
	32:  129300,
	33:  129323,
	34:  128565,
	35:  128547,
	37:  128128,
	38:  128296,
	39:  128075,
	41:  129398,
	42:  128147,
	46:  128055,
	49:  129303,
	53:  127874,
	59:  128169,
	60:  9749,
	63:  127801,
	66:  10084,
	67:  128148,
	69:  127873,
	74:  127774,
	75:  127772,
	76:  128077,
	78:  129309,
	79:  9996,
	85:  128536,
	89:  127817,
	96:  128517,
	99:  128079,
	104: 129393,
	106: 129401,
	109: 128535,
	110: 128562,
	111: 129402,
	116: 128536,
	120: 128074,
	122: 128536,
	123: 10060,
	124: 128076,
	129: 128587,
	144: 128079,
	147: 127853,
	171: 127861,
	172: 128539,
	173: 128557,
	174: 128558,
	175: 128539,
	182: 128514,
	187: 128123,
	201: 128077,
	214: 128536,
	222: 129303,
	227: 128079,
	247: 128567,
	264: 129318,
	272: 128579,
	320: 129395,
	325: 128561,
}

Functions

func CleanExpiredCQMessages added in v1.2.1

func CleanExpiredCQMessages()

CleanExpiredCQMessages 定期清理过期的 CQ 消息

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 ExtractCQMessages added in v1.2.1

func ExtractCQMessages(message string) (string, []string, error)

ExtractCQMessages 替换CQ消息为占位符,方便进行其他操作

func RestoreCQMessages added in v1.2.1

func RestoreCQMessages(cleanedMessage string, placeholders []string) string

RestoreCQMessages 通过占位符还原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

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

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

func (m Message) String() string

String impls the interface fmt.Stringer

type MessageID

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

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

func NewMessageIDFromInteger

func NewMessageIDFromInteger(raw int64) (m MessageID)

func NewMessageIDFromString

func NewMessageIDFromString(raw string) (m MessageID)

func (MessageID) ID

func (m MessageID) ID() int64

func (MessageID) MarshalJSON

func (m MessageID) MarshalJSON() ([]byte, error)

func (MessageID) String

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 Image

func Image(file string, summary ...interface{}) MessageSegment

Image 普通图片

https://github.com/botuniverse/onebot-11/tree/master/message/segment.md#%E5%9B%BE%E7%89%87

https://llonebot.github.io/zh-CN/develop/extends_api

summary: LLOneBot的扩展字段:图片预览文字

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码 与 String 不同之处在于,对于 base64 的图片消息会将其哈希 方便 log 打印,不可用作发送

func (MessageSegment) Chain

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

Chain 将两个 Data 合并

func (MessageSegment) String

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