hotcat-bot-qq 0.1.7 → 0.1.9
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/dist/botClient.d.ts +1 -0
- package/dist/botClient.js +52 -7
- package/dist/botEvent.js +40 -31
- package/package.json +1 -1
- package/plugins/hotCatPlugin/index.js +7 -2
- package/plugins/hotCatPlugin/index.ts +7 -2
package/dist/botClient.d.ts
CHANGED
package/dist/botClient.js
CHANGED
|
@@ -2,8 +2,8 @@ import { BotApi } from './botApi';
|
|
|
2
2
|
import { BotConsole } from './botConsole';
|
|
3
3
|
import { BotEvent } from './botEvent';
|
|
4
4
|
import { BotScheduler } from './botScheduler';
|
|
5
|
-
import { existsSync, mkdirSync, cpSync } from 'fs';
|
|
6
|
-
import { join, dirname } from 'path';
|
|
5
|
+
import { existsSync, mkdirSync, cpSync, readdirSync, readFileSync, statSync, lstatSync } from 'fs';
|
|
6
|
+
import { join, dirname, relative } from 'path';
|
|
7
7
|
import { fileURLToPath } from 'url';
|
|
8
8
|
/**
|
|
9
9
|
* Bot 客户端,封装连接、启动流程及 bot 自身信息。
|
|
@@ -84,15 +84,60 @@ export class BotClient {
|
|
|
84
84
|
this.plugin.watch('./plugins');
|
|
85
85
|
}
|
|
86
86
|
seedDefaultPlugin() {
|
|
87
|
-
const dest = join(process.cwd(), 'plugins', 'hotCatPlugin');
|
|
88
|
-
if (existsSync(dest))
|
|
89
|
-
return;
|
|
90
87
|
const selfDir = dirname(fileURLToPath(import.meta.url));
|
|
91
88
|
const src = join(selfDir, '..', 'plugins', 'hotCatPlugin');
|
|
92
89
|
if (!existsSync(src))
|
|
93
90
|
return;
|
|
91
|
+
const dest = join(process.cwd(), 'plugins', 'hotCatPlugin');
|
|
94
92
|
mkdirSync(join(process.cwd(), 'plugins'), { recursive: true });
|
|
95
|
-
|
|
96
|
-
|
|
93
|
+
if (!existsSync(dest)) {
|
|
94
|
+
cpSync(src, dest, { recursive: true });
|
|
95
|
+
new BotConsole('system', '默认插件 hotCatPlugin 已创建').log();
|
|
96
|
+
return;
|
|
97
|
+
}
|
|
98
|
+
const updated = this.syncPluginFiles(src, dest);
|
|
99
|
+
if (updated.length > 0) {
|
|
100
|
+
new BotConsole('system', `默认插件 hotCatPlugin 已更新: ${updated.join(', ')}`).log();
|
|
101
|
+
}
|
|
102
|
+
}
|
|
103
|
+
syncPluginFiles(src, dest) {
|
|
104
|
+
const updated = [];
|
|
105
|
+
const walkDir = (dir) => {
|
|
106
|
+
const entries = readdirSync(dir);
|
|
107
|
+
const files = [];
|
|
108
|
+
for (const entry of entries) {
|
|
109
|
+
const full = join(dir, entry);
|
|
110
|
+
if (lstatSync(full).isDirectory()) {
|
|
111
|
+
files.push(...walkDir(full));
|
|
112
|
+
}
|
|
113
|
+
else {
|
|
114
|
+
files.push(full);
|
|
115
|
+
}
|
|
116
|
+
}
|
|
117
|
+
return files;
|
|
118
|
+
};
|
|
119
|
+
const srcFiles = walkDir(src);
|
|
120
|
+
for (const file of srcFiles) {
|
|
121
|
+
const rel = relative(src, file);
|
|
122
|
+
const target = join(dest, rel);
|
|
123
|
+
if (!existsSync(target)) {
|
|
124
|
+
mkdirSync(dirname(target), { recursive: true });
|
|
125
|
+
cpSync(file, target);
|
|
126
|
+
updated.push(rel);
|
|
127
|
+
continue;
|
|
128
|
+
}
|
|
129
|
+
if (statSync(file).size !== statSync(target).size) {
|
|
130
|
+
cpSync(file, target);
|
|
131
|
+
updated.push(rel);
|
|
132
|
+
continue;
|
|
133
|
+
}
|
|
134
|
+
const srcContent = readFileSync(file);
|
|
135
|
+
const destContent = readFileSync(target);
|
|
136
|
+
if (!srcContent.equals(destContent)) {
|
|
137
|
+
cpSync(file, target);
|
|
138
|
+
updated.push(rel);
|
|
139
|
+
}
|
|
140
|
+
}
|
|
141
|
+
return updated;
|
|
97
142
|
}
|
|
98
143
|
}
|
package/dist/botEvent.js
CHANGED
|
@@ -24,11 +24,16 @@ export class MessageEvent {
|
|
|
24
24
|
});
|
|
25
25
|
this.napcat = napcat;
|
|
26
26
|
this.client = client;
|
|
27
|
+
this.napcat.on('message.group', (event) => {
|
|
28
|
+
new BotConsole('groupMessage', event).log();
|
|
29
|
+
});
|
|
30
|
+
this.napcat.on('message.private', (event) => {
|
|
31
|
+
new BotConsole('privateMessage', event).log();
|
|
32
|
+
});
|
|
27
33
|
}
|
|
28
34
|
onGroupMessage(fn) {
|
|
29
35
|
const w = async (event) => {
|
|
30
36
|
try {
|
|
31
|
-
new BotConsole('groupMessage', event).log();
|
|
32
37
|
await fn(this.client, event);
|
|
33
38
|
}
|
|
34
39
|
catch (e) {
|
|
@@ -48,7 +53,6 @@ export class MessageEvent {
|
|
|
48
53
|
onGroupNormal(fn) {
|
|
49
54
|
const w = async (event) => {
|
|
50
55
|
try {
|
|
51
|
-
new BotConsole('groupMessage', event).log();
|
|
52
56
|
await fn(this.client, event);
|
|
53
57
|
}
|
|
54
58
|
catch (e) {
|
|
@@ -68,7 +72,6 @@ export class MessageEvent {
|
|
|
68
72
|
onPrivateMessage(fn) {
|
|
69
73
|
const w = async (event) => {
|
|
70
74
|
try {
|
|
71
|
-
new BotConsole('privateMessage', event).log();
|
|
72
75
|
await fn(this.client, event);
|
|
73
76
|
}
|
|
74
77
|
catch (e) {
|
|
@@ -88,7 +91,6 @@ export class MessageEvent {
|
|
|
88
91
|
onPrivateFriend(fn) {
|
|
89
92
|
const w = async (event) => {
|
|
90
93
|
try {
|
|
91
|
-
new BotConsole('privateMessage', event).log();
|
|
92
94
|
await fn(this.client, event);
|
|
93
95
|
}
|
|
94
96
|
catch (e) {
|
|
@@ -108,7 +110,6 @@ export class MessageEvent {
|
|
|
108
110
|
onPrivateGroup(fn) {
|
|
109
111
|
const w = async (event) => {
|
|
110
112
|
try {
|
|
111
|
-
new BotConsole('privateMessage', event).log();
|
|
112
113
|
await fn(this.client, event);
|
|
113
114
|
}
|
|
114
115
|
catch (e) {
|
|
@@ -151,11 +152,16 @@ export class MessageSent {
|
|
|
151
152
|
});
|
|
152
153
|
this.napcat = napcat;
|
|
153
154
|
this.client = client;
|
|
155
|
+
this.napcat.on('message_sent.group', (event) => {
|
|
156
|
+
new BotConsole('groupMessageSelf', event).log();
|
|
157
|
+
});
|
|
158
|
+
this.napcat.on('message_sent.private', (event) => {
|
|
159
|
+
new BotConsole('privateMessageSelf', event).log();
|
|
160
|
+
});
|
|
154
161
|
}
|
|
155
162
|
onGroupSent(fn) {
|
|
156
163
|
const w = async (event) => {
|
|
157
164
|
try {
|
|
158
|
-
new BotConsole('groupMessageSelf', event).log();
|
|
159
165
|
await fn(this.client, event);
|
|
160
166
|
}
|
|
161
167
|
catch (e) {
|
|
@@ -175,7 +181,6 @@ export class MessageSent {
|
|
|
175
181
|
onGroupNormal(fn) {
|
|
176
182
|
const w = async (event) => {
|
|
177
183
|
try {
|
|
178
|
-
new BotConsole('groupMessageSelf', event).log();
|
|
179
184
|
await fn(this.client, event);
|
|
180
185
|
}
|
|
181
186
|
catch (e) {
|
|
@@ -195,7 +200,6 @@ export class MessageSent {
|
|
|
195
200
|
onPrivateSent(fn) {
|
|
196
201
|
const w = async (event) => {
|
|
197
202
|
try {
|
|
198
|
-
new BotConsole('privateMessageSelf', event).log();
|
|
199
203
|
await fn(this.client, event);
|
|
200
204
|
}
|
|
201
205
|
catch (e) {
|
|
@@ -215,7 +219,6 @@ export class MessageSent {
|
|
|
215
219
|
onPrivateFriend(fn) {
|
|
216
220
|
const w = async (event) => {
|
|
217
221
|
try {
|
|
218
|
-
new BotConsole('privateMessageSelf', event).log();
|
|
219
222
|
await fn(this.client, event);
|
|
220
223
|
}
|
|
221
224
|
catch (e) {
|
|
@@ -235,7 +238,6 @@ export class MessageSent {
|
|
|
235
238
|
onPrivateGroup(fn) {
|
|
236
239
|
const w = async (event) => {
|
|
237
240
|
try {
|
|
238
|
-
new BotConsole('privateMessageSelf', event).log();
|
|
239
241
|
await fn(this.client, event);
|
|
240
242
|
}
|
|
241
243
|
catch (e) {
|
|
@@ -278,11 +280,19 @@ export class RequestEvent {
|
|
|
278
280
|
});
|
|
279
281
|
this.napcat = napcat;
|
|
280
282
|
this.client = client;
|
|
283
|
+
this.napcat.on('request.friend', (event) => {
|
|
284
|
+
new BotConsole('requestFriend', event).log();
|
|
285
|
+
});
|
|
286
|
+
this.napcat.on('request.group.add', (event) => {
|
|
287
|
+
new BotConsole('requestGroupAdd', event).log();
|
|
288
|
+
});
|
|
289
|
+
this.napcat.on('request.group.invite', (event) => {
|
|
290
|
+
new BotConsole('requestGroupInvite', event).log();
|
|
291
|
+
});
|
|
281
292
|
}
|
|
282
293
|
onFriend(fn) {
|
|
283
294
|
const w = async (event) => {
|
|
284
295
|
try {
|
|
285
|
-
new BotConsole('requestFriend', event).log();
|
|
286
296
|
await fn(this.client, event);
|
|
287
297
|
}
|
|
288
298
|
catch (e) {
|
|
@@ -302,7 +312,6 @@ export class RequestEvent {
|
|
|
302
312
|
onGroupAdd(fn) {
|
|
303
313
|
const w = async (event) => {
|
|
304
314
|
try {
|
|
305
|
-
new BotConsole('requestGroupAdd', event).log();
|
|
306
315
|
await fn(this.client, event);
|
|
307
316
|
}
|
|
308
317
|
catch (e) {
|
|
@@ -322,7 +331,6 @@ export class RequestEvent {
|
|
|
322
331
|
onGroupInvite(fn) {
|
|
323
332
|
const w = async (event) => {
|
|
324
333
|
try {
|
|
325
|
-
new BotConsole('requestGroupInvite', event).log();
|
|
326
334
|
await fn(this.client, event);
|
|
327
335
|
}
|
|
328
336
|
catch (e) {
|
|
@@ -342,8 +350,6 @@ export class RequestEvent {
|
|
|
342
350
|
onGroupRequest(fn) {
|
|
343
351
|
const w = async (event) => {
|
|
344
352
|
try {
|
|
345
|
-
const type = event.sub_type === 'add' ? 'requestGroupAdd' : 'requestGroupInvite';
|
|
346
|
-
new BotConsole(type, event).log();
|
|
347
353
|
await fn(this.client, event);
|
|
348
354
|
}
|
|
349
355
|
catch (e) {
|
|
@@ -386,11 +392,29 @@ export class NoticeEvent {
|
|
|
386
392
|
});
|
|
387
393
|
this.napcat = napcat;
|
|
388
394
|
this.client = client;
|
|
395
|
+
const log = (event) => {
|
|
396
|
+
new BotConsole('notice', event).log();
|
|
397
|
+
};
|
|
398
|
+
this.napcat.on('notice.friend_add', log);
|
|
399
|
+
this.napcat.on('notice.friend_recall', log);
|
|
400
|
+
this.napcat.on('notice.group_admin', log);
|
|
401
|
+
this.napcat.on('notice.group_ban', log);
|
|
402
|
+
this.napcat.on('notice.group_card', log);
|
|
403
|
+
this.napcat.on('notice.group_decrease', log);
|
|
404
|
+
this.napcat.on('notice.group_increase', log);
|
|
405
|
+
this.napcat.on('notice.group_recall', log);
|
|
406
|
+
this.napcat.on('notice.group_upload', log);
|
|
407
|
+
this.napcat.on('notice.group_msg_emoji_like', log);
|
|
408
|
+
this.napcat.on('notice.essence', log);
|
|
409
|
+
this.napcat.on('notice.notify.poke', log);
|
|
410
|
+
this.napcat.on('notice.notify.group_name', log);
|
|
411
|
+
this.napcat.on('notice.notify.title', log);
|
|
412
|
+
this.napcat.on('notice.notify.profile_like', log);
|
|
413
|
+
this.napcat.on('notice.bot_offline', log);
|
|
389
414
|
}
|
|
390
415
|
onFriendAdd(fn) {
|
|
391
416
|
const w = async (event) => {
|
|
392
417
|
try {
|
|
393
|
-
new BotConsole('notice', event).log();
|
|
394
418
|
await fn(this.client, event);
|
|
395
419
|
}
|
|
396
420
|
catch (e) {
|
|
@@ -410,7 +434,6 @@ export class NoticeEvent {
|
|
|
410
434
|
onFriendRecall(fn) {
|
|
411
435
|
const w = async (event) => {
|
|
412
436
|
try {
|
|
413
|
-
new BotConsole('notice', event).log();
|
|
414
437
|
await fn(this.client, event);
|
|
415
438
|
}
|
|
416
439
|
catch (e) {
|
|
@@ -430,7 +453,6 @@ export class NoticeEvent {
|
|
|
430
453
|
onGroupAdmin(fn) {
|
|
431
454
|
const w = async (event) => {
|
|
432
455
|
try {
|
|
433
|
-
new BotConsole('notice', event).log();
|
|
434
456
|
await fn(this.client, event);
|
|
435
457
|
}
|
|
436
458
|
catch (e) {
|
|
@@ -450,7 +472,6 @@ export class NoticeEvent {
|
|
|
450
472
|
onGroupBan(fn) {
|
|
451
473
|
const w = async (event) => {
|
|
452
474
|
try {
|
|
453
|
-
new BotConsole('notice', event).log();
|
|
454
475
|
await fn(this.client, event);
|
|
455
476
|
}
|
|
456
477
|
catch (e) {
|
|
@@ -470,7 +491,6 @@ export class NoticeEvent {
|
|
|
470
491
|
onGroupCard(fn) {
|
|
471
492
|
const w = async (event) => {
|
|
472
493
|
try {
|
|
473
|
-
new BotConsole('notice', event).log();
|
|
474
494
|
await fn(this.client, event);
|
|
475
495
|
}
|
|
476
496
|
catch (e) {
|
|
@@ -490,7 +510,6 @@ export class NoticeEvent {
|
|
|
490
510
|
onGroupDecrease(fn) {
|
|
491
511
|
const w = async (event) => {
|
|
492
512
|
try {
|
|
493
|
-
new BotConsole('notice', event).log();
|
|
494
513
|
await fn(this.client, event);
|
|
495
514
|
}
|
|
496
515
|
catch (e) {
|
|
@@ -510,7 +529,6 @@ export class NoticeEvent {
|
|
|
510
529
|
onGroupIncrease(fn) {
|
|
511
530
|
const w = async (event) => {
|
|
512
531
|
try {
|
|
513
|
-
new BotConsole('notice', event).log();
|
|
514
532
|
await fn(this.client, event);
|
|
515
533
|
}
|
|
516
534
|
catch (e) {
|
|
@@ -530,7 +548,6 @@ export class NoticeEvent {
|
|
|
530
548
|
onGroupRecall(fn) {
|
|
531
549
|
const w = async (event) => {
|
|
532
550
|
try {
|
|
533
|
-
new BotConsole('notice', event).log();
|
|
534
551
|
await fn(this.client, event);
|
|
535
552
|
}
|
|
536
553
|
catch (e) {
|
|
@@ -550,7 +567,6 @@ export class NoticeEvent {
|
|
|
550
567
|
onGroupUpload(fn) {
|
|
551
568
|
const w = async (event) => {
|
|
552
569
|
try {
|
|
553
|
-
new BotConsole('notice', event).log();
|
|
554
570
|
await fn(this.client, event);
|
|
555
571
|
}
|
|
556
572
|
catch (e) {
|
|
@@ -570,7 +586,6 @@ export class NoticeEvent {
|
|
|
570
586
|
onGroupEmojiLike(fn) {
|
|
571
587
|
const w = async (event) => {
|
|
572
588
|
try {
|
|
573
|
-
new BotConsole('notice', event).log();
|
|
574
589
|
await fn(this.client, event);
|
|
575
590
|
}
|
|
576
591
|
catch (e) {
|
|
@@ -590,7 +605,6 @@ export class NoticeEvent {
|
|
|
590
605
|
onGroupEssence(fn) {
|
|
591
606
|
const w = async (event) => {
|
|
592
607
|
try {
|
|
593
|
-
new BotConsole('notice', event).log();
|
|
594
608
|
await fn(this.client, event);
|
|
595
609
|
}
|
|
596
610
|
catch (e) {
|
|
@@ -610,7 +624,6 @@ export class NoticeEvent {
|
|
|
610
624
|
onPoke(fn) {
|
|
611
625
|
const w = async (event) => {
|
|
612
626
|
try {
|
|
613
|
-
new BotConsole('notice', event).log();
|
|
614
627
|
await fn(this.client, event);
|
|
615
628
|
}
|
|
616
629
|
catch (e) {
|
|
@@ -630,7 +643,6 @@ export class NoticeEvent {
|
|
|
630
643
|
onGroupNameChange(fn) {
|
|
631
644
|
const w = async (event) => {
|
|
632
645
|
try {
|
|
633
|
-
new BotConsole('notice', event).log();
|
|
634
646
|
await fn(this.client, event);
|
|
635
647
|
}
|
|
636
648
|
catch (e) {
|
|
@@ -650,7 +662,6 @@ export class NoticeEvent {
|
|
|
650
662
|
onTitleChange(fn) {
|
|
651
663
|
const w = async (event) => {
|
|
652
664
|
try {
|
|
653
|
-
new BotConsole('notice', event).log();
|
|
654
665
|
await fn(this.client, event);
|
|
655
666
|
}
|
|
656
667
|
catch (e) {
|
|
@@ -670,7 +681,6 @@ export class NoticeEvent {
|
|
|
670
681
|
onProfileLike(fn) {
|
|
671
682
|
const w = async (event) => {
|
|
672
683
|
try {
|
|
673
|
-
new BotConsole('notice', event).log();
|
|
674
684
|
await fn(this.client, event);
|
|
675
685
|
}
|
|
676
686
|
catch (e) {
|
|
@@ -690,7 +700,6 @@ export class NoticeEvent {
|
|
|
690
700
|
onBotOffline(fn) {
|
|
691
701
|
const w = async (event) => {
|
|
692
702
|
try {
|
|
693
|
-
new BotConsole('notice', event).log();
|
|
694
703
|
await fn(this.client, event);
|
|
695
704
|
}
|
|
696
705
|
catch (e) {
|
package/package.json
CHANGED
|
@@ -14,7 +14,12 @@ export class HotCatPlugin extends PluginBase {
|
|
|
14
14
|
await this.api.sendGroupMessage(event.group_id, Message.reply(event.message_id), Message.text(`HotCat 信息\n` +
|
|
15
15
|
`版本:${this.meta.version}\n` +
|
|
16
16
|
`平台:${platform} ${arch}\n` +
|
|
17
|
-
`运行时间:${uptime}`
|
|
17
|
+
`运行时间:${uptime}\n` +
|
|
18
|
+
`Github: https://github.com/CHCAT1320/hotCat-bot-qq\n` +
|
|
19
|
+
`开发文档: https://hotcat-bot-qq.docs.chcat1320.top\n` +
|
|
20
|
+
`交流群: 638144340\n` +
|
|
21
|
+
`管理员QQ: 1095216448\n` +
|
|
22
|
+
`基于 MIT 许可发布 版权所有 © 2026 CHCAT1320`));
|
|
18
23
|
}
|
|
19
24
|
};
|
|
20
25
|
}
|
|
@@ -45,7 +50,7 @@ export class HotCatPlugin extends PluginBase {
|
|
|
45
50
|
}
|
|
46
51
|
HotCatPlugin.meta = {
|
|
47
52
|
name: 'hotCatPlugin',
|
|
48
|
-
version: '0.1.
|
|
53
|
+
version: '0.1.9',
|
|
49
54
|
description: 'HotCat 默认插件(#hotCat 指令查询 bot 状态)',
|
|
50
55
|
author: 'CHCAT1320',
|
|
51
56
|
};
|
|
@@ -7,7 +7,7 @@ import * as os from 'os'
|
|
|
7
7
|
export class HotCatPlugin extends PluginBase {
|
|
8
8
|
static meta = {
|
|
9
9
|
name: 'hotCatPlugin',
|
|
10
|
-
version: '0.1.
|
|
10
|
+
version: '0.1.9',
|
|
11
11
|
description: 'HotCat 默认插件(#hotCat 指令查询 bot 状态)',
|
|
12
12
|
author: 'CHCAT1320',
|
|
13
13
|
}
|
|
@@ -41,7 +41,12 @@ export class HotCatPlugin extends PluginBase {
|
|
|
41
41
|
`HotCat 信息\n` +
|
|
42
42
|
`版本:${this.meta.version}\n` +
|
|
43
43
|
`平台:${platform} ${arch}\n` +
|
|
44
|
-
`运行时间:${uptime}`
|
|
44
|
+
`运行时间:${uptime}\n` +
|
|
45
|
+
`Github: https://github.com/CHCAT1320/hotCat-bot-qq\n` +
|
|
46
|
+
`开发文档: https://hotcat-bot-qq.docs.chcat1320.top\n` +
|
|
47
|
+
`交流群: 638144340\n` +
|
|
48
|
+
`管理员QQ: 1095216448\n` +
|
|
49
|
+
`基于 MIT 许可发布 版权所有 © 2026 CHCAT1320`
|
|
45
50
|
)
|
|
46
51
|
)
|
|
47
52
|
}
|