diff --git a/.gitignore b/.gitignore index c0ca50f..6b14ce4 100644 --- a/.gitignore +++ b/.gitignore @@ -141,3 +141,4 @@ logs/ redis yunzai /.idea/ +/data/ diff --git a/config/pm2/pm2.json b/config/pm2/pm2.json index 5308d97..bb31ef3 100644 --- a/config/pm2/pm2.json +++ b/config/pm2/pm2.json @@ -1,7 +1,7 @@ { "apps": [ { - "name": "Yunzai-Bot", + "name": "Miao-Yunzai", "script": "./app.js", "max_memory_restart": "512M", "restart_delay": 60000 diff --git a/lib/bot.js b/lib/bot.js index e01a89b..a496b26 100644 --- a/lib/bot.js +++ b/lib/bot.js @@ -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 } } diff --git a/lib/events/login.js b/lib/events/login.js index f15a83a..40424c5 100644 --- a/lib/events/login.js +++ b/lib/events/login.js @@ -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--------------------------------------------------------') diff --git a/package.json b/package.json index ba4d556..c1e4008 100644 --- a/package.json +++ b/package.json @@ -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",