Skip to content
This repository has been archived by the owner on Aug 15, 2023. It is now read-only.

Commit

Permalink
qq framework switched from oicq to icqq and fix #995
Browse files Browse the repository at this point in the history
  • Loading branch information
Arondight committed Mar 6, 2023
1 parent 7b2ff42 commit 9b43b98
Show file tree
Hide file tree
Showing 5 changed files with 63 additions and 52 deletions.
42 changes: 30 additions & 12 deletions bot.js
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
import { createClient } from "icqq";
import lodash from "lodash";
import { createClient } from "oicq";
import { dispatch } from "#bot/dispatch";
import { init } from "#bot/init";
import { loadPlugins } from "#bot/plugin";
Expand All @@ -16,7 +16,9 @@ function create() {
}

for (const account of global.config.accounts) {
const bot = createClient(account.qq, { platform: account.platform, log_level: "debug", data_dir: global.oicqdir });
// https://github.com/icqqjs/icqq#%E4%B8%8Eoicq2%E7%9A%84%E5%B7%AE%E5%BC%82
//const bot = createClient(account.qq, { platform: account.platform, log_level: "debug", data_dir: global.oicqdir });
const bot = createClient({ platform: account.platform, log_level: "debug", data_dir: global.oicqdir });

bot.account = account;
bot.boardcast = boardcast.bind(null, bot);
Expand Down Expand Up @@ -105,29 +107,45 @@ async function run() {
bot.on(e, () => resolve());
}

bot.on("system.login.device", () => {
bot.logger.mark("输入密保手机收到的短信验证码后按下回车键继续。");
bot.sendSmsCode();
process.stdin.once("data", (input) => {
bot.submitSmsCode(input.toString());
resolve();
});
});
bot.on("system.login.slider", () => {
bot.logger.mark("输入滑动验证码请求中的 ticket 后按下回车键继续。");
process.stdin.once("data", (input) => {
bot.submitSlider(input.toString());
bot.submitSlider(input.toString().trim());
resolve();
});
});

bot.on("system.login.qrcode", () => {
bot.logger.mark("手机扫码完成后按下回车键继续。");
process.stdin.once("data", () => {
bot.login();
resolve();
});
});
bot.login(bot.account.password);

bot.on("system.login.device", (e) => {
console.log("输入证方式(1:短信验证;2:扫码验证)。");
process.stdin.once("data", (input) => {
if ("1" === input.toString().trim()) {
bot.logger.mark("输入密保手机收到的短信验证码后按下回车键继续。");
bot.sendSmsCode();
process.stdin.once("data", (input) => {
bot.submitSmsCode(input.toString().trim());
resolve();
});
} else {
console.log("扫码完成后回车继续:" + e.url);
process.stdin.once("data", () => {
bot.login();
resolve();
});
}
});
});

// https://github.com/icqqjs/icqq#%E4%B8%8Eoicq2%E7%9A%84%E5%B7%AE%E5%BC%82
//bot.login(bot.account.password);
bot.login(bot.account.qq, bot.account.password);
});
}
}
Expand Down
2 changes: 1 addition & 1 deletion config_defaults/setting.yml
Original file line number Diff line number Diff line change
Expand Up @@ -17,7 +17,7 @@ accounts:
-
# QQ 号码
qq: 123456789
# QQ 明文密码,为空( null )则使用扫码登录,推荐使用扫码登录
# QQ 明文密码,为空( null )则使用扫码登录,推荐使用密码登录
#password: null
password: zhimakaimen
# 1:安卓手机、 2:aPad 、 3:安卓手表、 4:MacOS 、 5:iPad
Expand Down
64 changes: 29 additions & 35 deletions package-lock.json

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

5 changes: 2 additions & 3 deletions package.json
Original file line number Diff line number Diff line change
Expand Up @@ -48,8 +48,7 @@
"install-dev": "npm run install-prod && npx cross-env-shell npm_config_sharp_binary_host='https://npmmirror.com/mirrors/sharp' npm_config_sharp_libvips_binary_host='https://npmmirror.com/mirrors/sharp-libvips' npm install --include dev",
"install-prod": "npm install --omit dev",
"update": "git pull && npm run install-prod",
"update-modules": "npx ncu -u && npm update",
"postinstall": "npx patch-package --patch-dir ./.patches"
"update-modules": "npx ncu -u && npm update"
},
"dependencies": {
"cross-env": "7.0.3",
Expand All @@ -58,6 +57,7 @@
"figlet": "1.5.2",
"fnv-plus": "1.3.1",
"iconv-lite": "0.6.3",
"icqq": "0.0.28",
"js-yaml": "4.1.0",
"kind-of": "6.0.3",
"lodash": "4.17.21",
Expand All @@ -67,7 +67,6 @@
"moment-timezone": "0.5.41",
"node-fetch": "3.3.0",
"node-schedule": "2.1.1",
"oicq": "2.3.1",
"p-limit": "4.0.0",
"patch-package": "6.5.1",
"pm2": "5.2.2",
Expand Down
2 changes: 1 addition & 1 deletion src/utils/oicq.js
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@
* ========================================================================== */
import lodash from "lodash";
import querystring from "querystring";
import { genDmMessageId } from "oicq/lib/message/message.js";
import { genDmMessageId } from "icqq/lib/message/message.js";
import { matchBracket } from "#utils/tools";

("use strict");
Expand Down

0 comments on commit 9b43b98

Please sign in to comment.