From 83e0aaa0f8aa2928f72c12f04ef0826ea7de15f4 Mon Sep 17 00:00:00 2001 From: Ink-33 Date: Wed, 18 Nov 2020 01:31:45 +0800 Subject: [PATCH 1/3] Fix: set_restart api panic --- main.go | 1 - 1 file changed, 1 deletion(-) diff --git a/main.go b/main.go index b09ece5..da2ac3d 100644 --- a/main.go +++ b/main.go @@ -328,7 +328,6 @@ func main() { b.Release() case <-r: log.Info("正在重启中...") - server.HttpServer.ShutDown() defer b.Release() restart(arg) } From b2be595fb892a7c4f48968ae2172516f038a3fee Mon Sep 17 00:00:00 2001 From: Ink-33 Date: Wed, 18 Nov 2020 22:33:51 +0800 Subject: [PATCH 2/3] simplifies composite literals --- coolq/cqcode.go | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/coolq/cqcode.go b/coolq/cqcode.go index 761446f..b0aafd6 100644 --- a/coolq/cqcode.go +++ b/coolq/cqcode.go @@ -184,12 +184,12 @@ func ToArrayMessage(e []message.IMessageElement, code int64, raw ...bool) (r []M } } case *message.GroupFlashImgElement: - return []MSG{MSG{ + return []MSG{{ "type": "image", "data": map[string]string{"file": o.Filename, "type": "flash"}, }} case *message.FriendFlashImgElement: - return []MSG{MSG{ + return []MSG{{ "type": "image", "data": map[string]string{"file": o.Filename, "type": "flash"}, }} From 64b1a223cc733693525e73540179f89c8989eb90 Mon Sep 17 00:00:00 2001 From: Ink-33 Date: Wed, 18 Nov 2020 22:46:52 +0800 Subject: [PATCH 3/3] Fix #427 --- main.go | 11 +++++------ 1 file changed, 5 insertions(+), 6 deletions(-) diff --git a/main.go b/main.go index da2ac3d..c0f9802 100644 --- a/main.go +++ b/main.go @@ -2,7 +2,6 @@ package main import ( "bufio" - "context" "crypto/md5" "encoding/base64" "encoding/json" @@ -236,19 +235,19 @@ func main() { if conf.PasswordEncrypted != "" { if strKey == "" { log.Infof("密码加密已启用, 请输入Key对密码进行解密以继续: (Enter 提交)") - ctx := context.Background() - go func(ctx context.Context) { + cancel := make(chan struct{}, 1) + go func() { select { - case <-ctx.Done(): + case <-cancel: return case <-time.After(time.Second * 45): log.Infof("解密key输入超时") time.Sleep(3 * time.Second) os.Exit(0) } - }(ctx) + }() strKey, _ = console.ReadString('\n') - ctx.Done() + cancel <- struct{}{} } else { log.Infof("密码加密已启用, 使用运行时传递的参数进行解密,按 Ctrl+C 取消.") }