Skip to content

Commit

Permalink
Merge pull request #426 from Ink-33/master
Browse files Browse the repository at this point in the history
Fix: set_restart api panic
  • Loading branch information
Mrs4s authored Nov 18, 2020
2 parents 8f76558 + 64b1a22 commit 03c3340
Show file tree
Hide file tree
Showing 2 changed files with 7 additions and 9 deletions.
4 changes: 2 additions & 2 deletions coolq/cqcode.go
Original file line number Diff line number Diff line change
Expand Up @@ -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"},
}}
Expand Down
12 changes: 5 additions & 7 deletions main.go
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,6 @@ package main

import (
"bufio"
"context"
"crypto/md5"
"encoding/base64"
"encoding/json"
Expand Down Expand Up @@ -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 取消.")
}
Expand Down Expand Up @@ -328,7 +327,6 @@ func main() {
b.Release()
case <-r:
log.Info("正在重启中...")
server.HttpServer.ShutDown()
defer b.Release()
restart(arg)
}
Expand Down

0 comments on commit 03c3340

Please sign in to comment.