message

package
v0.0.15 Latest Latest
Warning

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

Go to latest
Published: Jun 19, 2024 License: MIT Imports: 9 Imported by: 2

Documentation

Index

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

func (*ExtendAttributes) Get added in v0.0.8

func (e *ExtendAttributes) Get(key string) (string, bool)

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) Alias

func (e MessageElementA) Alias() []string

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) Alias

func (e MessageElementAt) Alias() []string

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) Alias

func (e MessageElementAudio) Alias() []string

func (*MessageElementAudio) Parse

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) Alias

func (e MessageElementAuthor) Alias() []string

func (*MessageElementAuthor) Parse

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) Alias

func (e MessageElementButton) Alias() []string

func (*MessageElementButton) Parse

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) Alias

func (e MessageElementCode) Alias() []string

func (*MessageElementCode) Parse

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 (*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) Alias added in v0.0.8

func (e MessageElementExtend) Alias() []string

func (*MessageElementExtend) Parse added in v0.0.8

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) Alias

func (e MessageElementFile) Alias() []string

func (*MessageElementFile) Parse

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) Alias

func (e MessageElementImg) Alias() []string

func (*MessageElementImg) Parse

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 (*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) Alias

func (e MessageElementMessage) Alias() []string

func (*MessageElementMessage) Parse

func (*MessageElementMessage) Stringify

func (e *MessageElementMessage) Stringify() string

func (*MessageElementMessage) Tag

func (e *MessageElementMessage) Tag() string

type MessageElementParser

type MessageElementParser interface {
	Tag() string
	Alias() []string
	Parse(n *html.Node) (MessageElement, error)
}

type MessageElementQuote

type MessageElementQuote struct {
	*ChildrenMessageElement
	*ExtendAttributes
	Id      string // 发 消息的 ID
	Forward bool   // 发 是否为转发消息
	// contains filtered or unexported fields
}

func (MessageElementQuote) Alias

func (e MessageElementQuote) Alias() []string

func (*MessageElementQuote) Parse

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) Alias

func (e MessageElementSharp) Alias() []string

func (*MessageElementSharp) Parse

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) Alias

func (e MessageElementSpl) Alias() []string

func (*MessageElementSpl) Parse

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 (*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) Alias

func (e MessageElementSub) Alias() []string

func (*MessageElementSub) Parse

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) Alias

func (e MessageElementSup) Alias() []string

func (*MessageElementSup) Parse

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) Alias

func (e MessageElementText) Alias() []string

func (*MessageElementText) GetChildren added in v0.0.13

func (e *MessageElementText) GetChildren() []MessageElement

func (*MessageElementText) Parse

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) Alias added in v0.0.7

func (e MessageElementVideo) Alias() []string

func (*MessageElementVideo) Parse added in v0.0.7

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) Alias

func (e MessageElmentBr) Alias() []string

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) Alias

func (e MessageElmentP) Alias() []string

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

type Token added in v0.0.8

type Token struct {
	*html.Token
	// contains filtered or unexported fields
}

Jump to

Keyboard shortcuts

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