-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathapp.js
More file actions
88 lines (75 loc) · 2 KB
/
Copy pathapp.js
File metadata and controls
88 lines (75 loc) · 2 KB
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
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
import {check} from './lib/check.js'
import {init} from './lib/init.js'
import {createClient} from 'oicq'
import solve from './lib/dealMsg.js'
process.title = 'Yuxuan-Bot'
//检查配置文件
await check()
//创建机器人
const Bot = createClient(BotConfig.account.qq, {
log_level: BotConfig.account.logLevel,
platform: BotConfig.account.platform,
resend: false,
data_dir: process.cwd() + '/data',
})
global.Bot = Bot
//扫码登录 or 密码登录
Bot.on('system.login.qrcode', function (e) {
this.logger.mark('扫码后按Enter回车完成登录')
process.stdin.once('data', () => {
this.login()
})
}).login(BotConfig.account.pwd)
//登录错误
Bot.on('system.login.error', function (e) {
if (e.code === 1) {
this.logger.error('请打开config.js,修改输入正确的密码')
}
process.exit()
})
//提交滑动验证码
Bot.on('system.login.slider', function (e) {
this.logger.mark('请输入获取的ticket,按回车完成【滑动验证】')
process.stdin.once('data', (input) => {
this.submitSlider(input)
})
})
//设备锁
Bot.on('system.login.device', function (e) {
process.stdin.once('data', () => {
this.login()
})
})
//监听上线事件
Bot.on('system.online', async () => {
await init();
});
//监听群聊消息事件
Bot.on('message.group', (event) => {
event.isGroup = true;
solve.dealMsg(event).catch((error) => {
Bot.logger.error(error);
});
});
//监听私聊消息事件
Bot.on('message.private', (event) => {
event.isPrivate = true;
solve.dealMsg(event).catch((error) => {
Bot.logger.error(error);
});
});
//监听好友事件
Bot.on('request.friend', (event) => {
solve.dealFriend(event);
});
//监听群通知
Bot.on('notice.group', (event) => {
event.isGroup = true;
solve.dealGroupNotice(event).catch((error) => {
Bot.logger.error(error);
});
});
//监听群事件
Bot.on('request.group', (event) => {
solve.dealGroupRequest(event);
});