utils

package
v1.1.4 Latest Latest
Warning

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

Go to latest
Published: Sep 24, 2023 License: AGPL-3.0 Imports: 34 Imported by: 14

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 int64) logrus.Fields

func FuncName

func FuncName() string

func GetGifDimensions

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

func GroupLogFields

func GroupLogFields(groupCode int64) 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 JoinInt64

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

func MergeImages

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

func MessageFilter

func MessageFilter(msg []message.IMessageElement, filter func(message.IMessageElement) bool) []message.IMessageElement

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 int64, img []byte, isNorm bool) (image *message.GroupImageElement, err error)

func UploadGroupImageByUrl

func UploadGroupImageByUrl(groupCode int64, url string, isNorm bool) (*message.GroupImageElement, error)

func UploadPrivateImage

func UploadPrivateImage(uin int64, img []byte, isNorm bool) (*message.FriendImageElement, 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 struct {
	Bot **miraiBot.Bot
	// contains filtered or unexported fields
}

HackedBot 拦截一些方法方便测试

func GetBot

func GetBot() *HackedBot

func (*HackedBot) FindFriend

func (h *HackedBot) FindFriend(uin int64) *client.FriendInfo

func (*HackedBot) FindGroup

func (h *HackedBot) FindGroup(code int64) *client.GroupInfo

func (*HackedBot) GetFriendList

func (h *HackedBot) GetFriendList() []*client.FriendInfo

func (*HackedBot) GetGroupList

func (h *HackedBot) GetGroupList() []*client.GroupInfo

func (*HackedBot) GetUin

func (h *HackedBot) GetUin() int64

func (*HackedBot) IsOnline

func (h *HackedBot) IsOnline() bool

func (*HackedBot) SolveFriendRequest

func (h *HackedBot) SolveFriendRequest(req *client.NewFriendRequest, accept bool)

func (*HackedBot) SolveGroupJoinRequest

func (h *HackedBot) SolveGroupJoinRequest(i interface{}, accept, block bool, reason string)

func (*HackedBot) TESTAddGroup

func (h *HackedBot) TESTAddGroup(groupCode int64)

TESTAddGroup 仅可用于测试

func (*HackedBot) TESTAddMember

func (h *HackedBot) TESTAddMember(groupCode int64, uin int64, permission client.MemberPermission)

TESTAddMember 仅可用于测试

func (*HackedBot) TESTReset

func (h *HackedBot) TESTReset()

TESTReset 仅可用于测试

func (*HackedBot) TESTSetUin

func (h *HackedBot) TESTSetUin(uin int64)

TESTSetUin 仅可用于测试

Directories

Path Synopsis

Jump to

Keyboard shortcuts

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