diff --git a/models/available.go b/models/available.go index ae6734a..9fd308c 100644 --- a/models/available.go +++ b/models/available.go @@ -146,46 +146,82 @@ func updateCookie() { var pinky = fmt.Sprintf("pin=%s;wskey=%s;", ck.PtPin, ck.WsKey) rsp := cmd(fmt.Sprintf(`python3 test.py "%s"`, pinky), &Sender{}) logs.Info(rsp) + ss := regexp.MustCompile(`pt_key=([^;=\s]+);pt_pin=([^;=\s]+)`).FindAllStringSubmatch(rsp, -1) + if len(ss) > 0 { + + xyb := 0 + for _, s := range ss { + ck := JdCookie{ + PtKey: s[1], + PtPin: s[2], + } + if CookieOK(&ck) { + xyb++ + if HasKey(ck.PtKey) { + (&JdCookie{}).Push(fmt.Sprintf("重复提交")) + } else { + if nck, err := GetJdCookie(ck.PtPin); err == nil { + nck.InPool(ck.PtKey) + msg := fmt.Sprintf("定时更新账号,%s", ck.PtPin) + (&JdCookie{}).Push(msg) + logs.Info(msg) + } else { + NewJdCookie(&ck) + msg := fmt.Sprintf("添加账号,账号名:%s", ck.PtPin) + logs.Info(msg) + } + } + } else { + (&JdCookie{}).Push(fmt.Sprintf("无效CK转换失败,%s", ck.PtPin)) + } + } + } else { + (&JdCookie{}).Push(fmt.Sprintf("Wskey失效,%s", ck.PtPin)) + } + go func() { + Save <- &JdCookie{} + }() + } + + } + for i := 0; i < l-1; i++ { + if len(cks[i].WsKey) > 0 { + rsp := cmd(fmt.Sprintf(`python3 test.py "%s"`, cks[i].WsKey), &Sender{}) + ss := regexp.MustCompile(`pt_key=([^;=\s]+);pt_pin=([^;=\s]+)`).FindAllStringSubmatch(rsp, -1) + if len(ss) > 0 { + + xyb := 0 + for _, s := range ss { + ck := JdCookie{ + PtKey: s[1], + PtPin: s[2], + } + if CookieOK(&ck) { + xyb++ + if HasKey(ck.PtKey) { + (&JdCookie{}).Push(fmt.Sprintf("重复提交")) + } else { + if nck, err := GetJdCookie(ck.PtPin); err == nil { + nck.InPool(ck.PtKey) + msg := fmt.Sprintf("定时更新账号,%s", ck.PtPin) + (&JdCookie{}).Push(msg) + logs.Info(msg) + } else { + NewJdCookie(&ck) + msg := fmt.Sprintf("添加账号,账号名:%s", ck.PtPin) + logs.Info(msg) + } + } + } else { + (&JdCookie{}).Push(fmt.Sprintf("无效CK转换失败,%s", ck.PtPin)) + } + } + } + go func() { + Save <- &JdCookie{} + }() } } - //for i := 0; i < l-1; i++ { - // if len(cks[i].WsKey) > 0 { - // rsp := cmd(fmt.Sprintf(`python3 test.py "%s"`, cks[i].WsKey), &Sender{}) - // ss := regexp.MustCompile(`pt_key=([^;=\s]+);pt_pin=([^;=\s]+)`).FindAllStringSubmatch(rsp, -1) - // if len(ss) > 0 { - // - // xyb := 0 - // for _, s := range ss { - // ck := JdCookie{ - // PtKey: s[1], - // PtPin: s[2], - // } - // if CookieOK(&ck) { - // xyb++ - // if HasKey(ck.PtKey) { - // (&JdCookie{}).Push(fmt.Sprintf("重复提交")) - // } else { - // if nck, err := GetJdCookie(ck.PtPin); err == nil { - // nck.InPool(ck.PtKey) - // msg := fmt.Sprintf("定时更新账号,%s", ck.PtPin) - // (&JdCookie{}).Push(msg) - // logs.Info(msg) - // } else { - // NewJdCookie(&ck) - // msg := fmt.Sprintf("添加账号,账号名:%s", ck.PtPin) - // logs.Info(msg) - // } - // } - // } else { - // (&JdCookie{}).Push(fmt.Sprintf("无效CK转换失败,%s", ck.PtPin)) - // } - // } - // } - // go func() { - // Save <- &JdCookie{} - // }() - // } - //} } func CookieOK(ck *JdCookie) bool {