Documentation ¶
Overview ¶
Package global 包含文件下载,视频音频编码,本地文件缓存处理,消息过滤器,调用速率限制,gocq主配置等的相关函数与结构体
Index ¶
- Constants
- func Check(err error, deleteSession bool)
- func DelFile(path string) bool
- func EncodeMP4(src string, dst string) error
- func EncoderSilk(data []byte) ([]byte, error)
- func ExtractCover(src string, target string) error
- func FindFile(file, cache, p string) (data []byte, err error)
- func GetLogLevel(level string) []logrus.Level
- func GetLogLevelColorCode(level logrus.Level) string
- func IsAMRorSILK(b []byte) bool
- func NeteaseMusicSongInfo(id string) (gjson.Result, error)
- func NewBuffer() *bytes.Buffer
- func PathExists(path string) bool
- func PutBuffer(buf *bytes.Buffer)
- func QQMusicSongInfo(id string) (gjson.Result, error)
- func ReadAddrFile(path string) []netip.AddrPort
- func ReadAllText(path string) string
- func SetupMainSignalHandler() <-chan struct{}
- func VersionNameCompare(current, remote string) bool
- func WriteAllText(path, text string) error
- type LocalHook
- type LogFormat
- type MSG
Constants ¶
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 EncoderSilk ¶ added in v0.9.38
EncoderSilk 将音频编码为Silk
func ExtractCover ¶ added in v0.9.38
ExtractCover 获取给定视频文件的Cover
func FindFile ¶ added in v0.9.26
FindFile 从给定的File寻找文件,并返回文件byte数组。File是一个合法的URL。p为文件寻找位置。 对于HTTP/HTTPS形式的URL,Cache为"1"或空时表示启用缓存
func GetLogLevel ¶ added in v0.9.40
GetLogLevel 获取日志等级
可能的值有
"trace","debug","info","warn","warn","error"
func GetLogLevelColorCode ¶ added in v1.0.0
GetLogLevelColorCode 获取日志等级对应色彩code
func NeteaseMusicSongInfo ¶ added in v0.9.22
NeteaseMusicSongInfo 通过给定id在wdd音乐上查找曲目信息
func QQMusicSongInfo ¶ added in v0.9.21
QQMusicSongInfo 通过给定id在QQ音乐上查找曲目信息
func ReadAddrFile ¶ added in v0.9.31
ReadAddrFile 从给定path中读取合法的IP地址与端口,每个IP地址以换行符"\n"作为分隔
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
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
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) SetFormatter ¶ added in v0.9.40
SetFormatter 设置日志格式