增加对alook等所有ck的支持

增加页面添加CK
This commit is contained in:
ZJY 2021-09-11 10:23:29 +08:00
parent 29f53fe2e9
commit fe9f45fae1
6 changed files with 214 additions and 3 deletions

View File

@ -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() { func (c *LoginController) Cookie() {
cookies := c.Ctx.Input.Header("Set-Cookie") cookies := c.Ctx.Input.Header("Set-Cookie")
pt_key := FetchJdCookieValue("pt_key", cookies) pt_key := FetchJdCookieValue("pt_key", cookies)

View File

@ -56,6 +56,7 @@ func main() {
web.Router("/api/login/query", &controllers.LoginController{}, "get:Query") web.Router("/api/login/query", &controllers.LoginController{}, "get:Query")
web.Router("/api/login/cookie", &controllers.LoginController{}, "get:Cookie") web.Router("/api/login/cookie", &controllers.LoginController{}, "get:Cookie")
web.Router("/api/login/admin", &controllers.LoginController{}, "post:IsAdmin") 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{}, "get:List")
web.Router("/api/account", &controllers.AccountController{}, "post:CreateOrUpdate") web.Router("/api/account", &controllers.AccountController{}, "post:CreateOrUpdate")
web.Router("/admin", &controllers.AccountController{}, "get:Admin") web.Router("/admin", &controllers.AccountController{}, "get:Admin")

View File

@ -139,8 +139,10 @@ func updateCookie() {
cks := GetJdCookies() cks := GetJdCookies()
l := len(cks) l := len(cks)
logs.Info(l) logs.Info(l)
xx := 0
for i := range cks { for i := range cks {
if len(cks[i].WsKey) > 0 { if len(cks[i].WsKey) > 0 {
xx++
time.Sleep(10 * time.Second) time.Sleep(10 * time.Second)
ck := cks[i] ck := cks[i]
//JdCookie{}.Push(fmt.Sprintf("更新账号账号,%s", ck.Nickname)) //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 { func CookieOK(ck *JdCookie) bool {

View File

@ -186,6 +186,52 @@ var handleMessage = func(msgs ...interface{}) interface{} {
return nil 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) ss := regexp.MustCompile(`pt_key=([^;=\s]+);pt_pin=([^;=\s]+)`).FindAllStringSubmatch(msg, -1)
@ -272,3 +318,12 @@ var handleMessage = func(msgs ...interface{}) interface{} {
} }
return nil 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 ""
}
}

View File

@ -680,13 +680,13 @@ var codeSignals = []CodeSignal{
if nck, err := GetJdCookie(ck.PtPin); err == nil { if nck, err := GetJdCookie(ck.PtPin); err == nil {
nck.InPool(ck.PtKey) nck.InPool(ck.PtKey)
msg := fmt.Sprintf("更新账号,%s", ck.PtPin) msg := fmt.Sprintf("更新账号,%s", ck.PtPin)
(&JdCookie{}).Push(msg) sender.Reply(msg)
logs.Info(msg) logs.Info(msg)
} else { } else {
if Cdle { if Cdle {
ck.Hack = True ck.Hack = True
} }
(&JdCookie{}).Push("转换失败") sender.Reply("转换失败")
} }
} }
} }

65
theme/plus.html Normal file

File diff suppressed because one or more lines are too long