message

package
v0.0.3 Latest Latest
Warning

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

Go to latest
Published: May 11, 2024 License: AGPL-3.0 Imports: 9 Imported by: 3

Documentation

Index

Constants

View Source
const (
	AtTypeGroupMember = 0 // At群成员
)

Variables

This section is empty.

Functions

func BuildMessageElements

func BuildMessageElements(msgElems []IMessageElement) (msgBody *message.MessageBody)

func ToReadableString

func ToReadableString(m []IMessageElement) string

Types

type AnonymousInfo

type AnonymousInfo struct {
	AnonymousId   string
	AnonymousNick string
}

type AtElement

type AtElement struct {
	Target  uint32
	UID     string
	Display string
	SubType AtType
}

func NewAt

func NewAt(target uint32, display ...string) *AtElement

func (*AtElement) BuildElement

func (e *AtElement) BuildElement() []*message.Elem

func (*AtElement) Type

func (e *AtElement) Type() ElementType

type AtType

type AtType int

type ElementType

type ElementType int
const (
	Text     ElementType = iota // 文本
	Image                       // 图片
	Face                        // 表情
	At                          // 艾特
	Reply                       // 回复
	Service                     // 服务
	Forward                     // 转发
	File                        // 文件
	Voice                       // 语音
	Video                       // 视频
	LightApp                    // 轻应用
	RedBag                      // 红包
)

type FaceElement

type FaceElement struct {
	FaceID uint16
	// contains filtered or unexported fields
}

func (*FaceElement) BuildElement

func (e *FaceElement) BuildElement() []*message.Elem

func (*FaceElement) Type

func (e *FaceElement) Type() ElementType

type FriendImageElement

type FriendImageElement struct {
	ImageId string
	Md5     []byte
	Size    uint32
	Width   int32
	Height  int32
	Url     string

	// Send
	MsgInfo     *oidb.MsgInfo
	Stream      []byte
	CompatImage *message.NotOnlineImage

	Flash bool
}

func (*FriendImageElement) BuildElement

func (e *FriendImageElement) BuildElement() []*message.Elem

func (*FriendImageElement) Type

func (e *FriendImageElement) Type() ElementType

type GroupImageElement

type GroupImageElement struct {
	ImageId   string
	FileId    int64
	ImageType int32
	Size      uint32
	Width     int32
	Height    int32
	Md5       []byte
	Url       string

	// EffectID show pic effect id.
	EffectID int32
	Flash    bool

	// Send
	MsgInfo    *oidb.MsgInfo
	Stream     []byte
	CompatFace []byte
}

func NewGroupImage

func NewGroupImage(data []byte) *GroupImageElement

func NewGroupImageByFile

func NewGroupImageByFile(path string) (*GroupImageElement, error)

func (*GroupImageElement) BuildElement

func (e *GroupImageElement) BuildElement() []*message.Elem

func (*GroupImageElement) Type

func (e *GroupImageElement) Type() ElementType

type GroupMessage

type GroupMessage struct {
	Id             int32
	InternalId     int32
	GroupCode      uint32
	GroupName      string
	Sender         *Sender
	Time           uint64
	Elements       []IMessageElement
	OriginalObject *message.PushMsgBody
}

func ParseGroupMessage

func ParseGroupMessage(msg *message.PushMsg) *GroupMessage

func (*GroupMessage) ToString

func (msg *GroupMessage) ToString() (res string)

type IMessage

type IMessage interface {
	GetElements() []IMessageElement
	Chat() int64
	ToString() string
	Texts() []string
}

type IMessageElement

type IMessageElement interface {
	Type() ElementType
}

type PrivateMessage

type PrivateMessage struct {
	Id         int32
	InternalId int32
	Self       int64
	Target     int64
	Time       int32
	Sender     *Sender
	Elements   []IMessageElement
}

func ParsePrivateMessage

func ParsePrivateMessage(msg *message.PushMsg) *PrivateMessage

type ReplyElement

type ReplyElement struct {
	ReplySeq int32
	Sender   uint64
	GroupID  uint64 // 私聊回复群聊时
	Time     int32
	Elements []IMessageElement
}

func (*ReplyElement) BuildElement

func (e *ReplyElement) BuildElement() []*message.Elem

func (*ReplyElement) Type

func (e *ReplyElement) Type() ElementType

type Sender

type Sender struct {
	Uin           uint32
	Uid           string
	Nickname      string
	CardName      string
	AnonymousInfo *AnonymousInfo
	IsFriend      bool
}

func (*Sender) IsAnonymous

func (s *Sender) IsAnonymous() bool

type SendingMessage

type SendingMessage struct {
	Elements []IMessageElement
}

func NewSendingMessage

func NewSendingMessage() *SendingMessage

func (*SendingMessage) Append

Append 要传入msg的引用

func (*SendingMessage) FirstOrNil

func (msg *SendingMessage) FirstOrNil(f func(element IMessageElement) bool) IMessageElement

func (*SendingMessage) GetElems

func (msg *SendingMessage) GetElems() []IMessageElement

type ShortVideoElement

type ShortVideoElement struct {
	Name      string
	Uuid      []byte
	Size      int32
	ThumbSize int32
	Md5       []byte
	ThumbMd5  []byte
	Url       string
}

func (*ShortVideoElement) BuildElement

func (e *ShortVideoElement) BuildElement() []*message.Elem

func (*ShortVideoElement) Type

func (e *ShortVideoElement) Type() ElementType

type Source

type Source struct {
	SourceType  SourceType
	PrimaryID   int64 // 群号/QQ号/guild_id
	SecondaryID int64 // channel_id
}

Source 消息来源

type SourceType

type SourceType byte
const (
	SourcePrivate      SourceType = 1 << iota
	SourceGroup        SourceType = 1 << iota
	SourceGuildChannel SourceType = 1 << iota
	SourceGuildDirect  SourceType = 1 << iota
)

MessageSourceType 常量

func (SourceType) String

func (t SourceType) String() string

type TempMessage

type TempMessage struct {
	Id        int32
	GroupCode uint32
	GroupName string
	Self      uint32
	Sender    *Sender
	Elements  []IMessageElement
}

func ParseTempMessage

func ParseTempMessage(msg *message.PushMsg) *TempMessage

type TextElement

type TextElement struct {
	Content string
}

func NewText

func NewText(s string) *TextElement

func (*TextElement) BuildElement

func (e *TextElement) BuildElement() []*message.Elem

func (*TextElement) Type

func (e *TextElement) Type() ElementType

type VoiceElement

type VoiceElement struct {
	Name string
	Md5  []byte
	Size uint32
	Url  string

	// --- sending ---
	Data []byte
}

func (*VoiceElement) BuildElement

func (e *VoiceElement) BuildElement() []*message.Elem

func (*VoiceElement) Type

func (e *VoiceElement) Type() ElementType

Jump to

Keyboard shortcuts

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