mirror of
https://github.com/Mrs4s/go-cqhttp.git
synced 2025-05-04 19:17:37 +08:00
make lint happy
This commit is contained in:
parent
7b2d1fd573
commit
13325634c0
@ -15,18 +15,17 @@ import (
|
|||||||
"github.com/Mrs4s/MiraiGo/client"
|
"github.com/Mrs4s/MiraiGo/client"
|
||||||
"github.com/Mrs4s/MiraiGo/utils"
|
"github.com/Mrs4s/MiraiGo/utils"
|
||||||
"github.com/Mrs4s/MiraiGo/wrapper"
|
"github.com/Mrs4s/MiraiGo/wrapper"
|
||||||
"github.com/Mrs4s/go-cqhttp/internal/encryption"
|
|
||||||
_ "github.com/Mrs4s/go-cqhttp/internal/encryption/t544"
|
|
||||||
"github.com/mattn/go-colorable"
|
"github.com/mattn/go-colorable"
|
||||||
"github.com/pkg/errors"
|
"github.com/pkg/errors"
|
||||||
log "github.com/sirupsen/logrus"
|
log "github.com/sirupsen/logrus"
|
||||||
"github.com/tidwall/gjson"
|
"github.com/tidwall/gjson"
|
||||||
"gopkg.ilharper.com/x/isatty"
|
"gopkg.ilharper.com/x/isatty"
|
||||||
|
|
||||||
"github.com/Mrs4s/go-cqhttp/internal/base"
|
|
||||||
|
|
||||||
"github.com/Mrs4s/go-cqhttp/global"
|
"github.com/Mrs4s/go-cqhttp/global"
|
||||||
|
"github.com/Mrs4s/go-cqhttp/internal/base"
|
||||||
"github.com/Mrs4s/go-cqhttp/internal/download"
|
"github.com/Mrs4s/go-cqhttp/internal/download"
|
||||||
|
"github.com/Mrs4s/go-cqhttp/internal/encryption"
|
||||||
|
_ "github.com/Mrs4s/go-cqhttp/internal/encryption/t544" // side effect
|
||||||
)
|
)
|
||||||
|
|
||||||
var console = bufio.NewReader(os.Stdin)
|
var console = bufio.NewReader(os.Stdin)
|
||||||
|
@ -22,14 +22,13 @@ import (
|
|||||||
"golang.org/x/crypto/pbkdf2"
|
"golang.org/x/crypto/pbkdf2"
|
||||||
"golang.org/x/term"
|
"golang.org/x/term"
|
||||||
|
|
||||||
"github.com/Mrs4s/go-cqhttp/internal/download"
|
|
||||||
|
|
||||||
"github.com/Mrs4s/go-cqhttp/coolq"
|
"github.com/Mrs4s/go-cqhttp/coolq"
|
||||||
"github.com/Mrs4s/go-cqhttp/db"
|
"github.com/Mrs4s/go-cqhttp/db"
|
||||||
"github.com/Mrs4s/go-cqhttp/global"
|
"github.com/Mrs4s/go-cqhttp/global"
|
||||||
"github.com/Mrs4s/go-cqhttp/global/terminal"
|
"github.com/Mrs4s/go-cqhttp/global/terminal"
|
||||||
"github.com/Mrs4s/go-cqhttp/internal/base"
|
"github.com/Mrs4s/go-cqhttp/internal/base"
|
||||||
"github.com/Mrs4s/go-cqhttp/internal/cache"
|
"github.com/Mrs4s/go-cqhttp/internal/cache"
|
||||||
|
"github.com/Mrs4s/go-cqhttp/internal/download"
|
||||||
"github.com/Mrs4s/go-cqhttp/internal/selfdiagnosis"
|
"github.com/Mrs4s/go-cqhttp/internal/selfdiagnosis"
|
||||||
"github.com/Mrs4s/go-cqhttp/internal/selfupdate"
|
"github.com/Mrs4s/go-cqhttp/internal/selfupdate"
|
||||||
"github.com/Mrs4s/go-cqhttp/modules/servers"
|
"github.com/Mrs4s/go-cqhttp/modules/servers"
|
||||||
@ -168,51 +167,48 @@ func LoginInteract() {
|
|||||||
if !global.PathExists("password.encrypt") {
|
if !global.PathExists("password.encrypt") {
|
||||||
if base.Account.Password == "" {
|
if base.Account.Password == "" {
|
||||||
log.Error("无法进行加密,请在配置文件中的添加密码后重新启动.")
|
log.Error("无法进行加密,请在配置文件中的添加密码后重新启动.")
|
||||||
readLine()
|
} else {
|
||||||
os.Exit(0)
|
log.Infof("密码加密已启用, 请输入Key对密码进行加密: (Enter 提交)")
|
||||||
|
byteKey, _ = term.ReadPassword(int(os.Stdin.Fd()))
|
||||||
|
base.PasswordHash = md5.Sum([]byte(base.Account.Password))
|
||||||
|
_ = os.WriteFile("password.encrypt", []byte(PasswordHashEncrypt(base.PasswordHash[:], byteKey)), 0o644)
|
||||||
|
log.Info("密码已加密,为了您的账号安全,请删除配置文件中的密码后重新启动.")
|
||||||
}
|
}
|
||||||
log.Infof("密码加密已启用, 请输入Key对密码进行加密: (Enter 提交)")
|
|
||||||
byteKey, _ = term.ReadPassword(int(os.Stdin.Fd()))
|
|
||||||
base.PasswordHash = md5.Sum([]byte(base.Account.Password))
|
|
||||||
_ = os.WriteFile("password.encrypt", []byte(PasswordHashEncrypt(base.PasswordHash[:], byteKey)), 0o644)
|
|
||||||
log.Info("密码已加密,为了您的账号安全,请删除配置文件中的密码后重新启动.")
|
|
||||||
readLine()
|
readLine()
|
||||||
os.Exit(0)
|
os.Exit(0)
|
||||||
} else {
|
|
||||||
if base.Account.Password != "" {
|
|
||||||
log.Error("密码已加密,为了您的账号安全,请删除配置文件中的密码后重新启动.")
|
|
||||||
readLine()
|
|
||||||
os.Exit(0)
|
|
||||||
}
|
|
||||||
|
|
||||||
if len(byteKey) == 0 {
|
|
||||||
log.Infof("密码加密已启用, 请输入Key对密码进行解密以继续: (Enter 提交)")
|
|
||||||
cancel := make(chan struct{}, 1)
|
|
||||||
state, _ := term.GetState(int(os.Stdin.Fd()))
|
|
||||||
go func() {
|
|
||||||
select {
|
|
||||||
case <-cancel:
|
|
||||||
return
|
|
||||||
case <-time.After(time.Second * 45):
|
|
||||||
log.Infof("解密key输入超时")
|
|
||||||
time.Sleep(3 * time.Second)
|
|
||||||
_ = term.Restore(int(os.Stdin.Fd()), state)
|
|
||||||
os.Exit(0)
|
|
||||||
}
|
|
||||||
}()
|
|
||||||
byteKey, _ = term.ReadPassword(int(os.Stdin.Fd()))
|
|
||||||
cancel <- struct{}{}
|
|
||||||
} else {
|
|
||||||
log.Infof("密码加密已启用, 使用运行时传递的参数进行解密,按 Ctrl+C 取消.")
|
|
||||||
}
|
|
||||||
|
|
||||||
encrypt, _ := os.ReadFile("password.encrypt")
|
|
||||||
ph, err := PasswordHashDecrypt(string(encrypt), byteKey)
|
|
||||||
if err != nil {
|
|
||||||
log.Fatalf("加密存储的密码损坏,请尝试重新配置密码")
|
|
||||||
}
|
|
||||||
copy(base.PasswordHash[:], ph)
|
|
||||||
}
|
}
|
||||||
|
if base.Account.Password != "" {
|
||||||
|
log.Error("密码已加密,为了您的账号安全,请删除配置文件中的密码后重新启动.")
|
||||||
|
readLine()
|
||||||
|
os.Exit(0)
|
||||||
|
}
|
||||||
|
if len(byteKey) == 0 {
|
||||||
|
log.Infof("密码加密已启用, 请输入Key对密码进行解密以继续: (Enter 提交)")
|
||||||
|
cancel := make(chan struct{}, 1)
|
||||||
|
state, _ := term.GetState(int(os.Stdin.Fd()))
|
||||||
|
go func() {
|
||||||
|
select {
|
||||||
|
case <-cancel:
|
||||||
|
return
|
||||||
|
case <-time.After(time.Second * 45):
|
||||||
|
log.Infof("解密key输入超时")
|
||||||
|
time.Sleep(3 * time.Second)
|
||||||
|
_ = term.Restore(int(os.Stdin.Fd()), state)
|
||||||
|
os.Exit(0)
|
||||||
|
}
|
||||||
|
}()
|
||||||
|
byteKey, _ = term.ReadPassword(int(os.Stdin.Fd()))
|
||||||
|
cancel <- struct{}{}
|
||||||
|
} else {
|
||||||
|
log.Infof("密码加密已启用, 使用运行时传递的参数进行解密,按 Ctrl+C 取消.")
|
||||||
|
}
|
||||||
|
|
||||||
|
encrypt, _ := os.ReadFile("password.encrypt")
|
||||||
|
ph, err := PasswordHashDecrypt(string(encrypt), byteKey)
|
||||||
|
if err != nil {
|
||||||
|
log.Fatalf("加密存储的密码损坏,请尝试重新配置密码")
|
||||||
|
}
|
||||||
|
copy(base.PasswordHash[:], ph)
|
||||||
} else if len(base.Account.Password) > 0 {
|
} else if len(base.Account.Password) > 0 {
|
||||||
base.PasswordHash = md5.Sum([]byte(base.Account.Password))
|
base.PasswordHash = md5.Sum([]byte(base.Account.Password))
|
||||||
}
|
}
|
||||||
|
@ -28,7 +28,7 @@ func (bot *CQBot) CQGetVersion() global.MSG {
|
|||||||
//
|
//
|
||||||
// @route12(send_message)
|
// @route12(send_message)
|
||||||
// @rename(m->message)
|
// @rename(m->message)
|
||||||
func (bot *CQBot) CQSendMessageV12(groupID, userID, detailType string, m gjson.Result) global.MSG {
|
func (bot *CQBot) CQSendMessageV12(groupID, userID, detailType string, m gjson.Result) global.MSG { // nolint
|
||||||
// TODO: implement
|
// TODO: implement
|
||||||
return OK(nil)
|
return OK(nil)
|
||||||
}
|
}
|
||||||
|
@ -136,7 +136,7 @@ func (bot *CQBot) groupMessageEvent(c *client.QQClient, m *message.GroupMessage)
|
|||||||
bot.dispatch(gm)
|
bot.dispatch(gm)
|
||||||
}
|
}
|
||||||
|
|
||||||
func (bot *CQBot) tempMessageEvent(c *client.QQClient, e *client.TempMessageEvent) {
|
func (bot *CQBot) tempMessageEvent(_ *client.QQClient, e *client.TempMessageEvent) {
|
||||||
m := e.Message
|
m := e.Message
|
||||||
bot.checkMedia(m.Elements, m.Sender.Uin)
|
bot.checkMedia(m.Elements, m.Sender.Uin)
|
||||||
source := message.Source{
|
source := message.Source{
|
||||||
@ -491,7 +491,7 @@ func (bot *CQBot) leaveGroupEvent(c *client.QQClient, e *client.GroupLeaveEvent)
|
|||||||
bot.dispatch(bot.groupDecrease(e.Group.Code, c.Uin, e.Operator))
|
bot.dispatch(bot.groupDecrease(e.Group.Code, c.Uin, e.Operator))
|
||||||
}
|
}
|
||||||
|
|
||||||
func (bot *CQBot) memberPermissionChangedEvent(c *client.QQClient, e *client.MemberPermissionChangedEvent) {
|
func (bot *CQBot) memberPermissionChangedEvent(_ *client.QQClient, e *client.MemberPermissionChangedEvent) {
|
||||||
st := "unset"
|
st := "unset"
|
||||||
if e.NewPermission == client.Administrator {
|
if e.NewPermission == client.Administrator {
|
||||||
st = "set"
|
st = "set"
|
||||||
@ -502,7 +502,7 @@ func (bot *CQBot) memberPermissionChangedEvent(c *client.QQClient, e *client.Mem
|
|||||||
})
|
})
|
||||||
}
|
}
|
||||||
|
|
||||||
func (bot *CQBot) memberCardUpdatedEvent(c *client.QQClient, e *client.MemberCardUpdatedEvent) {
|
func (bot *CQBot) memberCardUpdatedEvent(_ *client.QQClient, e *client.MemberCardUpdatedEvent) {
|
||||||
log.Infof("群 %v 的 %v 更新了名片 %v -> %v", formatGroupName(e.Group), formatMemberName(e.Member), e.OldCard, e.Member.CardName)
|
log.Infof("群 %v 的 %v 更新了名片 %v -> %v", formatGroupName(e.Group), formatMemberName(e.Member), e.OldCard, e.Member.CardName)
|
||||||
bot.dispatchEvent("notice/group_card", global.MSG{
|
bot.dispatchEvent("notice/group_card", global.MSG{
|
||||||
"group_id": e.Group.Code,
|
"group_id": e.Group.Code,
|
||||||
@ -526,7 +526,7 @@ func (bot *CQBot) memberLeaveEvent(_ *client.QQClient, e *client.MemberLeaveGrou
|
|||||||
bot.dispatch(bot.groupDecrease(e.Group.Code, e.Member.Uin, e.Operator))
|
bot.dispatch(bot.groupDecrease(e.Group.Code, e.Member.Uin, e.Operator))
|
||||||
}
|
}
|
||||||
|
|
||||||
func (bot *CQBot) friendRequestEvent(c *client.QQClient, e *client.NewFriendRequest) {
|
func (bot *CQBot) friendRequestEvent(_ *client.QQClient, e *client.NewFriendRequest) {
|
||||||
log.Infof("收到来自 %v(%v) 的好友请求: %v", e.RequesterNick, e.RequesterUin, e.Message)
|
log.Infof("收到来自 %v(%v) 的好友请求: %v", e.RequesterNick, e.RequesterUin, e.Message)
|
||||||
flag := strconv.FormatInt(e.RequestId, 10)
|
flag := strconv.FormatInt(e.RequestId, 10)
|
||||||
bot.friendReqCache.Store(flag, e)
|
bot.friendReqCache.Store(flag, e)
|
||||||
@ -537,7 +537,7 @@ func (bot *CQBot) friendRequestEvent(c *client.QQClient, e *client.NewFriendRequ
|
|||||||
})
|
})
|
||||||
}
|
}
|
||||||
|
|
||||||
func (bot *CQBot) friendAddedEvent(c *client.QQClient, e *client.NewFriendEvent) {
|
func (bot *CQBot) friendAddedEvent(_ *client.QQClient, e *client.NewFriendEvent) {
|
||||||
log.Infof("添加了新好友: %v(%v)", e.Friend.Nickname, e.Friend.Uin)
|
log.Infof("添加了新好友: %v(%v)", e.Friend.Nickname, e.Friend.Uin)
|
||||||
bot.tempSessionCache.Delete(e.Friend.Uin)
|
bot.tempSessionCache.Delete(e.Friend.Uin)
|
||||||
bot.dispatchEvent("notice/friend_add", global.MSG{
|
bot.dispatchEvent("notice/friend_add", global.MSG{
|
||||||
@ -545,7 +545,7 @@ func (bot *CQBot) friendAddedEvent(c *client.QQClient, e *client.NewFriendEvent)
|
|||||||
})
|
})
|
||||||
}
|
}
|
||||||
|
|
||||||
func (bot *CQBot) groupInvitedEvent(c *client.QQClient, e *client.GroupInvitedRequest) {
|
func (bot *CQBot) groupInvitedEvent(_ *client.QQClient, e *client.GroupInvitedRequest) {
|
||||||
log.Infof("收到来自群 %v(%v) 内用户 %v(%v) 的加群邀请.", e.GroupName, e.GroupCode, e.InvitorNick, e.InvitorUin)
|
log.Infof("收到来自群 %v(%v) 内用户 %v(%v) 的加群邀请.", e.GroupName, e.GroupCode, e.InvitorNick, e.InvitorUin)
|
||||||
flag := strconv.FormatInt(e.RequestId, 10)
|
flag := strconv.FormatInt(e.RequestId, 10)
|
||||||
bot.dispatchEvent("request/group/invite", global.MSG{
|
bot.dispatchEvent("request/group/invite", global.MSG{
|
||||||
@ -557,7 +557,7 @@ func (bot *CQBot) groupInvitedEvent(c *client.QQClient, e *client.GroupInvitedRe
|
|||||||
})
|
})
|
||||||
}
|
}
|
||||||
|
|
||||||
func (bot *CQBot) groupJoinReqEvent(c *client.QQClient, e *client.UserJoinGroupRequest) {
|
func (bot *CQBot) groupJoinReqEvent(_ *client.QQClient, e *client.UserJoinGroupRequest) {
|
||||||
log.Infof("群 %v(%v) 收到来自用户 %v(%v) 的加群请求.", e.GroupName, e.GroupCode, e.RequesterNick, e.RequesterUin)
|
log.Infof("群 %v(%v) 收到来自用户 %v(%v) 的加群请求.", e.GroupName, e.GroupCode, e.RequesterNick, e.RequesterUin)
|
||||||
flag := strconv.FormatInt(e.RequestId, 10)
|
flag := strconv.FormatInt(e.RequestId, 10)
|
||||||
bot.dispatchEvent("request/group/add", global.MSG{
|
bot.dispatchEvent("request/group/add", global.MSG{
|
||||||
@ -569,7 +569,7 @@ func (bot *CQBot) groupJoinReqEvent(c *client.QQClient, e *client.UserJoinGroupR
|
|||||||
})
|
})
|
||||||
}
|
}
|
||||||
|
|
||||||
func (bot *CQBot) otherClientStatusChangedEvent(c *client.QQClient, e *client.OtherClientStatusChangedEvent) {
|
func (bot *CQBot) otherClientStatusChangedEvent(_ *client.QQClient, e *client.OtherClientStatusChangedEvent) {
|
||||||
if e.Online {
|
if e.Online {
|
||||||
log.Infof("Bot 账号在客户端 %v (%v) 登录.", e.Client.DeviceName, e.Client.DeviceKind)
|
log.Infof("Bot 账号在客户端 %v (%v) 登录.", e.Client.DeviceName, e.Client.DeviceKind)
|
||||||
} else {
|
} else {
|
||||||
|
@ -10,7 +10,7 @@ import (
|
|||||||
"github.com/tidwall/gjson"
|
"github.com/tidwall/gjson"
|
||||||
)
|
)
|
||||||
|
|
||||||
func TestParseString(t *testing.T) {
|
func TestParseString(_ *testing.T) {
|
||||||
// TODO: add more text
|
// TODO: add more text
|
||||||
for _, v := range ParseString(`[CQ:face,id=115,text=111][CQ:face,id=217]] [CQ:text,text=123] [`) {
|
for _, v := range ParseString(`[CQ:face,id=115,text=111][CQ:face,id=217]] [CQ:text,text=123] [`) {
|
||||||
fmt.Println(v)
|
fmt.Println(v)
|
||||||
|
Loading…
x
Reference in New Issue
Block a user