fix 测试新增导致CK清空问题

This commit is contained in:
ZJY 2021-09-16 01:16:04 +08:00
parent 359438ec65
commit 4a621d3867
2 changed files with 30 additions and 56 deletions

View File

@ -201,6 +201,7 @@ func CookieOK(ck *JdCookie) bool {
switch ui.Retcode {
case "1001": //ck.BeanNum
if ui.Msg == "not login" {
if ck.Available == True {
ck.Push(fmt.Sprintf("失效账号,%s", ck.PtPin))
ck.Update(Available, false)

View File

@ -105,28 +105,22 @@ var handleMessage = func(msgs ...interface{}) interface{} {
}
}
{
if strings.Contains(msg, "wskey=") {
rsp := cmd(fmt.Sprintf(`python3 test.py "%s"`, msg), &Sender{})
logs.Info(rsp)
ss1 := regexp.MustCompile(`pin=([^;=\s]+);wskey=([^;=\s]+)`).FindAllStringSubmatch(msg, -1)
if strings.Contains(rsp, "错误") {
logs.Error("wskey错误")
sender.Reply(fmt.Sprintf("wskey错误"))
} else {
if len(ss1) > 0 {
for _, s := range ss1 {
ck := JdCookie{
PtPin: s[1],
PtKey: rsp,
WsKey: s[2],
}
ss := regexp.MustCompile(`pt_key=([^;=\s]+);pt_pin=([^;=\s]+)`).FindAllStringSubmatch(rsp, -1)
for _, s1 := range ss {
ck.PtPin = s1[2]
ck.PtKey = s1[1]
}
ss := regexp.MustCompile(`pin=([^;=\s]+);wskey=([^;=\s]+)`).FindAllStringSubmatch(msg, -1)
if len(ss) > 0 {
for _, s := range ss {
rsp := cmd(fmt.Sprintf(`python3 test.py "%s"`, s), &Sender{})
if strings.Contains(rsp, "错误") {
logs.Error("wskey错误")
sender.Reply(fmt.Sprintf("wskey错误"))
} else {
ptKey := FetchJdCookieValue("pt_key", rsp)
ptPin := FetchJdCookieValue("pt_pin", rsp)
ck := JdCookie{
PtPin: ptPin,
PtKey: ptKey,
WsKey: s[2],
}
if CookieOK(&ck) {
if sender.IsQQ() {
ck.QQ = sender.UserID
@ -135,45 +129,21 @@ var handleMessage = func(msgs ...interface{}) interface{} {
}
if nck, err := GetJdCookie(ck.PtPin); err == nil {
nck.InPool(ck.PtKey)
if nck.WsKey == "" || len(nck.WsKey) == 0 {
nck.Updates(JdCookie{
WsKey: ck.WsKey,
})
if sender.IsQQ() {
ck.Update(QQ, ck.QQ)
}
nck.Update(PtKey, ck.PtKey)
msg := fmt.Sprintf("写入WsKey并更新账号%s", ck.PtPin)
sender.Reply(fmt.Sprintf(msg))
(&JdCookie{}).Push(msg)
logs.Info(msg)
} else {
if nck.WsKey == ck.WsKey {
msg := fmt.Sprintf("重复写入")
sender.Reply(fmt.Sprintf(msg))
(&JdCookie{}).Push(msg)
logs.Info(msg)
} else {
nck.Updates(JdCookie{
WsKey: ck.WsKey,
})
msg := fmt.Sprintf("更新WsKey并更新账号%s", ck.PtPin)
sender.Reply(fmt.Sprintf(msg))
(&JdCookie{}).Push(msg)
logs.Info(msg)
}
}
} else {
NewJdCookie(&ck)
msg := fmt.Sprintf("添加账号,用户名:%s", ck.PtPin)
msg := fmt.Sprintf("更新账号,%s", ck.PtPin)
if sender.IsQQ() {
ck.Update(QQ, ck.QQ)
}
sender.Reply(fmt.Sprintf(msg))
(&JdCookie{}).Push(msg)
} else {
NewJdCookie(&ck)
msg := fmt.Sprintf("添加账号,账号名:%s", ck.PtPin)
if sender.IsQQ() {
ck.Update(QQ, ck.QQ)
}
sender.Reply(fmt.Sprintf(msg))
(&JdCookie{}).Push(msg)
logs.Info(msg)
}
}
go func() {
Save <- &JdCookie{}
@ -181,7 +151,6 @@ var handleMessage = func(msgs ...interface{}) interface{} {
return nil
}
}
}
}
{ //tyt
@ -246,6 +215,10 @@ var handleMessage = func(msgs ...interface{}) interface{} {
sender.Reply(fmt.Sprintf("无效"))
}
}
go func() {
Save <- &JdCookie{}
}()
return nil
}
}
{ //