mirror of
https://github.com/Mrs4s/go-cqhttp.git
synced 2025-05-04 19:17:37 +08:00
Merge branch 'master' of https://github.com/Mrs4s/go-cqhttp
This commit is contained in:
commit
b545e05a9d
@ -191,7 +191,7 @@ func (bot *CQBot) dispatchEventMessage(m MSG) {
|
||||
fn(m)
|
||||
end := time.Now()
|
||||
if end.Sub(start) > time.Second*5 {
|
||||
log.Debugf("警告: 事件处理耗时超过 5 秒 (%v秒), 请检查应用是否有堵塞.", end.Sub(start)/time.Second)
|
||||
log.Debugf("警告: 事件处理耗时超过 5 秒 (%v), 请检查应用是否有堵塞.", end.Sub(start))
|
||||
}
|
||||
}()
|
||||
}
|
||||
|
@ -8,7 +8,6 @@ import (
|
||||
"github.com/Mrs4s/go-cqhttp/global"
|
||||
log "github.com/sirupsen/logrus"
|
||||
"io/ioutil"
|
||||
"os"
|
||||
"path"
|
||||
"strconv"
|
||||
"strings"
|
||||
@ -374,7 +373,7 @@ func (bot *CQBot) checkMedia(e []message.IMessageElement) {
|
||||
w.WriteUInt32(uint32(i.Size))
|
||||
w.WriteString(i.Filename)
|
||||
w.WriteString(i.Url)
|
||||
}), os.ModePerm)
|
||||
}), 0644)
|
||||
}
|
||||
i.Filename = filename
|
||||
case *message.VoiceElement:
|
||||
@ -386,7 +385,7 @@ func (bot *CQBot) checkMedia(e []message.IMessageElement) {
|
||||
log.Warnf("语音文件 %v 下载失败: %v", i.Name, err)
|
||||
continue
|
||||
}
|
||||
_ = ioutil.WriteFile(path.Join(global.VOICE_PATH, i.Name), b, os.ModePerm)
|
||||
_ = ioutil.WriteFile(path.Join(global.VOICE_PATH, i.Name), b, 0644)
|
||||
}
|
||||
case *message.ShortVideoElement:
|
||||
filename := hex.EncodeToString(i.Md5) + ".video"
|
||||
@ -396,7 +395,7 @@ func (bot *CQBot) checkMedia(e []message.IMessageElement) {
|
||||
w.WriteUInt32(uint32(i.Size))
|
||||
w.WriteString(i.Name)
|
||||
w.Write(i.Uuid)
|
||||
}), os.ModePerm)
|
||||
}), 0644)
|
||||
}
|
||||
i.Name = filename
|
||||
i.Url = bot.Client.GetShortVideoUrl(i.Uuid, i.Md5)
|
||||
|
@ -27,7 +27,7 @@ func ReadAllText(path string) string {
|
||||
}
|
||||
|
||||
func WriteAllText(path, text string) {
|
||||
_ = ioutil.WriteFile(path, []byte(text), 0777)
|
||||
_ = ioutil.WriteFile(path, []byte(text), 0644)
|
||||
}
|
||||
|
||||
func Check(err error) {
|
||||
|
10
main.go
10
main.go
@ -37,17 +37,17 @@ func init() {
|
||||
log.SetOutput(io.MultiWriter(os.Stderr, w))
|
||||
}
|
||||
if !global.PathExists(global.IMAGE_PATH) {
|
||||
if err := os.MkdirAll(global.IMAGE_PATH, os.ModePerm); err != nil {
|
||||
if err := os.MkdirAll(global.IMAGE_PATH, 0755); err != nil {
|
||||
log.Fatalf("创建图片缓存文件夹失败: %v", err)
|
||||
}
|
||||
}
|
||||
if !global.PathExists(global.VOICE_PATH) {
|
||||
if err := os.MkdirAll(global.VOICE_PATH, os.ModePerm); err != nil {
|
||||
if err := os.MkdirAll(global.VOICE_PATH, 0755); err != nil {
|
||||
log.Fatalf("创建语音缓存文件夹失败: %v", err)
|
||||
}
|
||||
}
|
||||
if !global.PathExists(global.VIDEO_PATH) {
|
||||
if err := os.MkdirAll(global.VIDEO_PATH, os.ModePerm); err != nil {
|
||||
if err := os.MkdirAll(global.VIDEO_PATH, 0755); err != nil {
|
||||
log.Fatalf("创建视频缓存文件夹失败: %v", err)
|
||||
}
|
||||
}
|
||||
@ -135,7 +135,7 @@ func main() {
|
||||
if !global.PathExists("device.json") {
|
||||
log.Warn("虚拟设备信息不存在, 将自动生成随机设备.")
|
||||
client.GenRandomDevice()
|
||||
_ = ioutil.WriteFile("device.json", client.SystemDeviceInfo.ToJson(), os.ModePerm)
|
||||
_ = ioutil.WriteFile("device.json", client.SystemDeviceInfo.ToJson(), 0644)
|
||||
log.Info("已生成设备信息并保存到 device.json 文件.")
|
||||
} else {
|
||||
log.Info("将使用 device.json 内的设备信息运行Bot.")
|
||||
@ -171,7 +171,7 @@ func main() {
|
||||
if !rsp.Success {
|
||||
switch rsp.Error {
|
||||
case client.NeedCaptcha:
|
||||
_ = ioutil.WriteFile("captcha.jpg", rsp.CaptchaImage, os.ModePerm)
|
||||
_ = ioutil.WriteFile("captcha.jpg", rsp.CaptchaImage, 0644)
|
||||
img, _, _ := image.Decode(bytes.NewReader(rsp.CaptchaImage))
|
||||
fmt.Println(asciiart.New("image", img).Art)
|
||||
log.Warn("请输入验证码 (captcha.jpg): (Enter 提交)")
|
||||
|
Loading…
x
Reference in New Issue
Block a user