mmsg

package
v1.1.2 Latest Latest
Warning

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

Go to latest
Published: Jul 1, 2023 License: AGPL-3.0 Imports: 10 Imported by: 3

Documentation

Index

Constants

View Source
const (
	ImageBytes message.ElementType = 10000 + iota
	Typed
	Cut
	At
	Poke
)

Variables

This section is empty.

Functions

This section is empty.

Types

type AtElement added in v1.0.7

type AtElement struct {
	*message.AtElement
}

func NewAt added in v1.0.7

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

func (*AtElement) PackToElement added in v1.0.7

func (a *AtElement) PackToElement(target Target) message.IMessageElement

func (*AtElement) Type added in v1.0.7

func (a *AtElement) Type() message.ElementType

type CustomElement

type CustomElement interface {
	PackToElement(target Target) message.IMessageElement
}

type CutElement added in v1.0.5

type CutElement struct {
}

func (*CutElement) PackToElement added in v1.0.5

func (c *CutElement) PackToElement(Target) message.IMessageElement

func (*CutElement) Type added in v1.0.5

func (c *CutElement) Type() message.ElementType

type GroupTarget

type GroupTarget struct {
	GroupCode int64 `json:"group_code"`
}

func NewGroupTarget

func NewGroupTarget(groupCode int64) *GroupTarget

func (*GroupTarget) TargetCode

func (t *GroupTarget) TargetCode() int64

func (*GroupTarget) TargetType

func (t *GroupTarget) TargetType() TargetType

type IMsgCtx

type IMsgCtx interface {
	TextSend(text string) interface{}
	TextReply(text string) interface{}
	Reply(m *MSG) interface{}
	Send(m *MSG) interface{}
	NoPermissionReply() interface{}
	GetLog() *logrus.Entry
	GetTarget() Target
	GetSender() *message.Sender
}

type ImageBytesElement

type ImageBytesElement struct {
	Buf []byte
	// contains filtered or unexported fields
}

func NewImage

func NewImage(buf []byte) *ImageBytesElement

func NewImageByLocal added in v1.0.5

func NewImageByLocal(filepath string) *ImageBytesElement

func NewImageByUrl

func NewImageByUrl(url string, opts ...requests.Option) *ImageBytesElement

NewImageByUrl 默认会对相同的url使用缓存

func NewImageByUrlWithoutCache added in v1.0.7

func NewImageByUrlWithoutCache(url string, opts ...requests.Option) *ImageBytesElement

NewImageByUrlWithoutCache 默认情况下相同的url会存在缓存, 如果url会随机返回不同的图片,则需要禁用缓存 这个函数就是不使用缓存的版本

func (*ImageBytesElement) Alternative

func (i *ImageBytesElement) Alternative(s string) *ImageBytesElement

func (*ImageBytesElement) Norm added in v1.0.6

func (*ImageBytesElement) PackToElement

func (i *ImageBytesElement) PackToElement(target Target) message.IMessageElement

func (*ImageBytesElement) Resize added in v1.0.6

func (i *ImageBytesElement) Resize(width, height uint) *ImageBytesElement

func (*ImageBytesElement) Type

type MSG

type MSG struct {
	// contains filtered or unexported fields
}

MSG 线程不安全

func NewMSG

func NewMSG() *MSG

func NewMSGFromGroupMessage added in v1.0.9

func NewMSGFromGroupMessage(gm *message.GroupMessage) *MSG

func NewMSGFromPrivateMessage added in v1.0.9

func NewMSGFromPrivateMessage(pm *message.PrivateMessage) *MSG

func NewText

func NewText(s string) *MSG

func NewTextf

func NewTextf(format string, args ...interface{}) *MSG

func (*MSG) Append

func (m *MSG) Append(elems ...message.IMessageElement) *MSG

func (*MSG) At added in v1.0.7

func (m *MSG) At(target int64) *MSG

func (*MSG) AtAll added in v1.0.7

func (m *MSG) AtAll(prepend ...bool) *MSG

AtAll 添加@全体成员,如果prepend设置为true,则会添加在消息最前面

func (*MSG) Clear added in v1.0.9

func (m *MSG) Clear() *MSG

func (*MSG) Clone added in v1.0.5

func (m *MSG) Clone() *MSG

func (*MSG) Cut added in v1.0.5

func (m *MSG) Cut() *MSG

func (*MSG) Drop added in v1.0.9

func (m *MSG) Drop(predicate func(e message.IMessageElement, index int) bool) *MSG

Drop predicate返回true的元素被去掉

func (*MSG) Elements

func (m *MSG) Elements() []message.IMessageElement

func (*MSG) Image

func (m *MSG) Image(buf []byte, alternative string) *MSG

func (*MSG) ImageByLocal added in v1.0.6

func (m *MSG) ImageByLocal(filepath, alternative string) *MSG

func (*MSG) ImageByLocalWithNorm added in v1.0.6

func (m *MSG) ImageByLocalWithNorm(filepath, alternative string) *MSG

func (*MSG) ImageByLocalWithResize added in v1.0.6

func (m *MSG) ImageByLocalWithResize(filepath, alternative string, width, height uint) *MSG

func (*MSG) ImageByUrl

func (m *MSG) ImageByUrl(url string, alternative string, opts ...requests.Option) *MSG

func (*MSG) ImageByUrlWithNorm added in v1.0.1

func (m *MSG) ImageByUrlWithNorm(url string, alternative string, opts ...requests.Option) *MSG

func (*MSG) ImageByUrlWithResize added in v1.0.6

func (m *MSG) ImageByUrlWithResize(url string, alternative string, width, height uint, opts ...requests.Option) *MSG

func (*MSG) ImageWithNorm added in v1.0.1

func (m *MSG) ImageWithNorm(buf []byte, alternative string) *MSG

func (*MSG) ImageWithResize added in v1.0.6

func (m *MSG) ImageWithResize(buf []byte, alternative string, width, height uint) *MSG

func (*MSG) Poke added in v1.0.9

func (m *MSG) Poke(target int64) *MSG

Poke 戳一戳,只支持群聊,如果MSG发送给私聊,将自动忽略

func (*MSG) Text

func (m *MSG) Text(s string) *MSG

func (*MSG) Textf

func (m *MSG) Textf(format string, args ...interface{}) *MSG

func (*MSG) ToCombineMessage added in v1.0.5

func (m *MSG) ToCombineMessage(target Target) *message.SendingMessage

ToCombineMessage 总是返回 non-nil

func (*MSG) ToMessage

func (m *MSG) ToMessage(target Target) []*message.SendingMessage

ToMessage 返回消息用于发送

type PokeElement added in v1.0.9

type PokeElement struct {
	Uin int64
}

PokeElement 戳一戳

func NewPoke added in v1.0.9

func NewPoke(uin int64) *PokeElement

func (*PokeElement) PackToElement added in v1.0.9

func (p *PokeElement) PackToElement(target Target) message.IMessageElement

func (*PokeElement) Type added in v1.0.9

func (p *PokeElement) Type() message.ElementType

type PrivateTarget

type PrivateTarget struct {
	Uin int64 `json:"uin"`
}

func NewPrivateTarget

func NewPrivateTarget(uin int64) *PrivateTarget

func (*PrivateTarget) TargetCode

func (t *PrivateTarget) TargetCode() int64

func (*PrivateTarget) TargetType

func (t *PrivateTarget) TargetType() TargetType

type Target

type Target interface {
	TargetType() TargetType
	TargetCode() int64
}

type TargetType

type TargetType int32
const (
	TargetGroup TargetType = iota
	TargetPrivate
)

func (TargetType) IsGroup

func (t TargetType) IsGroup() bool

func (TargetType) IsPrivate

func (t TargetType) IsPrivate() bool

type TypedElement

type TypedElement struct {
	// contains filtered or unexported fields
}

TypedElement 根据TargetType选择不同的element,不解决循环问题,使用不当可能导致堆栈溢出 可以同时设置 OnGroup 和 OnPrivate ,发送时会根据目标自动选择 如果只设置了一个,发送另一个时会返回 nil ,即这里什么也不发送

func NewGroupElement

func NewGroupElement(e message.IMessageElement) *TypedElement

func NewPrivateElement

func NewPrivateElement(e message.IMessageElement) *TypedElement

func NewTypedElement

func NewTypedElement() *TypedElement

func (*TypedElement) OnGroup

func (*TypedElement) OnPrivate

func (*TypedElement) PackToElement

func (t *TypedElement) PackToElement(target Target) message.IMessageElement

func (*TypedElement) Type

func (t *TypedElement) Type() message.ElementType

Jump to

Keyboard shortcuts

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