Documentation ¶
Overview ¶
Package message @Description: 用于message转换和封装的一个包
Index ¶
- func BytesToString(b []byte) string
- func EscapeCQCodeText(str string) string
- func EscapeCQText(str string) string
- func StringToBytes(s string) (b []byte)
- func UnescapeCQCodeText(str string) string
- func UnescapeCQText(str string) string
- type Message
- type MessageSegment
- func At(qq int64) MessageSegment
- func CustomMusic(url, audio, title string) MessageSegment
- func CustomNode(nickname string, userID int64, content interface{}) MessageSegment
- func Face(id int) MessageSegment
- func Forward(id string) MessageSegment
- func Gift(userID string, giftID string) MessageSegmentdeprecated
- func Image(file string) MessageSegment
- func ImageC(file interface{}) MessageSegment
- func JSON(data string) MessageSegment
- func Music(mType string, id int64) MessageSegment
- func Node(id int64) MessageSegment
- func Poke(userID int64) MessageSegment
- func Record(file string) MessageSegment
- func Reply(id int64) MessageSegment
- func TTS(text string) MessageSegment
- func Text(text ...interface{}) MessageSegment
- func XML(data string) MessageSegment
Constants ¶
This section is empty.
Variables ¶
This section is empty.
Functions ¶
func EscapeCQCodeText ¶
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 UnescapeCQCodeText ¶
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 ¶
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 ¶
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 ¶
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 ¶
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 ¶
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 ¶
CQString returns the CQEncoded string. All media in the message will be converted to its CQCode. CQString 解码cq字符串
func (Message) ExtractPlainText ¶
ExtractPlainText 提取消息中的纯文本
type MessageSegment ¶
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 At ¶
func At(qq int64) MessageSegment
At @某人 https://github.com/howmanybots/onebot/blob/master/v11/specs/message/segment.md#%E6%9F%90%E4%BA%BA
func CustomMusic ¶
func CustomMusic(url, audio, title string) MessageSegment
CustomMusic 音乐自定义分享 https://github.com/howmanybots/onebot/blob/master/v11/specs/message/segment.md#%E9%9F%B3%E4%B9%90%E8%87%AA%E5%AE%9A%E4%B9%89%E5%88%86%E4%BA%AB-
func CustomNode ¶
func CustomNode(nickname string, userID int64, content interface{}) MessageSegment
CustomNode 自定义合并转发节点 https://github.com/howmanybots/onebot/blob/master/v11/specs/message/segment.md#%E5%90%88%E5%B9%B6%E8%BD%AC%E5%8F%91%E8%87%AA%E5%AE%9A%E4%B9%89%E8%8A%82%E7%82%B9
func Face ¶
func Face(id int) MessageSegment
Face QQ表情 https://github.com/howmanybots/onebot/blob/master/v11/specs/message/segment.md#qq-%E8%A1%A8%E6%83%85
func Forward ¶
func Forward(id string) MessageSegment
Forward 合并转发 https://github.com/howmanybots/onebot/blob/master/v11/specs/message/segment.md#%E5%90%88%E5%B9%B6%E8%BD%AC%E5%8F%91-
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) MessageSegment
Image 普通图片 https://github.com/howmanybots/onebot/blob/master/v11/specs/message/segment.md#%E5%9B%BE%E7%89%87
func ImageC ¶ added in v1.1.4
func ImageC(file interface{}) MessageSegment
ImageC 普通图片 https://github.com/howmanybots/onebot/blob/master/v11/specs/message/segment.md#%E5%9B%BE%E7%89%87
func JSON ¶
func JSON(data string) MessageSegment
func Music ¶
func Music(mType string, id int64) MessageSegment
func Node ¶
func Node(id int64) MessageSegment
func Poke ¶
func Poke(userID int64) MessageSegment
Poke 戳一戳 https://github.com/Mrs4s/go-cqhttp/blob/master/docs/cqhttp.md#%E6%88%B3%E4%B8%80%E6%88%B3
func Record ¶
func Record(file string) MessageSegment
Record 语音 https://github.com/howmanybots/onebot/blob/master/v11/specs/message/segment.md#%E8%AF%AD%E9%9F%B3
func Reply ¶
func Reply(id int64) MessageSegment
Reply 回复 https://github.com/howmanybots/onebot/blob/master/v11/specs/message/segment.md#%E5%9B%9E%E5%A4%8D
func TTS ¶
func TTS(text string) MessageSegment
func Text ¶
func Text(text ...interface{}) MessageSegment
func XML ¶
func XML(data string) MessageSegment
func (MessageSegment) Add ¶
func (m MessageSegment) Add(key string, val interface{}) MessageSegment
Add 为 MessageSegment 的 Data 增加一个字段
func (MessageSegment) Delete ¶
func (m MessageSegment) Delete(key string) MessageSegment