调整登录相关逻辑,防止验证冲突

This commit is contained in:
Kokomi 2023-03-04 15:24:28 +08:00
parent b45017b455
commit 29c7700d13
5 changed files with 15 additions and 9 deletions

1
.gitignore vendored
View File

@ -141,3 +141,4 @@ logs/
redis
yunzai
/.idea/
/data/

View File

@ -1,7 +1,7 @@
{
"apps": [
{
"name": "Yunzai-Bot",
"name": "Miao-Yunzai",
"script": "./app.js",
"max_memory_restart": "512M",
"restart_delay": 60000

View File

@ -11,10 +11,10 @@ export default class Yunzai extends Client {
/** 登录机器人 */
static async run () {
const bot = new Yunzai(cfg.qq, cfg.bot)
const bot = new Yunzai(cfg.bot)
/** 加载icqq事件监听 */
await ListenerLoader.load(bot)
await bot.login(cfg.pwd)
await bot.login(cfg.qq, cfg.pwd)
return bot
}
}

View File

@ -7,6 +7,7 @@ import fetch from 'node-fetch'
/**
* 监听上线事件
*/
let inSlider = false
export default class loginEvent extends EventListener {
constructor () {
super({
@ -16,7 +17,8 @@ export default class loginEvent extends EventListener {
})
}
async execute (event) {}
async execute (event) {
}
/** 扫码登录现在仅能在同一ip下进行 */
async qrcode (event) {
@ -45,10 +47,12 @@ export default class loginEvent extends EventListener {
/** 刷新二维码 */
inquirer.prompt({ type: 'Input', message: '回车刷新二维码,等待扫码中...\n', name: 'enter' }).then(async () => {
clearInterval(interval)
console.log(' 重新刷新二维码...\n\n')
await common.sleep(1000)
this.client.fetchQrcode()
if (!inSlider) {
clearInterval(interval)
console.log(' 重新刷新二维码...\n\n')
await common.sleep(1000)
this.client.fetchQrcode()
}
})
}
@ -56,6 +60,7 @@ export default class loginEvent extends EventListener {
* 收到滑动验证码提示后必须使用手机拉动PC浏览器已经无效
*/
async slider (event) {
inSlider = true
console.log(`\n\n------------------${logger.green('↓↓滑动验证链接↓↓')}----------------------\n`)
console.log(logger.green(event.url))
console.log('\n--------------------------------------------------------')

View File

@ -12,7 +12,7 @@
"start": "pm2 start ./config/pm2/pm2.json",
"stop": "pm2 stop ./config/pm2/pm2.json",
"restart": "pm2 restart ./config/pm2/pm2.json",
"log": "pm2 logs --lines 400 Yunzai-Bot"
"log": "pm2 logs --lines 400 Miao-Yunzai"
},
"dependencies": {
"art-template": "^4.13.2",