1
0
mirror of https://github.com/Mrs4s/go-cqhttp.git synced 2025-05-05 11:33:48 +08:00

Merge pull request #426 from Ink-33/master

Fix: set_restart api panic
This commit is contained in:
Mrs4s 2020-11-19 00:22:56 +08:00 committed by GitHub
commit 03c3340954
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
2 changed files with 7 additions and 9 deletions

View File

@ -184,12 +184,12 @@ func ToArrayMessage(e []message.IMessageElement, code int64, raw ...bool) (r []M
} }
} }
case *message.GroupFlashImgElement: case *message.GroupFlashImgElement:
return []MSG{MSG{ return []MSG{{
"type": "image", "type": "image",
"data": map[string]string{"file": o.Filename, "type": "flash"}, "data": map[string]string{"file": o.Filename, "type": "flash"},
}} }}
case *message.FriendFlashImgElement: case *message.FriendFlashImgElement:
return []MSG{MSG{ return []MSG{{
"type": "image", "type": "image",
"data": map[string]string{"file": o.Filename, "type": "flash"}, "data": map[string]string{"file": o.Filename, "type": "flash"},
}} }}

12
main.go
View File

@ -2,7 +2,6 @@ package main
import ( import (
"bufio" "bufio"
"context"
"crypto/md5" "crypto/md5"
"encoding/base64" "encoding/base64"
"encoding/json" "encoding/json"
@ -236,19 +235,19 @@ func main() {
if conf.PasswordEncrypted != "" { if conf.PasswordEncrypted != "" {
if strKey == "" { if strKey == "" {
log.Infof("密码加密已启用, 请输入Key对密码进行解密以继续: (Enter 提交)") log.Infof("密码加密已启用, 请输入Key对密码进行解密以继续: (Enter 提交)")
ctx := context.Background() cancel := make(chan struct{}, 1)
go func(ctx context.Context) { go func() {
select { select {
case <-ctx.Done(): case <-cancel:
return return
case <-time.After(time.Second * 45): case <-time.After(time.Second * 45):
log.Infof("解密key输入超时") log.Infof("解密key输入超时")
time.Sleep(3 * time.Second) time.Sleep(3 * time.Second)
os.Exit(0) os.Exit(0)
} }
}(ctx) }()
strKey, _ = console.ReadString('\n') strKey, _ = console.ReadString('\n')
ctx.Done() cancel <- struct{}{}
} else { } else {
log.Infof("密码加密已启用, 使用运行时传递的参数进行解密,按 Ctrl+C 取消.") log.Infof("密码加密已启用, 使用运行时传递的参数进行解密,按 Ctrl+C 取消.")
} }
@ -328,7 +327,6 @@ func main() {
b.Release() b.Release()
case <-r: case <-r:
log.Info("正在重启中...") log.Info("正在重启中...")
server.HttpServer.ShutDown()
defer b.Release() defer b.Release()
restart(arg) restart(arg)
} }