-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathapp.js
69 lines (58 loc) · 1.98 KB
/
app.js
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
"use strict"
const fs = require('fs');
const path = require('path');
const { createClient } = require("icqq");
require("dotenv").config();
const account = parseInt(process.env.qq);
const password = process.env.password;
const config = {
// trace,debug,info,warn,error,mark
log_level: "info",
// 1:Android Phone 2:aPad 3:Android Watch 4:MacOS 5:iPad
platform: 3,
// Cache users of group?
reconn_interval: false
};
const client = createClient(config);
client.on('system.login.slider', (e) => {
console.log('输入滑块地址获取的ticket后继续。\n滑块地址: ' + e.url)
process.stdin.once('data', (data) => {
client.submitSlider(data.toString().trim());
})
});
client.on('system.login.qrcode', (e) => {
console.log('扫码完成后回车继续:')
process.stdin.once('data', () => {
client.login();
})
});
client.on('system.login.device', (e) => {
console.log('请选择验证方式:(1:短信验证 其他:扫码验证)')
process.stdin.once('data', (data) => {
if (data.toString().trim() === '1') {
client.sendSmsCode()
console.log('请输入手机收到的短信验证码:')
process.stdin.once('data', (res) => {
client.submitSmsCode(res.toString().trim());
})
} else {
console.log('扫码完成后回车继续:' + e.url);
process.stdin.once('data', () => {
client.login();
});
}
})
});
client.on("system.online", () => console.log("Service is now online!"));
client.login(account, password)
exports.client = client;
// Load message handler
const message_handler_dir = path.join(__dirname, 'message');
fs.readdirSync(message_handler_dir).forEach(file => {
require(path.resolve(message_handler_dir, file));
});
// Openai API
require("./api/openai_api");
process.on("unhandledRejection", (reason, promise) => {
console.log('Unhandled Rejection at:', promise, 'reason:', reason)
});