utils

package
v2.0.0-...-5bd8924 Latest Latest
Warning

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

Go to latest
Published: Jun 16, 2025 License: AGPL-3.0 Imports: 36 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func ArgSplit

func ArgSplit(str string) (result []string)

func DecodeGifWithCompleteFrame

func DecodeGifWithCompleteFrame(r io.Reader) (g *gif.GIF, err error)

func DeserializationElement

func DeserializationElement(r string) ([]message.IMessageElement, error)

DeserializationElement 反序列化消息,只支持图片,文字

func DeserializationGroupMsg

func DeserializationGroupMsg(r string) (*message.GroupMessage, error)

func FilePathWalkDir

func FilePathWalkDir(root string) ([]string, error)

func FriendLogFields

func FriendLogFields(uin uint32) logrus.Fields

func FuncName

func FuncName() string

func GetGifDimensions

func GetGifDimensions(gif *gif.GIF) (x, y int)

func GroupLogFields

func GroupLogFields[GT constraints.Integer](groupCode GT) logrus.Fields

func ImageFormat

func ImageFormat(origImage []byte) (string, error)

func ImageGet

func ImageGet(url string, opt ...requests.Option) ([]byte, error)

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

func ImageGetWithoutCache

func ImageGetWithoutCache(url string, opt ...requests.Option) ([]byte, error)

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

func ImageNormSize

func ImageNormSize(origImage []byte) ([]byte, error)

func ImageReserve

func ImageReserve(imgBytes []byte) ([]byte, error)

func ImageResize

func ImageResize(origImage []byte, width, height uint) ([]byte, error)

func ImageSuffix

func ImageSuffix(name string) bool

func JoinInt

func JoinInt[T constraints.Signed](ele []T, sep string) string

func JoinInt64

func JoinInt64(ele []int64, sep string) string

func JoinUint

func JoinUint[T constraints.Unsigned](ele []T, sep string) string

func MergeImages

func MergeImages(images [][]byte) ([]byte, error)

func PrefixMatch

func PrefixMatch(opts []string, prefix string) (string, bool)

PrefixMatch 从 opts 中选择一个前缀是 prefix 的字符串,如果有多个选项,则返回 false

func RemoveHtmlTag

func RemoveHtmlTag(s string) string

func Retry

func Retry(count int, interval time.Duration, f func() bool) bool

func SerializationElement

func SerializationElement(e []message.IMessageElement) (string, error)

SerializationElement 序列化消息,只支持图片,文字

func SerializationGroupMsg

func SerializationGroupMsg(m *message.GroupMessage) (string, error)

func SubImage

func SubImage(img image.Image, r image.Rectangle) image.Image

func Switch2Bool

func Switch2Bool(s string) bool

func TimestampFormat

func TimestampFormat(ts int64) string

func ToDatas

func ToDatas(data interface{}) (map[string]string, error)

func ToParams

func ToParams(data interface{}) (gout.H, error)

func UnquoteString

func UnquoteString(s string) (string, error)

func UploadGroupImage

func UploadGroupImage(groupCode uint32, img []byte, isNorm bool) (image *message.ImageElement, err error)

func UploadGroupImageByUrl

func UploadGroupImageByUrl(groupCode uint32, url string, isNorm bool) (*message.ImageElement, error)

func UploadPrivateImage

func UploadPrivateImage(uin uint32, img []byte, isNorm bool) (*message.ImageElement, error)

func UrlEncode

func UrlEncode(data map[string]string) string

Types

type EmitE

type EmitE struct {
	Id   interface{}
	Type concern_type.Type
}

func NewEmitE

func NewEmitE(id interface{}, t concern_type.Type) *EmitE

type EmitQueue

type EmitQueue struct {
	TimeInterval time.Duration
	// contains filtered or unexported fields
}

func NewEmitQueue

func NewEmitQueue(c chan<- *EmitE, interval time.Duration) *EmitQueue

func (*EmitQueue) Add

func (q *EmitQueue) Add(e *EmitE)

func (*EmitQueue) Delete

func (q *EmitQueue) Delete(id interface{})

func (*EmitQueue) Start

func (q *EmitQueue) Start()

func (*EmitQueue) Stop

func (q *EmitQueue) Stop()

func (*EmitQueue) Update

func (q *EmitQueue) Update(e *EmitE)

type HackedBot

type HackedBot[UT, GT constraints.Integer] struct {
	Bot **miraiBot.Bot
	// contains filtered or unexported fields
}

HackedBot 拦截一些方法方便测试

func GetBot

func GetBot() *HackedBot[uint32, uint32]

func (*HackedBot[UT, GT]) FindFriend

func (h *HackedBot[UT, GT]) FindFriend(uin UT) *entity.User

func (*HackedBot[UT, GT]) FindGroup

func (h *HackedBot[UT, GT]) FindGroup(code GT) *entity.Group

func (*HackedBot[UT, GT]) FindGroupMember

func (h *HackedBot[UT, GT]) FindGroupMember(groupCode GT, uin UT) *entity.GroupMember

func (*HackedBot[UT, GT]) GetFriendList

func (h *HackedBot[UT, GT]) GetFriendList() []*entity.User

func (*HackedBot[UT, GT]) GetGroupList

func (h *HackedBot[UT, GT]) GetGroupList() []*entity.Group

func (*HackedBot[UT, GT]) GetUin

func (h *HackedBot[UT, GT]) GetUin() UT

func (*HackedBot[UT, GT]) IsOnline

func (h *HackedBot[UT, GT]) IsOnline() bool

func (*HackedBot[UT, GT]) SolveFriendRequest

func (h *HackedBot[UT, GT]) SolveFriendRequest(req *event.NewFriendRequest, accept bool)

func (*HackedBot[UT, GT]) SolveGroupJoinRequest

func (h *HackedBot[UT, GT]) SolveGroupJoinRequest(i *event.GroupInvite, accept, _ bool, reason string)

func (*HackedBot[UT, GT]) TESTAddGroup

func (h *HackedBot[UT, GT]) TESTAddGroup(groupCode GT)

TESTAddGroup 仅可用于测试

func (*HackedBot[UT, GT]) TESTAddMember

func (h *HackedBot[UT, GT]) TESTAddMember(groupCode GT, uin UT, permission entity.GroupMemberPermission)

TESTAddMember 仅可用于测试

func (*HackedBot[UT, GT]) TESTReset

func (h *HackedBot[UT, GT]) TESTReset()

TESTReset 仅可用于测试

func (*HackedBot[UT, GT]) TESTSetUin

func (h *HackedBot[UT, GT]) TESTSetUin(uin UT)

TESTSetUin 仅可用于测试

Directories

Path Synopsis

Jump to

Keyboard shortcuts

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