add 增加配置是否自动添加好友

add 增加短信自动绑定QQ
This commit is contained in:
ZJY 2021-09-27 12:17:21 +08:00
parent d7f35a2b43
commit 3a978563a3
4 changed files with 21 additions and 5 deletions

View File

@ -14,6 +14,7 @@ IsOldV4: #填写true或者false false是否新版或者旧版V4
ApiToken: #为空默认随机禁用
Wskey: # 填空默认禁用wskey转换 需要的填true
SMSAddress:
IsAddFriend: #填写true或者false false
theme:
static: ./static
master:

View File

@ -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 {

View File

@ -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

View File

@ -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")