global

package
v1.2.0 Latest Latest
Warning

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

Go to latest
Published: Oct 9, 2023 License: AGPL-3.0 Imports: 31 Imported by: 7

Documentation

Overview

Package global 包含文件下载,视频音频编码,本地文件缓存处理,消息过滤器,调用速率限制,gocq主配置等的相关函数与结构体

Index

Constants

View Source
const (
	// ImagePath go-cqhttp使用的图片缓存目录
	ImagePath = "data/images"
	// VoicePath go-cqhttp使用的语音缓存目录
	VoicePath = "data/voices"
	// VideoPath go-cqhttp使用的视频缓存目录
	VideoPath = "data/videos"
	// VersionsPath go-cqhttp使用的版本信息目录
	VersionsPath = "data/versions"
	// CachePath go-cqhttp使用的缓存目录
	CachePath = "data/cache"
	// DumpsPath go-cqhttp使用错误转储目录
	DumpsPath = "dumps"
	// HeaderAmr AMR文件头
	HeaderAmr = "#!AMR"
	// HeaderSilk Silkv3文件头
	HeaderSilk = "\x02#!SILK_V3"
)

Variables

This section is empty.

Functions

func Check

func Check(err error, deleteSession bool)

Check 检测err是否为nil

func DelFile added in v0.9.27

func DelFile(path string) bool

DelFile 删除一个给定path,并返回删除结果

func EncodeMP4 added in v0.9.38

func EncodeMP4(src string, dst string) error

EncodeMP4 将给定视频文件编码为MP4

func EncoderSilk added in v0.9.38

func EncoderSilk(data []byte) ([]byte, error)

EncoderSilk 将音频编码为Silk

func ExtractCover added in v0.9.38

func ExtractCover(src string, target string) error

ExtractCover 获取给定视频文件的Cover

func FindFile added in v0.9.26

func FindFile(file, cache, p string) (data []byte, err error)

FindFile 从给定的File寻找文件,并返回文件byte数组。File是一个合法的URL。p为文件寻找位置。 对于HTTP/HTTPS形式的URL,Cache为"1"或空时表示启用缓存

func GetLogLevel added in v0.9.40

func GetLogLevel(level string) []logrus.Level

GetLogLevel 获取日志等级

可能的值有

"trace","debug","info","warn","warn","error"

func GetLogLevelColorCode added in v1.0.0

func GetLogLevelColorCode(level logrus.Level) string

GetLogLevelColorCode 获取日志等级对应色彩code

func IsAMRorSILK added in v0.9.20

func IsAMRorSILK(b []byte) bool

IsAMRorSILK 判断给定文件是否为Amr或Silk格式

func NeteaseMusicSongInfo added in v0.9.22

func NeteaseMusicSongInfo(id string) (gjson.Result, error)

NeteaseMusicSongInfo 通过给定id在wdd音乐上查找曲目信息

func NewBuffer added in v1.0.0

func NewBuffer() *bytes.Buffer

NewBuffer 从池中获取新 bytes.Buffer

func PathExists

func PathExists(path string) bool

PathExists 判断给定path是否存在

func PutBuffer added in v1.0.0

func PutBuffer(buf *bytes.Buffer)

PutBuffer 将 Buffer放入池中

func QQMusicSongInfo added in v0.9.21

func QQMusicSongInfo(id string) (gjson.Result, error)

QQMusicSongInfo 通过给定id在QQ音乐上查找曲目信息

func ReadAddrFile added in v0.9.31

func ReadAddrFile(path string) []netip.AddrPort

ReadAddrFile 从给定path中读取合法的IP地址与端口,每个IP地址以换行符"\n"作为分隔

func ReadAllText

func ReadAllText(path string) string

ReadAllText 读取给定path对应文件,无法读取时返回空值

func SetupMainSignalHandler added in v1.0.0

func SetupMainSignalHandler() <-chan struct{}

SetupMainSignalHandler is for main to use at last

func VersionNameCompare added in v0.9.30

func VersionNameCompare(current, remote string) bool

VersionNameCompare 检查版本名是否需要更新, 仅适用于 go-cqhttp 的版本命名规则

例: v0.9.29-fix2 == v0.9.29-fix2 -> false

v0.9.29-fix1 < v0.9.29-fix2 -> true

v0.9.29-fix2 > v0.9.29-fix1 -> false

v0.9.29-fix2 < v0.9.30 -> true

v1.0.0-alpha2 < v1.0.0-beta1 -> true

v1.0.0 > v1.0.0-beta1 -> false

func WriteAllText

func WriteAllText(path, text string) error

WriteAllText 将给定text写入给定path

Types

type LocalHook added in v0.9.40

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

LocalHook logrus本地钩子

func NewLocalHook added in v0.9.40

func NewLocalHook(args any, consoleFormatter, fileFormatter logrus.Formatter, levels ...logrus.Level) *LocalHook

NewLocalHook 初始化本地日志钩子实现

func (*LocalHook) Fire added in v0.9.40

func (hook *LocalHook) Fire(entry *logrus.Entry) error

Fire ref: logrus/hooks.go impl Hook interface

func (*LocalHook) Levels added in v0.9.40

func (hook *LocalHook) Levels() []logrus.Level

Levels ref: logrus/hooks.go impl Hook interface

func (*LocalHook) SetFormatter added in v0.9.40

func (hook *LocalHook) SetFormatter(consoleFormatter, fileFormatter logrus.Formatter)

SetFormatter 设置日志格式

func (*LocalHook) SetPath added in v0.9.40

func (hook *LocalHook) SetPath(path string)

SetPath 设置日志写入路径

func (*LocalHook) SetWriter added in v0.9.40

func (hook *LocalHook) SetWriter(writer io.Writer)

SetWriter 设置Writer

type LogFormat added in v1.0.0

type LogFormat struct {
	EnableColor bool
}

LogFormat specialize for go-cqhttp

func (LogFormat) Format added in v1.0.0

func (f LogFormat) Format(entry *logrus.Entry) ([]byte, error)

Format implements logrus.Formatter

type MSG added in v0.9.34

type MSG = map[string]any

MSG 消息Map

Directories

Path Synopsis
Package terminal 包含用于检测在windows下是否通过双击运行go-cqhttp, 禁用快速编辑, 启用VT100的函数
Package terminal 包含用于检测在windows下是否通过双击运行go-cqhttp, 禁用快速编辑, 启用VT100的函数

Jump to

Keyboard shortcuts

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