utils

package
v0.9.25-0...-7aecb6b Latest Latest
Warning

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

Go to latest
Published: Feb 14, 2021 License: AGPL-3.0 Imports: 27 Imported by: 0

Documentation

Index

Constants

View Source
const (
	//ImagePath go-cqhttp使用的图片缓存目录
	ImagePath = "data/images"
	//ImagePathOld 兼容旧版go-cqhtto使用的图片缓存目录
	ImagePathOld = "data/image"
	//VoicePath go-cqhttp使用的语音缓存目录
	VoicePath = "data/voices"
	//VoicePathOld 兼容旧版go-cqhtto使用的语音缓存目录
	VoicePathOld = "data/record"
	//VideoPath go-cqhttp使用的视频缓存目录
	VideoPath = "data/videos"
	//CachePath go-cqhttp使用的缓存目录
	CachePath = "data/cache"
)

Variables

View Source
var (
	//ErrSyntax Path语法错误时返回的错误
	ErrSyntax = errors.New("syntax error")
	//HeaderAmr AMR文件头
	HeaderAmr = []byte("#!AMR")
	//HeaderSilk Silkv3文件头
	HeaderSilk = []byte("\x02#!SILK_V3")
)
View Source
var (

	//Proxy 存储Config.proxy_rewrite,用于设置代理
	Proxy string

	//ErrOverSize 响应主体过大时返回此错误
	ErrOverSize = errors.New("oversize")

	//UserAgent HTTP请求时使用的UA
	UserAgent = "" /* 130-byte string literal not displayed */
)

Functions

func DownloadFile

func DownloadFile(url, path string, limit int64, headers map[string]string) error

DownloadFile 将给定URL对应的文件下载至给定Path

func DownloadFileMultiThreading

func DownloadFileMultiThreading(url, path string, limit int64, threadCount int, headers map[string]string) error

DownloadFileMultiThreading 使用threadCount个线程将给定URL对应的文件下载至给定Path

func EncodeMP4

func EncodeMP4(src string, dst string) error

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

func EncoderSilk

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

EncoderSilk 将音频编码为Silk

func EnsureBool

func EnsureBool(p interface{}, defaultVal bool) bool

EnsureBool 判断给定的p是否可表示为合法Bool类型,否则返回defaultVal

支持的合法类型有

type bool

type gjson.True or gjson.False

type string "true","yes","1" or "false","no","0" (case insensitive)

func ExtractCover

func ExtractCover(src string, target string) error

ExtractCover 获取给定视频文件的Cover

func FindFile

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

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

func GetBytes

func GetBytes(url string) ([]byte, error)

GetBytes 对给定URL发送Get请求,返回响应主体

func GetSliderTicket

func GetSliderTicket(raw, id string) (string, error)

GetSliderTicket 通过给定的验证链接raw和id,获取验证结果Ticket

func InitCodec

func InitCodec()

InitCodec 初始化Silk编码器

func IsAMRorSILK

func IsAMRorSILK(b []byte) bool

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

func NeteaseMusicSongInfo

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

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

func PathExists

func PathExists(path string) bool

PathExists 判断给定path是否存在

func QQMusicSongInfo

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

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

func ReadAllText

func ReadAllText(path string) string

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

func SplitURL

func SplitURL(s string) []string

SplitURL 将给定URL字符串分割为两部分,用于URL预处理防止风控

Types

This section is empty.

Directories

Path Synopsis

Jump to

Keyboard shortcuts

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