utils

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: 34 Imported by: 2

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 added in v1.0.0

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

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

func DeserializationGroupMsg added in v1.0.0

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

func FilePathWalkDir

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

func FriendLogFields added in v1.0.0

func FriendLogFields(uin int64) logrus.Fields

func FuncName

func FuncName() string

func GetGifDimensions

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

func GroupLogFields added in v0.0.10

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 added in v1.0.7

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 added in v1.0.6

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

func ImageSuffix

func ImageSuffix(name string) bool

func JoinInt64 added in v0.0.13

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

func MergeImages added in v0.0.19

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 added in v1.0.0

func RemoveHtmlTag(s string) string

func Retry

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

func SerializationElement added in v1.0.0

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

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

func SerializationGroupMsg added in v1.0.0

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

func SubImage added in v0.0.13

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

func Switch2Bool added in v0.0.10

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 added in v1.0.0

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

func UrlEncode added in v0.0.17

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 added in v1.0.0

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

func (*EmitQueue) Start added in v1.0.0

func (q *EmitQueue) Start()

func (*EmitQueue) Stop

func (q *EmitQueue) Stop()

func (*EmitQueue) Update added in v1.0.0

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

type HackedBot added in v1.0.0

type HackedBot struct {
	Bot **miraiBot.Bot
	// contains filtered or unexported fields
}

HackedBot 拦截一些方法方便测试

func GetBot added in v1.0.0

func GetBot() *HackedBot

func (*HackedBot) FindFriend added in v1.0.0

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

func (*HackedBot) FindGroup added in v1.0.0

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

func (*HackedBot) GetFriendList added in v1.0.0

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

func (*HackedBot) GetGroupList added in v1.0.0

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

func (*HackedBot) GetUin added in v1.0.0

func (h *HackedBot) GetUin() int64

func (*HackedBot) IsOnline added in v1.0.0

func (h *HackedBot) IsOnline() bool

func (*HackedBot) SolveFriendRequest added in v1.0.0

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

func (*HackedBot) SolveGroupJoinRequest added in v1.0.0

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

func (*HackedBot) TESTAddGroup added in v1.0.0

func (h *HackedBot) TESTAddGroup(groupCode int64)

TESTAddGroup 仅可用于测试

func (*HackedBot) TESTAddMember added in v1.0.0

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

TESTAddMember 仅可用于测试

func (*HackedBot) TESTReset added in v1.0.0

func (h *HackedBot) TESTReset()

TESTReset 仅可用于测试

func (*HackedBot) TESTSetUin added in v1.0.0

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