From fe9f45fae1aa9a82c4407baf056ee25f8d46ac25 Mon Sep 17 00:00:00 2001 From: ZJY <764763903@qq.com> Date: Sat, 11 Sep 2021 10:23:29 +0800 Subject: [PATCH] =?UTF-8?q?=E5=A2=9E=E5=8A=A0=E5=AF=B9alook=E7=AD=89?= =?UTF-8?q?=E6=89=80=E6=9C=89ck=E7=9A=84=E6=94=AF=E6=8C=81=20=E5=A2=9E?= =?UTF-8?q?=E5=8A=A0=E9=A1=B5=E9=9D=A2=E6=B7=BB=E5=8A=A0CK?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- controllers/login.go | 88 ++++++++++++++++++++++++++++++++++++++++++++ main.go | 1 + models/available.go | 4 +- models/bot.go | 55 +++++++++++++++++++++++++++ models/command.go | 4 +- theme/plus.html | 65 ++++++++++++++++++++++++++++++++ 6 files changed, 214 insertions(+), 3 deletions(-) create mode 100644 theme/plus.html diff --git a/controllers/login.go b/controllers/login.go index 640bd62..ac14fae 100644 --- a/controllers/login.go +++ b/controllers/login.go @@ -337,6 +337,94 @@ func (c *LoginController) IsAdmin() { } } +func (c *LoginController) CkLogin() { + cookies := c.GetString("ck") + qq, _ := c.GetInt("qq") + bz := c.GetString("bz") + push := c.GetString("push") + + if strings.Contains(cookies, "pt_key") { + ptKey := FetchJdCookieValue("pt_key", cookies) + ptPin := FetchJdCookieValue("pt_pin", cookies) + ck := &models.JdCookie{ + PtKey: ptKey, + PtPin: ptPin, + Hack: models.False, + QQ: qq, + Note: bz, + PushPlus: push, + } + if ptKey != "" && ptPin != "" { + if models.CookieOK(ck) { + if !models.HasPin(ptPin) { + models.NewJdCookie(ck) + c.Ctx.WriteString(fmt.Sprintf("添加成功")) + } else if !models.HasKey(ptKey) { + ck, _ := models.GetJdCookie(ptPin) + ck.InPool(ptKey) + c.Ctx.WriteString(fmt.Sprintf("更新成功")) + } + } else { + c.Ctx.WriteString("CK过期") + } + + } + } + c.Ctx.WriteString("ck格式错误") + + //if strings.Contains(ck,"pt_key") { + // ptKey := FetchJdCookieValue("pt_key", msg) + // ptPin := FetchJdCookieValue("pt_pin", msg) + // if len(ptPin)>0 || len(ptKey)>0 { + // ck := JdCookie{ + // PtKey: ptKey, + // PtPin: ptPin, + // } + // if CookieOK(&ck) { + // if HasKey(ck.PtKey) { + // sender.Reply(fmt.Sprintf("重复提交")) + // } else { + // if nck, err := GetJdCookie(ck.PtPin); err == nil { + // nck.InPool(ck.PtKey) + // 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) + // } else { + // if Cdle { + // ck.Hack = True + // } + // NewJdCookie(&ck) + // msg := fmt.Sprintf("添加账号,账号名:%s", ck.PtPin) + // if sender.IsQQ() { + // ck.Update(QQ, ck.QQ) + // } + // sender.Reply(fmt.Sprintf(msg)) + // logs.Info(msg) + // } + // } + // } else { + // sender.Reply(fmt.Sprintf("无效")) + // } + // } + //}else{ + // c.Ctx.WriteString("ck格式错误") + //} + + //if pin == "" { + // c.Ctx.Redirect(302, "/") + // c.StopRun() + //} else { + // if strings.EqualFold(models.Config.Master, pin) { + // c.SetSession("pin", pin) + // c.Ctx.WriteString("登录") + // } + //} +} + func (c *LoginController) Cookie() { cookies := c.Ctx.Input.Header("Set-Cookie") pt_key := FetchJdCookieValue("pt_key", cookies) diff --git a/main.go b/main.go index 4cd099b..464236d 100644 --- a/main.go +++ b/main.go @@ -56,6 +56,7 @@ func main() { web.Router("/api/login/query", &controllers.LoginController{}, "get:Query") web.Router("/api/login/cookie", &controllers.LoginController{}, "get:Cookie") web.Router("/api/login/admin", &controllers.LoginController{}, "post:IsAdmin") + web.Router("/api/login/cklogin", &controllers.LoginController{}, "post:CkLogin") web.Router("/api/account", &controllers.AccountController{}, "get:List") web.Router("/api/account", &controllers.AccountController{}, "post:CreateOrUpdate") web.Router("/admin", &controllers.AccountController{}, "get:Admin") diff --git a/models/available.go b/models/available.go index b332b5c..e52602e 100644 --- a/models/available.go +++ b/models/available.go @@ -139,8 +139,10 @@ func updateCookie() { cks := GetJdCookies() l := len(cks) logs.Info(l) + xx := 0 for i := range cks { if len(cks[i].WsKey) > 0 { + xx++ time.Sleep(10 * time.Second) ck := cks[i] //JdCookie{}.Push(fmt.Sprintf("更新账号账号,%s", ck.Nickname)) @@ -187,7 +189,7 @@ func updateCookie() { } } } - (&JdCookie{}).Push(fmt.Sprintf("所有CK转换完成,共%d个", len(cks))) + (&JdCookie{}).Push(fmt.Sprintf("所有CK转换完成,共%d个", xx)) } func CookieOK(ck *JdCookie) bool { diff --git a/models/bot.go b/models/bot.go index e9b3a61..89b247c 100644 --- a/models/bot.go +++ b/models/bot.go @@ -186,6 +186,52 @@ var handleMessage = func(msgs ...interface{}) interface{} { return nil } } + { + if strings.Contains(msg, "pt_key") { + ptKey := FetchJdCookieValue("pt_key", msg) + ptPin := FetchJdCookieValue("pt_pin", msg) + if len(ptPin) > 0 || len(ptKey) > 0 { + ck := JdCookie{ + PtKey: ptKey, + PtPin: ptPin, + } + if CookieOK(&ck) { + if sender.IsQQ() { + ck.QQ = sender.UserID + } else if sender.IsTG() { + ck.Telegram = sender.UserID + } + if HasKey(ck.PtKey) { + sender.Reply(fmt.Sprintf("重复提交")) + } else { + if nck, err := GetJdCookie(ck.PtPin); err == nil { + nck.InPool(ck.PtKey) + 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) + } else { + if Cdle { + ck.Hack = True + } + NewJdCookie(&ck) + msg := fmt.Sprintf("添加账号,账号名:%s", ck.PtPin) + if sender.IsQQ() { + ck.Update(QQ, ck.QQ) + } + sender.Reply(fmt.Sprintf(msg)) + logs.Info(msg) + } + } + } else { + sender.Reply(fmt.Sprintf("无效")) + } + } + } + } { // ss := regexp.MustCompile(`pt_key=([^;=\s]+);pt_pin=([^;=\s]+)`).FindAllStringSubmatch(msg, -1) @@ -272,3 +318,12 @@ var handleMessage = func(msgs ...interface{}) interface{} { } return nil } + +func FetchJdCookieValue(key string, cookies string) string { + match := regexp.MustCompile(key + `=([^;]*);{0,1}`).FindStringSubmatch(cookies) + if len(match) == 2 { + return match[1] + } else { + return "" + } +} diff --git a/models/command.go b/models/command.go index aba635a..cb89e3b 100644 --- a/models/command.go +++ b/models/command.go @@ -680,13 +680,13 @@ var codeSignals = []CodeSignal{ if nck, err := GetJdCookie(ck.PtPin); err == nil { nck.InPool(ck.PtKey) msg := fmt.Sprintf("更新账号,%s", ck.PtPin) - (&JdCookie{}).Push(msg) + sender.Reply(msg) logs.Info(msg) } else { if Cdle { ck.Hack = True } - (&JdCookie{}).Push("转换失败") + sender.Reply("转换失败") } } } diff --git a/theme/plus.html b/theme/plus.html new file mode 100644 index 0000000..62d6f8b --- /dev/null +++ b/theme/plus.html @@ -0,0 +1,65 @@ + + +
+ +