message

package
v1.2.1 Latest Latest
Warning

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

Go to latest
Published: May 1, 2024 License: AGPL-3.0 Imports: 12 Imported by: 1

Documentation

Index

Constants

View Source
const (
	QQMusic    = iota // QQ音乐
	CloudMusic        // 网易云音乐
	MiguMusic         // 咪咕音乐
	KugouMusic        // 酷狗音乐
	KuwoMusic         // 酷我音乐
)

MusicType values.

View Source
const MaxMessageSize = 5000

单条消息发送的大小限制(预估)

Variables

This section is empty.

Functions

func EstimateLength

func EstimateLength(elems []IMessageElement) int

func FaceNameById

func FaceNameById(id int) string

func ToProtoElems

func ToProtoElems(elems []IMessageElement, generalFlags bool) (r []*msg.Elem)

func ToReadableString

func ToReadableString(m []IMessageElement) string

func ToSrcProtoElems

func ToSrcProtoElems(elems []IMessageElement) []*msg.Elem

Types

type AnimatedSticker

type AnimatedSticker struct {
	ID   int32
	Name string
}

func (*AnimatedSticker) Pack

func (e *AnimatedSticker) Pack() []*msg.Elem

func (*AnimatedSticker) Type

func (e *AnimatedSticker) Type() ElementType

type AnonymousInfo

type AnonymousInfo struct {
	AnonymousId   string
	AnonymousNick string
}

type AtElement

type AtElement struct {
	Target  int64
	Display string
	SubType AtType
}

func AtAll

func AtAll() *AtElement

func NewAt

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

func (*AtElement) Pack

func (e *AtElement) Pack() (r []*msg.Elem)

func (*AtElement) Type

func (e *AtElement) Type() ElementType

type AtType

type AtType int

type DiceElement

type DiceElement struct {
	*MarketFaceElement
	Value int32
}

type ElementType

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

func (ElementType) String

func (i ElementType) String() string

type FaceElement

type FaceElement struct {
	Index int32
	Name  string
}

func NewFace

func NewFace(index int32) *FaceElement

func (*FaceElement) Pack

func (e *FaceElement) Pack() (r []*msg.Elem)

func (*FaceElement) Type

func (e *FaceElement) Type() ElementType

type FingerGuessingElement

type FingerGuessingElement struct {
	*MarketFaceElement
	Value int32
	Name  string
}

type ForwardElement

type ForwardElement struct {
	FileName string
	Content  string
	ResId    string
	Items    []*msg.PbMultiMsgItem
}

func (*ForwardElement) Pack

func (e *ForwardElement) Pack() []*msg.Elem

func (*ForwardElement) Type

func (e *ForwardElement) Type() ElementType

Type impl IMessageElement

type ForwardMessage

type ForwardMessage struct {
	Nodes []*ForwardNode
}

ForwardMessage 合并转发消息

func NewForwardMessage

func NewForwardMessage() *ForwardMessage

func (*ForwardMessage) AddNode

func (f *ForwardMessage) AddNode(node *ForwardNode) *ForwardMessage

AddNode adds a node to the forward message. return for method chaining.

func (*ForwardMessage) Brief

func (f *ForwardMessage) Brief() string

func (*ForwardMessage) CalculateValidationData

func (f *ForwardMessage) CalculateValidationData(seq, random int32, groupCode int64) ([]byte, []byte)

func (*ForwardMessage) Length

func (f *ForwardMessage) Length() int

Length return the length of Nodes.

func (*ForwardMessage) PackForwardMessage

func (f *ForwardMessage) PackForwardMessage(seq int32, random int32, groupCode int64) []*msg.Message

func (*ForwardMessage) Preview

func (f *ForwardMessage) Preview() string

func (*ForwardMessage) Type

func (f *ForwardMessage) Type() ElementType

type ForwardNode

type ForwardNode struct {
	GroupId    int64
	SenderId   int64
	SenderName string
	Time       int32
	Message    []IMessageElement
}

type FriendImageElement

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

	Flash bool
}

func (*FriendImageElement) Pack

func (e *FriendImageElement) Pack() []*msg.Elem

func (*FriendImageElement) Type

func (e *FriendImageElement) Type() ElementType

type GroupFileElement

type GroupFileElement struct {
	Name  string
	Size  int64
	Path  string
	Busid int32
}

func (*GroupFileElement) Type

func (e *GroupFileElement) Type() ElementType

type GroupImageElement

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

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

func NewGroupImage

func NewGroupImage(id string, md5 []byte, fid int64, size, width, height, imageType int32) *GroupImageElement

func (*GroupImageElement) Pack

func (e *GroupImageElement) Pack() (r []*msg.Elem)

func (*GroupImageElement) Type

func (e *GroupImageElement) Type() ElementType

type GroupMessage

type GroupMessage struct {
	Id             int32
	InternalId     int32
	GroupCode      int64
	GroupName      string
	Sender         *Sender
	Time           int32
	Elements       []IMessageElement
	OriginalObject *msg.Message
}

func (*GroupMessage) Chat

func (msg *GroupMessage) Chat() int64

func (*GroupMessage) GetElements

func (msg *GroupMessage) GetElements() []IMessageElement

func (*GroupMessage) Texts

func (msg *GroupMessage) Texts() []string

func (*GroupMessage) ToString

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

type GroupVoiceElement

type GroupVoiceElement struct {
	Data []byte
	Ptt  *msg.Ptt
}

func (*GroupVoiceElement) Type

func (e *GroupVoiceElement) Type() ElementType

type GuildChannelMessage

type GuildChannelMessage struct {
	Id         uint64
	InternalId uint64
	GuildId    uint64
	ChannelId  uint64
	Time       int64
	Sender     *GuildSender
	Elements   []IMessageElement
	Reactions  []*GuildMessageEmojiReaction // only available for pulling messages
}

type GuildImageElement

type GuildImageElement struct {
	FileId        int64
	FilePath      string
	ImageType     int32
	Size          int32
	Width         int32
	Height        int32
	DownloadIndex string
	Md5           []byte
	Url           string
}

func (*GuildImageElement) Pack

func (e *GuildImageElement) Pack() (r []*msg.Elem)

func (*GuildImageElement) Type

func (e *GuildImageElement) Type() ElementType

type GuildMessageEmojiReaction

type GuildMessageEmojiReaction struct {
	EmojiId   string
	EmojiType uint64
	Face      *FaceElement
	Count     int32
	Clicked   bool
}

type GuildSender

type GuildSender struct {
	TinyId   uint64
	Nickname string
}

type IMessage

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

type IMessageElement

type IMessageElement interface {
	Type() ElementType
}

func NewDice

func NewDice(value int32) IMessageElement

func NewFingerGuessing

func NewFingerGuessing(value int32) IMessageElement

func ParseMessageElems

func ParseMessageElems(elems []*msg.Elem) []IMessageElement

type IRichMessageElement

type IRichMessageElement interface {
	Pack() []*msg.Elem
}

type ImageBizType

type ImageBizType uint32
const (
	UnknownBizType  ImageBizType = 0
	CustomFaceImage ImageBizType = 1
	HotImage        ImageBizType = 2
	DouImage        ImageBizType = 3 // 斗图
	ZhiTuImage      ImageBizType = 4
	StickerImage    ImageBizType = 7
	SelfieImage     ImageBizType = 8
	StickerAdImage  ImageBizType = 9
	RelatedEmoImage ImageBizType = 10
	HotSearchImage  ImageBizType = 13
)

type LightAppElement

type LightAppElement struct {
	Content string
}

func NewLightApp

func NewLightApp(content string) *LightAppElement

func (*LightAppElement) Pack

func (e *LightAppElement) Pack() (r []*msg.Elem)

func (*LightAppElement) Type

func (e *LightAppElement) Type() ElementType

type MarketFaceElement

type MarketFaceElement struct {
	Name       string
	FaceId     []byte // decoded = mediaType == 2 ? string(FaceId) : hex.EncodeToString(FaceId).toLower().trimSpace(); download url param?
	TabId      int32
	ItemType   int32
	SubType    int32  // image type, 0 -> None 1 -> Magic Face 2 -> GIF 3 -> PNG
	MediaType  int32  // 1 -> Voice Face 2 -> dynamic face
	EncryptKey []byte // tea + xor, see EMosmUtils.class::a maybe useful?
	MagicValue string
}

func (*MarketFaceElement) Pack

func (e *MarketFaceElement) Pack() []*msg.Elem

func (*MarketFaceElement) Type

func (e *MarketFaceElement) Type() ElementType

type MusicShareElement

type MusicShareElement struct {
	MusicType  int    // 音乐类型,请使用 QQMusic 等常量
	Title      string // 标题(歌曲名)
	Brief      string
	Summary    string // 简介(歌手名)
	Url        string // 点击跳转链接
	PictureUrl string // 显示图片链接
	MusicUrl   string // 音乐播放链接
}

MusicShareElement 音乐分享卡片

请使用 SendGroupMusicShare 或者 SendFriendMusicShare 发送

func (*MusicShareElement) Type

func (e *MusicShareElement) Type() ElementType

Type implement message.IMessageElement

type PrivateMessage

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

func (*PrivateMessage) Chat

func (msg *PrivateMessage) Chat() int64

func (*PrivateMessage) GetElements

func (msg *PrivateMessage) GetElements() []IMessageElement

func (*PrivateMessage) Texts

func (msg *PrivateMessage) Texts() []string

func (*PrivateMessage) ToString

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

type PrivateVoiceElement

type PrivateVoiceElement = GroupVoiceElement

type RedBagElement

type RedBagElement struct {
	MsgType RedBagMessageType
	Title   string
}

func (*RedBagElement) Type

func (e *RedBagElement) Type() ElementType

type RedBagMessageType

type RedBagMessageType int
const (
	RedBagSimple             RedBagMessageType = 2
	RedBagLucky              RedBagMessageType = 3
	RedBagSimpleTheme        RedBagMessageType = 4
	RedBagLuckyTheme         RedBagMessageType = 5
	RedBagWord               RedBagMessageType = 6
	RedBagSimpleSpecify      RedBagMessageType = 7
	RedBagLuckySpecify       RedBagMessageType = 8
	RedBagSimpleSpecifyOver3 RedBagMessageType = 11
	RedBagLuckySpecifyOver3  RedBagMessageType = 12
	RedBagVoice              RedBagMessageType = 13
	RedBagLook               RedBagMessageType = 14 // ?
	RedBagVoiceC2C           RedBagMessageType = 15
	RedBagH5                 RedBagMessageType = 17
	RedBagKSong              RedBagMessageType = 18
	RedBagEmoji              RedBagMessageType = 19
	RedBagDraw               RedBagMessageType = 22
	RedBagH5Common           RedBagMessageType = 20
	RedBagWordChain          RedBagMessageType = 24
	RedBagKeyword            RedBagMessageType = 25 // ?
	RedBagDrawMultiModel     RedBagMessageType = 26 // ??

	AtTypeGroupMember  = 0 // At群成员
	AtTypeGuildMember  = 1 // At频道成员
	AtTypeGuildChannel = 2 // At频道
)

/com/tencent/mobileqq/data/MessageForQQWalletMsg.java

type ReplyElement

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

func NewPrivateReply

func NewPrivateReply(m *PrivateMessage) *ReplyElement

func NewReply

func NewReply(m *GroupMessage) *ReplyElement

func (*ReplyElement) Type

func (e *ReplyElement) Type() ElementType

type Sender

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

func (*Sender) DisplayName

func (s *Sender) DisplayName() string

func (*Sender) IsAnonymous

func (s *Sender) IsAnonymous() bool

type SendingMessage

type SendingMessage struct {
	Elements []IMessageElement
}

func NewSendingMessage

func NewSendingMessage() *SendingMessage

func SplitLongMessage

func SplitLongMessage(sendingMessage *SendingMessage) []*SendingMessage

SplitLongMessage 将过长的消息分割为若干个适合发送的消息

func (*SendingMessage) Any

func (msg *SendingMessage) Any(filter func(e IMessageElement) bool) bool

func (*SendingMessage) Append

func (*SendingMessage) Count

func (msg *SendingMessage) Count(filter func(e IMessageElement) bool) (c int)

func (*SendingMessage) FirstOrNil

func (msg *SendingMessage) FirstOrNil(filter func(e IMessageElement) bool) IMessageElement

func (*SendingMessage) ToFragmented

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

type ServiceElement

type ServiceElement struct {
	Id      int32
	Content string
	ResId   string
	SubType string
}

func NewRichJson

func NewRichJson(template string) *ServiceElement

func NewRichXml

func NewRichXml(template string, resID int64) *ServiceElement

func NewUrlShare

func NewUrlShare(url, title, content, image string) *ServiceElement

func (*ServiceElement) Pack

func (e *ServiceElement) Pack() (r []*msg.Elem)

func (*ServiceElement) Type

func (e *ServiceElement) Type() ElementType

type ShortVideoElement

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

func (*ShortVideoElement) Pack

func (e *ShortVideoElement) Pack() (r []*msg.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
	SourceGuildChannel
	SourceGuildDirect
)

MessageSourceType 常量

func (SourceType) String

func (t SourceType) String() string

type TempMessage

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

func (*TempMessage) Chat

func (msg *TempMessage) Chat() int64

func (*TempMessage) GetElements

func (msg *TempMessage) GetElements() []IMessageElement

func (*TempMessage) Texts

func (msg *TempMessage) Texts() []string

func (*TempMessage) ToString

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

type TextElement

type TextElement struct {
	Content string
}

func NewText

func NewText(s string) *TextElement

func (*TextElement) Pack

func (e *TextElement) Pack() (r []*msg.Elem)

func (*TextElement) Type

func (e *TextElement) Type() ElementType

type VoiceElement

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

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

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