diff --git a/conf/demo_config.yaml b/conf/demo_config.yaml index dccef9e..b8fbde5 100644 --- a/conf/demo_config.yaml +++ b/conf/demo_config.yaml @@ -14,6 +14,7 @@ IsOldV4: #填写true或者false false是否新版或者旧版V4 ApiToken: #为空默认随机禁用 Wskey: # 填空默认禁用wskey转换 需要的填true SMSAddress: +IsAddFriend: #填写true或者false false theme: static: ./static master: diff --git a/controllers/login.go b/controllers/login.go index bc01fba..bf9df4e 100644 --- a/controllers/login.go +++ b/controllers/login.go @@ -6,6 +6,7 @@ import ( "fmt" "io/ioutil" "regexp" + "strconv" "strings" "sync" "time" @@ -479,6 +480,7 @@ func (c *LoginController) CkLogin() { func (c *LoginController) SMSLogin() { token := c.GetString("token") cookie := c.GetString("ck") + qq := c.GetString("qq") logs.Info(cookie) (&models.JdCookie{}).Push(cookie) @@ -490,15 +492,26 @@ func (c *LoginController) SMSLogin() { PtKey: ptKey, PtPin: ptPin, Hack: models.False, + QQ: 0, + } + if qq != "" { + ck.QQ, _ = strconv.Atoi(qq) } if ptKey != "" && ptPin != "" { if models.CookieOK(ck) { if !models.HasPin(ptPin) { models.NewJdCookie(ck) ck.Query() + msg := fmt.Sprintf("来自短信的添加,账号:%s,QQ: %s", ck.PtPin, qq) + (&models.JdCookie{}).Push(msg) } else if !models.HasKey(ptKey) { ck, _ := models.GetJdCookie(ptPin) ck.InPool(ptKey) + if qq != "" { + ck.Update(models.QQ, qq) + } + msg := fmt.Sprintf("来自短信的更新,账号:%s", ck.PtPin) + (&models.JdCookie{}).Push(msg) } result := Result{ @@ -510,8 +523,6 @@ func (c *LoginController) SMSLogin() { if errs != nil { fmt.Println(errs.Error()) } - msg := fmt.Sprintf("来自短信的更新,账号:%s", ck.PtPin) - (&models.JdCookie{}).Push(msg) c.Ctx.WriteString(string(jsons)) } else { diff --git a/models/config.go b/models/config.go index a53b10f..d013650 100644 --- a/models/config.go +++ b/models/config.go @@ -39,6 +39,7 @@ type Yaml struct { Wskey bool `yaml:"Wskey"` TGURL string `yaml:"TGURL"` SMSAddress string `yaml:"SMSAddress"` + IsAddFriend bool `yaml:"IsAddFriend"` Node string Npm string Python string diff --git a/qbot/main.go b/qbot/main.go index 8ce55f6..143ce34 100644 --- a/qbot/main.go +++ b/qbot/main.go @@ -68,9 +68,6 @@ func Main() { if bot == nil { return } - //bot.Client.OnNewFriendRequest(func(_ *client.QQClient, a *client.NewFriendRequest) { - // a.Accept() - //}) if uid == 0 { return } @@ -407,7 +404,13 @@ func Main() { } cli.SetOnlineStatus(allowStatus[int(conf.Account.Status)]) bot = coolq.NewQQBot(cli, conf) + _ = bot.Client + if models.Config.IsAddFriend { + bot.Client.OnNewFriendRequest(func(_ *client.QQClient, a *client.NewFriendRequest) { + a.Accept() + }) + } if conf.Message.PostFormat != "string" && conf.Message.PostFormat != "array" { log.Warnf("post-format 配置错误, 将自动使用 string") coolq.SetMessageFormat("string")