Documentation ¶
Index ¶
- Variables
- func RegsiterParserElement(parser MessageElementParser)
- func Stringify(elements []MessageElement) (string, error)
- type ChildrenMessageElement
- type ExtendAttributes
- type Message
- type MessageBidiList
- type MessageElement
- type MessageElementA
- type MessageElementAt
- type MessageElementAudio
- type MessageElementAuthor
- type MessageElementButton
- type MessageElementCode
- type MessageElementDel
- type MessageElementEm
- type MessageElementExtend
- type MessageElementFile
- type MessageElementImg
- type MessageElementIns
- type MessageElementMessage
- type MessageElementParser
- type MessageElementQuote
- type MessageElementSharp
- type MessageElementSpl
- type MessageElementStrong
- type MessageElementSub
- type MessageElementSup
- type MessageElementText
- type MessageElementVideo
- type MessageElmentBr
- type MessageElmentP
- type Token
Constants ¶
This section is empty.
Variables ¶
View Source
var ExtendParser = &MessageElementExtend{}
Functions ¶
func RegsiterParserElement ¶
func RegsiterParserElement(parser MessageElementParser)
func Stringify ¶
func Stringify(elements []MessageElement) (string, error)
Types ¶
type ChildrenMessageElement ¶ added in v0.0.7
type ChildrenMessageElement struct {
// contains filtered or unexported fields
}
func (*ChildrenMessageElement) GetChildren ¶ added in v0.0.12
func (e *ChildrenMessageElement) GetChildren() []MessageElement
func (*ChildrenMessageElement) SetChildren ¶ added in v0.0.15
func (e *ChildrenMessageElement) SetChildren(children []MessageElement) *ChildrenMessageElement
type ExtendAttributes ¶ added in v0.0.8
type ExtendAttributes struct {
// contains filtered or unexported fields
}
func (*ExtendAttributes) AddAttribute ¶ added in v0.0.8
func (e *ExtendAttributes) AddAttribute(key, value string) *ExtendAttributes
func (*ExtendAttributes) DelAttribute ¶ added in v0.0.15
func (e *ExtendAttributes) DelAttribute(key string) *ExtendAttributes
type Message ¶
type Message struct { Id string `json:"id"` // 消息 ID Content string `json:"content"` // 消息内容 Channel *channel.Channel `json:"channel,omitempty"` // 频道对象 Guild *guild.Guild `json:"guild,omitempty"` // 群组对象 Member *guildmember.GuildMember `json:"member,omitempty"` // 群组成员对象 User *user.User `json:"user,omitempty"` // 用户对象 CreateAt int64 `json:"create_at,omitempty"` // 消息发送的时间戳 UpdateAt int64 `json:"update_at,omitempty"` // 消息修改的时间戳 }
消息
func (*Message) Decode ¶
func (m *Message) Decode(elements []MessageElement) error
func (*Message) Encode ¶
func (m *Message) Encode() ([]MessageElement, error)
type MessageBidiList ¶ added in v0.0.11
type MessageBidiList struct { Data []*Message `json:"data"` // 数据 Prev string `json:"prev,omitempty"` // 上一页的令牌 Next string `json:"next,omitempty"` // 下一页的令牌 }
Message 双向分页列表
type MessageElement ¶
type MessageElement interface { Tag() string Stringify() string Alias() []string GetChildren() []MessageElement }
func Parse ¶
func Parse(source string) ([]MessageElement, error)
func Select ¶ added in v0.0.13
func Select(element MessageElement, tag string) []MessageElement
Select 选取特定的消息元素
type MessageElementA ¶
type MessageElementA struct { *ChildrenMessageElement *ExtendAttributes Href string // 收发 链接的 URL // contains filtered or unexported fields }
func (*MessageElementA) Parse ¶
func (e *MessageElementA) Parse(n *html.Node) (MessageElement, error)
func (*MessageElementA) Stringify ¶
func (e *MessageElementA) Stringify() string
func (*MessageElementA) Tag ¶
func (e *MessageElementA) Tag() string
type MessageElementAt ¶
type MessageElementAt struct { *ChildrenMessageElement *ExtendAttributes Id string // 收发 目标用户的 ID Name string // 收发 目标用户的名称 Role string // 收发 目标角色 Type string // 收发 特殊操作,例如 all 表示 @全体成员,here 表示 @在线成员 // contains filtered or unexported fields }
func (*MessageElementAt) Parse ¶
func (e *MessageElementAt) Parse(n *html.Node) (MessageElement, error)
func (*MessageElementAt) Stringify ¶
func (e *MessageElementAt) Stringify() string
func (*MessageElementAt) Tag ¶
func (e *MessageElementAt) Tag() string
type MessageElementAudio ¶
type MessageElementAudio struct { *ChildrenMessageElement *ExtendAttributes Src string // 收发 资源的 URL Title string // 收发 资源文件名称 Cache bool // 发 是否使用已缓存的文件 Timeout string // 发 下载文件的最长时间 (毫秒) Duration uint32 // 收 音频长度 (秒) Poster string // 收发 音频封面 URL // contains filtered or unexported fields }
func (*MessageElementAudio) Parse ¶
func (e *MessageElementAudio) Parse(n *html.Node) (MessageElement, error)
func (*MessageElementAudio) Stringify ¶
func (e *MessageElementAudio) Stringify() string
func (*MessageElementAudio) Tag ¶
func (e *MessageElementAudio) Tag() string
type MessageElementAuthor ¶
type MessageElementAuthor struct { *ChildrenMessageElement *ExtendAttributes Id string // 发 用户 ID Name string // 发 昵称 Avatar string // 发 头像 URL // contains filtered or unexported fields }
func (*MessageElementAuthor) Parse ¶
func (e *MessageElementAuthor) Parse(n *html.Node) (MessageElement, error)
func (*MessageElementAuthor) Stringify ¶
func (e *MessageElementAuthor) Stringify() string
func (*MessageElementAuthor) Tag ¶
func (e *MessageElementAuthor) Tag() string
type MessageElementButton ¶
type MessageElementButton struct { *ChildrenMessageElement *ExtendAttributes Id string // 发 按钮的 ID Type string // 发 按钮的类型 Href string // 发 按钮的链接 Text string // 发 待输入文本 Theme string // 发 按钮的样式 // contains filtered or unexported fields }
func (*MessageElementButton) Parse ¶
func (e *MessageElementButton) Parse(n *html.Node) (MessageElement, error)
func (*MessageElementButton) Stringify ¶
func (e *MessageElementButton) Stringify() string
func (*MessageElementButton) Tag ¶
func (e *MessageElementButton) Tag() string
type MessageElementCode ¶
type MessageElementCode struct { *ChildrenMessageElement *ExtendAttributes // contains filtered or unexported fields }
func (*MessageElementCode) Parse ¶
func (e *MessageElementCode) Parse(n *html.Node) (MessageElement, error)
func (*MessageElementCode) Stringify ¶
func (e *MessageElementCode) Stringify() string
func (*MessageElementCode) Tag ¶
func (e *MessageElementCode) Tag() string
type MessageElementDel ¶
type MessageElementDel struct { *ChildrenMessageElement *ExtendAttributes }
func (*MessageElementDel) Alias ¶
func (e *MessageElementDel) Alias() []string
func (*MessageElementDel) Parse ¶
func (e *MessageElementDel) Parse(n *html.Node) (MessageElement, error)
func (*MessageElementDel) Stringify ¶
func (e *MessageElementDel) Stringify() string
func (*MessageElementDel) Tag ¶
func (e *MessageElementDel) Tag() string
type MessageElementEm ¶
type MessageElementEm struct { *ChildrenMessageElement *ExtendAttributes }
func (*MessageElementEm) Alias ¶
func (e *MessageElementEm) Alias() []string
func (*MessageElementEm) Parse ¶
func (e *MessageElementEm) Parse(n *html.Node) (MessageElement, error)
func (*MessageElementEm) Stringify ¶
func (e *MessageElementEm) Stringify() string
func (*MessageElementEm) Tag ¶
func (e *MessageElementEm) Tag() string
type MessageElementExtend ¶ added in v0.0.8
type MessageElementExtend struct { *ChildrenMessageElement *ExtendAttributes // contains filtered or unexported fields }
func NewMessageElementExtend ¶ added in v0.0.14
func NewMessageElementExtend(tag string, attrs map[string]string, children ...MessageElement) *MessageElementExtend
func (*MessageElementExtend) Parse ¶ added in v0.0.8
func (e *MessageElementExtend) Parse(n *html.Node) (MessageElement, error)
func (*MessageElementExtend) Stringify ¶ added in v0.0.8
func (e *MessageElementExtend) Stringify() string
func (*MessageElementExtend) Tag ¶ added in v0.0.8
func (e *MessageElementExtend) Tag() string
type MessageElementFile ¶
type MessageElementFile struct { *ChildrenMessageElement *ExtendAttributes Src string // 收发 资源的 URL Title string // 收发 资源文件名称 Cache bool // 发 是否使用已缓存的文件 Timeout string // 发 下载文件的最长时间 (毫秒) Poster string // 收发 缩略图 URL // contains filtered or unexported fields }
func (*MessageElementFile) Parse ¶
func (e *MessageElementFile) Parse(n *html.Node) (MessageElement, error)
func (*MessageElementFile) Stringify ¶
func (e *MessageElementFile) Stringify() string
func (*MessageElementFile) Tag ¶
func (e *MessageElementFile) Tag() string
type MessageElementImg ¶
type MessageElementImg struct { *ChildrenMessageElement *ExtendAttributes Src string // 收发 资源的 URL Title string // 收发 资源文件名称 Cache bool // 发 是否使用已缓存的文件 Timeout string // 发 下载文件的最长时间 (毫秒) Width uint32 // 收 图片宽度 (像素) Height uint32 // 收 图片高度 (像素) // contains filtered or unexported fields }
func (*MessageElementImg) Parse ¶
func (e *MessageElementImg) Parse(n *html.Node) (MessageElement, error)
func (*MessageElementImg) Stringify ¶
func (e *MessageElementImg) Stringify() string
func (*MessageElementImg) Tag ¶
func (e *MessageElementImg) Tag() string
type MessageElementIns ¶
type MessageElementIns struct { *ChildrenMessageElement *ExtendAttributes }
func (*MessageElementIns) Alias ¶
func (e *MessageElementIns) Alias() []string
func (*MessageElementIns) Parse ¶
func (e *MessageElementIns) Parse(n *html.Node) (MessageElement, error)
func (*MessageElementIns) Stringify ¶
func (e *MessageElementIns) Stringify() string
func (*MessageElementIns) Tag ¶
func (e *MessageElementIns) Tag() string
type MessageElementMessage ¶
type MessageElementMessage struct { *ChildrenMessageElement *ExtendAttributes Id string // 发 消息的 ID Forward bool // 发 是否为转发消息 // contains filtered or unexported fields }
func (*MessageElementMessage) Parse ¶
func (e *MessageElementMessage) Parse(n *html.Node) (MessageElement, error)
func (*MessageElementMessage) Stringify ¶
func (e *MessageElementMessage) Stringify() string
func (*MessageElementMessage) Tag ¶
func (e *MessageElementMessage) Tag() string
type MessageElementParser ¶
type MessageElementQuote ¶
type MessageElementQuote struct { *ChildrenMessageElement *ExtendAttributes Id string // 发 消息的 ID Forward bool // 发 是否为转发消息 // contains filtered or unexported fields }
func (*MessageElementQuote) Parse ¶
func (e *MessageElementQuote) Parse(n *html.Node) (MessageElement, error)
func (*MessageElementQuote) Stringify ¶
func (e *MessageElementQuote) Stringify() string
func (*MessageElementQuote) Tag ¶
func (e *MessageElementQuote) Tag() string
type MessageElementSharp ¶
type MessageElementSharp struct { *ChildrenMessageElement *ExtendAttributes Id string // 收发 目标频道的 ID Name string // 收发 目标频道的名称 // contains filtered or unexported fields }
func (*MessageElementSharp) Parse ¶
func (e *MessageElementSharp) Parse(n *html.Node) (MessageElement, error)
func (*MessageElementSharp) Stringify ¶
func (e *MessageElementSharp) Stringify() string
func (*MessageElementSharp) Tag ¶
func (e *MessageElementSharp) Tag() string
type MessageElementSpl ¶
type MessageElementSpl struct { *ChildrenMessageElement *ExtendAttributes // contains filtered or unexported fields }
func (*MessageElementSpl) Parse ¶
func (e *MessageElementSpl) Parse(n *html.Node) (MessageElement, error)
func (*MessageElementSpl) Stringify ¶
func (e *MessageElementSpl) Stringify() string
func (*MessageElementSpl) Tag ¶
func (e *MessageElementSpl) Tag() string
type MessageElementStrong ¶
type MessageElementStrong struct { *ChildrenMessageElement *ExtendAttributes }
func (*MessageElementStrong) Alias ¶
func (e *MessageElementStrong) Alias() []string
func (*MessageElementStrong) Parse ¶
func (e *MessageElementStrong) Parse(n *html.Node) (MessageElement, error)
func (*MessageElementStrong) Stringify ¶
func (e *MessageElementStrong) Stringify() string
func (*MessageElementStrong) Tag ¶
func (e *MessageElementStrong) Tag() string
type MessageElementSub ¶
type MessageElementSub struct { *ChildrenMessageElement *ExtendAttributes // contains filtered or unexported fields }
func (*MessageElementSub) Parse ¶
func (e *MessageElementSub) Parse(n *html.Node) (MessageElement, error)
func (*MessageElementSub) Stringify ¶
func (e *MessageElementSub) Stringify() string
func (*MessageElementSub) Tag ¶
func (e *MessageElementSub) Tag() string
type MessageElementSup ¶
type MessageElementSup struct { *ChildrenMessageElement *ExtendAttributes // contains filtered or unexported fields }
func (*MessageElementSup) Parse ¶
func (e *MessageElementSup) Parse(n *html.Node) (MessageElement, error)
func (*MessageElementSup) Stringify ¶
func (e *MessageElementSup) Stringify() string
func (*MessageElementSup) Tag ¶
func (e *MessageElementSup) Tag() string
type MessageElementText ¶
type MessageElementText struct { Content string // contains filtered or unexported fields }
func (*MessageElementText) GetChildren ¶ added in v0.0.13
func (e *MessageElementText) GetChildren() []MessageElement
func (*MessageElementText) Parse ¶
func (e *MessageElementText) Parse(n *html.Node) (MessageElement, error)
func (*MessageElementText) Stringify ¶
func (e *MessageElementText) Stringify() string
func (*MessageElementText) Tag ¶
func (e *MessageElementText) Tag() string
type MessageElementVideo ¶ added in v0.0.7
type MessageElementVideo struct { *ChildrenMessageElement *ExtendAttributes Src string // 收发 资源的 URL Title string // 收发 资源文件名称 Cache bool // 发 是否使用已缓存的文件 Timeout string // 发 下载文件的最长时间 (毫秒) Width uint32 // 收 视频宽度 (像素) Height uint32 // 收 视频高度 (像素) Duration uint32 // 收 视频长度 (秒) Poster string // 收发 视频封面 URL // contains filtered or unexported fields }
func (*MessageElementVideo) Parse ¶ added in v0.0.7
func (e *MessageElementVideo) Parse(n *html.Node) (MessageElement, error)
func (*MessageElementVideo) Stringify ¶ added in v0.0.7
func (e *MessageElementVideo) Stringify() string
func (*MessageElementVideo) Tag ¶ added in v0.0.7
func (e *MessageElementVideo) Tag() string
type MessageElmentBr ¶
type MessageElmentBr struct {
// contains filtered or unexported fields
}
func (*MessageElmentBr) GetChildren ¶ added in v0.0.13
func (e *MessageElmentBr) GetChildren() []MessageElement
func (*MessageElmentBr) Parse ¶
func (e *MessageElmentBr) Parse(n *html.Node) (MessageElement, error)
func (*MessageElmentBr) Stringify ¶
func (e *MessageElmentBr) Stringify() string
func (*MessageElmentBr) Tag ¶
func (e *MessageElmentBr) Tag() string
type MessageElmentP ¶
type MessageElmentP struct { *ChildrenMessageElement *ExtendAttributes // contains filtered or unexported fields }
func (*MessageElmentP) Parse ¶
func (e *MessageElmentP) Parse(n *html.Node) (MessageElement, error)
func (*MessageElmentP) Stringify ¶
func (e *MessageElmentP) Stringify() string
func (*MessageElmentP) Tag ¶
func (e *MessageElmentP) Tag() string
Click to show internal directories.
Click to hide internal directories.