alemonjs 1.0.0

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.
Files changed (169) hide show
  1. package/LICENSE +340 -0
  2. package/README.md +54 -0
  3. package/lib/alemon/app.js +38 -0
  4. package/lib/alemon/apps.js +121 -0
  5. package/lib/alemon/buffer.js +38 -0
  6. package/lib/alemon/dealmsg.js +423 -0
  7. package/lib/alemon/dialogue.js +61 -0
  8. package/lib/alemon/index.js +40 -0
  9. package/lib/alemon/message.js +27 -0
  10. package/lib/alemon/plugin.js +44 -0
  11. package/lib/alemon/puppeteer.js +226 -0
  12. package/lib/alemon/qrcode.js +66 -0
  13. package/lib/alemon/screenshot.js +126 -0
  14. package/lib/alemon/typings.js +96 -0
  15. package/lib/config.js +25 -0
  16. package/lib/discord/alemon/api.js +44 -0
  17. package/lib/discord/alemon/bot.js +11 -0
  18. package/lib/discord/alemon/conversation.js +7 -0
  19. package/lib/discord/alemon/message/PUBLIC_GUILD_MESSAGES.js +185 -0
  20. package/lib/discord/alemon/segment.js +62 -0
  21. package/lib/discord/index.js +50 -0
  22. package/lib/discord/login.js +99 -0
  23. package/lib/index.js +12 -0
  24. package/lib/kook/alemon/bot.js +11 -0
  25. package/lib/kook/alemon/conversation.js +56 -0
  26. package/lib/kook/alemon/message/PUBLIC_GUILD_MESSAGES.js +195 -0
  27. package/lib/kook/alemon/segment.js +90 -0
  28. package/lib/kook/index.js +39 -0
  29. package/lib/kook/login.js +53 -0
  30. package/lib/login.js +112 -0
  31. package/lib/main.js +106 -0
  32. package/lib/ntqq/alemon/bot.js +11 -0
  33. package/lib/ntqq/alemon/conversation.js +18 -0
  34. package/lib/ntqq/alemon/message/C2C_MESSAGE_CREATE.js +142 -0
  35. package/lib/ntqq/alemon/message/GROUP_AT_MESSAGE_CREATE.js +218 -0
  36. package/lib/ntqq/alemon/segment.js +29 -0
  37. package/lib/ntqq/alemon/types.js +1 -0
  38. package/lib/ntqq/index.js +77 -0
  39. package/lib/ntqq/login.js +74 -0
  40. package/lib/ntqq/sdk/api.js +158 -0
  41. package/lib/ntqq/sdk/config.js +46 -0
  42. package/lib/ntqq/sdk/index.js +5 -0
  43. package/lib/ntqq/sdk/intents.js +69 -0
  44. package/lib/ntqq/sdk/types.js +1 -0
  45. package/lib/ntqq/sdk/typings.js +9 -0
  46. package/lib/ntqq/sdk/web/client.js +89 -0
  47. package/lib/ntqq/sdk/web/img.js +76 -0
  48. package/lib/ntqq/sdk/web/index.js +4 -0
  49. package/lib/ntqq/sdk/web/ip.js +24 -0
  50. package/lib/ntqq/sdk/wss.js +178 -0
  51. package/lib/qq/alemon/apidoc.js +216 -0
  52. package/lib/qq/alemon/bot.js +11 -0
  53. package/lib/qq/alemon/console.js +13 -0
  54. package/lib/qq/alemon/conversation.js +139 -0
  55. package/lib/qq/alemon/doc.js +93 -0
  56. package/lib/qq/alemon/e.js +41 -0
  57. package/lib/qq/alemon/message/AUDIO_ACTION.js +57 -0
  58. package/lib/qq/alemon/message/DIRECT_MESSAGE.js +202 -0
  59. package/lib/qq/alemon/message/FORUMS_EVENT.js +66 -0
  60. package/lib/qq/alemon/message/GUILDS.js +65 -0
  61. package/lib/qq/alemon/message/GUILD_MEMBERS.js +153 -0
  62. package/lib/qq/alemon/message/GUILD_MESSAGES.js +50 -0
  63. package/lib/qq/alemon/message/GUILD_MESSAGE_REACTIONS.js +37 -0
  64. package/lib/qq/alemon/message/INTERACTION.js +36 -0
  65. package/lib/qq/alemon/message/MESSAGE.js +303 -0
  66. package/lib/qq/alemon/message/MESSAGE_AUDIT.js +41 -0
  67. package/lib/qq/alemon/message/OPEN_FORUMS_EVENT.js +74 -0
  68. package/lib/qq/alemon/message/PUBLIC_GUILD_MESSAGES.js +52 -0
  69. package/lib/qq/alemon/permissions.js +43 -0
  70. package/lib/qq/alemon/privatechat.js +78 -0
  71. package/lib/qq/alemon/segment.js +25 -0
  72. package/lib/qq/alemon/types.js +25 -0
  73. package/lib/qq/index.js +44 -0
  74. package/lib/qq/login.js +151 -0
  75. package/lib/types.js +5 -0
  76. package/lib/villa/alemon/conversation.js +48 -0
  77. package/lib/villa/alemon/message/GUILDS.js +124 -0
  78. package/lib/villa/alemon/message/GUILD_MEMBERS.js +128 -0
  79. package/lib/villa/alemon/message/GUILD_MESSAGE_REACTIONS.js +127 -0
  80. package/lib/villa/alemon/message/MESSAGES.js +334 -0
  81. package/lib/villa/alemon/message/MESSAGE_AUDIT.js +128 -0
  82. package/lib/villa/alemon/message/e.js +41 -0
  83. package/lib/villa/alemon/segment.js +34 -0
  84. package/lib/villa/index.js +46 -0
  85. package/lib/villa/login.js +62 -0
  86. package/package.json +63 -0
  87. package/types/alemon/app.d.ts +22 -0
  88. package/types/alemon/apps.d.ts +41 -0
  89. package/types/alemon/buffer.d.ts +13 -0
  90. package/types/alemon/dealmsg.d.ts +41 -0
  91. package/types/alemon/dialogue.d.ts +55 -0
  92. package/types/alemon/index.d.ts +40 -0
  93. package/types/alemon/message.d.ts +17 -0
  94. package/types/alemon/plugin.d.ts +69 -0
  95. package/types/alemon/puppeteer.d.ts +53 -0
  96. package/types/alemon/qrcode.d.ts +20 -0
  97. package/types/alemon/screenshot.d.ts +23 -0
  98. package/types/alemon/typings.d.ts +525 -0
  99. package/types/config.d.ts +12 -0
  100. package/types/discord/alemon/api.d.ts +11 -0
  101. package/types/discord/alemon/bot.d.ts +6 -0
  102. package/types/discord/alemon/conversation.d.ts +6 -0
  103. package/types/discord/alemon/message/PUBLIC_GUILD_MESSAGES.d.ts +7 -0
  104. package/types/discord/alemon/segment.d.ts +46 -0
  105. package/types/discord/index.d.ts +1 -0
  106. package/types/discord/login.d.ts +7 -0
  107. package/types/index.d.ts +6 -0
  108. package/types/kook/alemon/bot.d.ts +8 -0
  109. package/types/kook/alemon/conversation.d.ts +7 -0
  110. package/types/kook/alemon/message/PUBLIC_GUILD_MESSAGES.d.ts +6 -0
  111. package/types/kook/alemon/segment.d.ts +66 -0
  112. package/types/kook/index.d.ts +5 -0
  113. package/types/kook/login.d.ts +7 -0
  114. package/types/login.d.ts +18 -0
  115. package/types/main.d.ts +15 -0
  116. package/types/ntqq/alemon/bot.d.ts +8 -0
  117. package/types/ntqq/alemon/conversation.d.ts +8 -0
  118. package/types/ntqq/alemon/message/C2C_MESSAGE_CREATE.d.ts +2 -0
  119. package/types/ntqq/alemon/message/GROUP_AT_MESSAGE_CREATE.d.ts +8 -0
  120. package/types/ntqq/alemon/segment.d.ts +20 -0
  121. package/types/ntqq/alemon/types.d.ts +11 -0
  122. package/types/ntqq/index.d.ts +1 -0
  123. package/types/ntqq/login.d.ts +6 -0
  124. package/types/ntqq/sdk/api.d.ts +44 -0
  125. package/types/ntqq/sdk/config.d.ts +23 -0
  126. package/types/ntqq/sdk/index.d.ts +5 -0
  127. package/types/ntqq/sdk/intents.d.ts +2 -0
  128. package/types/ntqq/sdk/types.d.ts +11 -0
  129. package/types/ntqq/sdk/typings.d.ts +17 -0
  130. package/types/ntqq/sdk/web/client.d.ts +8 -0
  131. package/types/ntqq/sdk/web/img.d.ts +20 -0
  132. package/types/ntqq/sdk/web/index.d.ts +4 -0
  133. package/types/ntqq/sdk/web/ip.d.ts +5 -0
  134. package/types/ntqq/sdk/wss.d.ts +35 -0
  135. package/types/qq/alemon/apidoc.d.ts +154 -0
  136. package/types/qq/alemon/bot.d.ts +8 -0
  137. package/types/qq/alemon/console.d.ts +1 -0
  138. package/types/qq/alemon/conversation.d.ts +5 -0
  139. package/types/qq/alemon/doc.d.ts +93 -0
  140. package/types/qq/alemon/e.d.ts +38 -0
  141. package/types/qq/alemon/message/AUDIO_ACTION.d.ts +15 -0
  142. package/types/qq/alemon/message/DIRECT_MESSAGE.d.ts +16 -0
  143. package/types/qq/alemon/message/FORUMS_EVENT.d.ts +25 -0
  144. package/types/qq/alemon/message/GUILDS.d.ts +19 -0
  145. package/types/qq/alemon/message/GUILD_MEMBERS.d.ts +11 -0
  146. package/types/qq/alemon/message/GUILD_MESSAGES.d.ts +12 -0
  147. package/types/qq/alemon/message/GUILD_MESSAGE_REACTIONS.d.ts +9 -0
  148. package/types/qq/alemon/message/INTERACTION.d.ts +8 -0
  149. package/types/qq/alemon/message/MESSAGE.d.ts +16 -0
  150. package/types/qq/alemon/message/MESSAGE_AUDIT.d.ts +9 -0
  151. package/types/qq/alemon/message/OPEN_FORUMS_EVENT.d.ts +28 -0
  152. package/types/qq/alemon/message/PUBLIC_GUILD_MESSAGES.d.ts +12 -0
  153. package/types/qq/alemon/permissions.d.ts +29 -0
  154. package/types/qq/alemon/privatechat.d.ts +14 -0
  155. package/types/qq/alemon/segment.d.ts +19 -0
  156. package/types/qq/alemon/types.d.ts +82 -0
  157. package/types/qq/index.d.ts +6 -0
  158. package/types/qq/login.d.ts +6 -0
  159. package/types/types.d.ts +85 -0
  160. package/types/villa/alemon/conversation.d.ts +7 -0
  161. package/types/villa/alemon/message/GUILDS.d.ts +10 -0
  162. package/types/villa/alemon/message/GUILD_MEMBERS.d.ts +14 -0
  163. package/types/villa/alemon/message/GUILD_MESSAGE_REACTIONS.d.ts +7 -0
  164. package/types/villa/alemon/message/MESSAGES.d.ts +7 -0
  165. package/types/villa/alemon/message/MESSAGE_AUDIT.d.ts +10 -0
  166. package/types/villa/alemon/message/e.d.ts +37 -0
  167. package/types/villa/alemon/segment.d.ts +26 -0
  168. package/types/villa/index.d.ts +1 -0
  169. package/types/villa/login.d.ts +7 -0
@@ -0,0 +1,139 @@
1
+ import { SessionEvents, AvailableIntentsEventsEnum } from 'qq-guild-bot';
2
+ import { GUILDS } from './message/GUILDS.js';
3
+ import { GUILD_MEMBERS } from './message/GUILD_MEMBERS.js';
4
+ import { DIRECT_MESSAGE } from './message/DIRECT_MESSAGE.js';
5
+ import { PUBLIC_GUILD_MESSAGES } from './message/PUBLIC_GUILD_MESSAGES.js';
6
+ import { GUILD_MESSAGE_REACTIONS } from './message/GUILD_MESSAGE_REACTIONS.js';
7
+ import { OPEN_FORUMS_EVENT } from './message/OPEN_FORUMS_EVENT.js';
8
+ import { GUILD_MESSAGES } from './message/GUILD_MESSAGES.js';
9
+ import { INTERACTION } from './message/INTERACTION.js';
10
+ import { MESSAGE_AUDIT } from './message/MESSAGE_AUDIT.js';
11
+ import { AUDIO_ACTION } from './message/AUDIO_ACTION.js';
12
+ import { FORUMS_EVENT } from './message/FORUMS_EVENT.js';
13
+ import { setBotMsgByQQ } from './bot.js';
14
+ import { getBotConfigByKey } from '../../login.js';
15
+ /**
16
+ * 会话事件分类
17
+ * @param ws
18
+ */
19
+ export const createConversationByQQ = ws => {
20
+ /**
21
+ * 准备
22
+ */
23
+ ws.on(SessionEvents.READY, async (data) => {
24
+ const cfg = getBotConfigByKey('qq');
25
+ if (cfg.sandbox)
26
+ console.info('[READY]', data);
27
+ const robot = data.msg;
28
+ const bot = {
29
+ id: robot.user.id,
30
+ name: robot.user.username,
31
+ avatar: 'string'
32
+ };
33
+ // 设置bot信息
34
+ setBotMsgByQQ(bot);
35
+ /**
36
+ * 基础权限
37
+ */
38
+ /**
39
+ * 机器人进出频道消息
40
+ */
41
+ ws.on(AvailableIntentsEventsEnum.GUILDS, GUILDS);
42
+ /**
43
+ * 成员频道进出变动消息
44
+ */
45
+ ws.on(AvailableIntentsEventsEnum.GUILD_MEMBERS, GUILD_MEMBERS);
46
+ /**
47
+ * 私聊会话消息
48
+ */
49
+ ws.on(AvailableIntentsEventsEnum.DIRECT_MESSAGE, DIRECT_MESSAGE);
50
+ /**
51
+ * 频道会话消息(公域)
52
+ */
53
+ ws.on(AvailableIntentsEventsEnum.PUBLIC_GUILD_MESSAGES, PUBLIC_GUILD_MESSAGES);
54
+ /**
55
+ * ***
56
+ * 需申请权限
57
+ * **
58
+ */
59
+ /**
60
+ * 频道会话消息(私域)
61
+ */
62
+ ws.on(AvailableIntentsEventsEnum.GUILD_MESSAGES, GUILD_MESSAGES);
63
+ /**
64
+ * 论坛消息(私域)
65
+ */
66
+ ws.on(AvailableIntentsEventsEnum.FORUMS_EVENT, FORUMS_EVENT);
67
+ /**
68
+ * 论坛消息(公域)
69
+ */
70
+ ws.on('OPEN_FORUMS_EVENT', OPEN_FORUMS_EVENT);
71
+ /**
72
+ * 频道表情点击会话消息
73
+ */
74
+ ws.on(AvailableIntentsEventsEnum.GUILD_MESSAGE_REACTIONS, GUILD_MESSAGE_REACTIONS);
75
+ /**
76
+ * 互动事件监听
77
+ */
78
+ ws.on(AvailableIntentsEventsEnum.INTERACTION, INTERACTION);
79
+ ws.on(AvailableIntentsEventsEnum.MESSAGE_AUDIT, MESSAGE_AUDIT);
80
+ /**
81
+ * 审核事件监听
82
+ */
83
+ ws.on(AvailableIntentsEventsEnum.AUDIO_ACTION, AUDIO_ACTION);
84
+ console.info('[READY]', ` 欢迎回来 ${bot.name}`);
85
+ });
86
+ /**
87
+ * 权限错误
88
+ */
89
+ ws.on(SessionEvents.ERROR, (one) => {
90
+ console.error('[ERROR]', one);
91
+ });
92
+ /**
93
+ * 超长断连
94
+ */
95
+ ws.on(SessionEvents.DEAD, (one) => {
96
+ console.error('DEAD', one);
97
+ console.error('请确认配置!');
98
+ console.error('账户密码是否正确?');
99
+ console.error('域事件是否匹配?');
100
+ });
101
+ /**
102
+ * 关闭
103
+ */
104
+ ws.on(SessionEvents.CLOSED, (one) => {
105
+ console.error('[CLOSED]', one);
106
+ });
107
+ /**
108
+ * 断开连接
109
+ */
110
+ ws.on(SessionEvents.DISCONNECT, (one) => {
111
+ console.error('[DISCONNECT]', one);
112
+ });
113
+ /**
114
+ * 无效会话
115
+ */
116
+ ws.on(SessionEvents.INVALID_SESSION, (one) => {
117
+ console.error('[INVALID_SESSION]', one);
118
+ });
119
+ /**
120
+ * 再连接
121
+ */
122
+ ws.on(SessionEvents.RECONNECT, (one) => {
123
+ console.error('[RECONNECT]', one);
124
+ });
125
+ /**
126
+ * 重新开始
127
+ */
128
+ ws.on(SessionEvents.RESUMED, (one) => {
129
+ console.error('[RESUMED]', one);
130
+ });
131
+ /**
132
+ * WS断连
133
+ */
134
+ ws.on(SessionEvents.EVENT_WS, async (one) => {
135
+ if (one.eventType == 'DISCONNECT') {
136
+ console.info('[EVENT_WS][DISCONNECT]', one);
137
+ }
138
+ });
139
+ };
@@ -0,0 +1,93 @@
1
+ /**
2
+ * ********************
3
+ * 会被主人限制的权限
4
+ * *******************
5
+ * 是否允许主动发消息:
6
+ * 允许发送的次数
7
+ * 是否允许私聊
8
+ */
9
+ export {};
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
+ * 拉去表情表态列表 (使用消息ID)
89
+ */
90
+ /**
91
+ * 子频道机器人(也是普通机器人)
92
+ * 机器人没有身份组的概念
93
+ */
@@ -0,0 +1,41 @@
1
+ export const now_e = {
2
+ /**
3
+ * 卡片
4
+ * @param obj
5
+ * @returns
6
+ */
7
+ replyCard: async (obj) => {
8
+ console.info('待实现');
9
+ return false;
10
+ },
11
+ /**
12
+ * 引用消息
13
+ * @param mid
14
+ * @param boj
15
+ * @returns
16
+ */
17
+ replyByMid: async (mid, msg) => {
18
+ console.info('待实现');
19
+ return false;
20
+ },
21
+ /**
22
+ * 发送表情表态
23
+ * @param mid
24
+ * @param boj { emoji_type: number; emoji_id: string }
25
+ * @returns
26
+ */
27
+ replyEmoji: async (mid, boj) => {
28
+ console.info('待实现');
29
+ return false;
30
+ },
31
+ /**
32
+ * 删除表情表态
33
+ * @param mid
34
+ * @param boj { emoji_type: number; emoji_id: string }
35
+ * @returns
36
+ */
37
+ deleteEmoji: async (mid, boj) => {
38
+ console.info('待实现');
39
+ return false;
40
+ }
41
+ };
@@ -0,0 +1,57 @@
1
+ import { typeMessage } from '../../../alemon/index.js';
2
+ import { getBotMsgByQQ } from '../bot.js';
3
+ /**
4
+ * AUDIO_MICROPHONE 音频
5
+ * AUDIO_FREQUENCY 麦克风
6
+ */
7
+ /**
8
+ * DO
9
+ */
10
+ /**
11
+ AUDIO_ACTION (1 << 29)
12
+ - AUDIO_START // 音频开始播放时 create
13
+ - AUDIO_FINISH // 音频播放结束时 delete
14
+ - AUDIO_ON_MIC // 上麦时 create
15
+ - AUDIO_OFF_MIC // 下麦时 delete
16
+ */
17
+ export const AUDIO_ACTION = async (event) => {
18
+ const e = {
19
+ platform: 'qq',
20
+ bot: getBotMsgByQQ(),
21
+ event: 'AUDIO_MICROPHONE',
22
+ eventType: 'CREATE',
23
+ isPrivate: false,
24
+ isRecall: false,
25
+ isGroup: false
26
+ };
27
+ if (new RegExp(/MIC$/).test(event.eventType)) {
28
+ if (!new RegExp(/ON_MIC$/).test(event.eventType)) {
29
+ /**
30
+ * 下麦
31
+ */
32
+ e.eventType = 'DELETE';
33
+ }
34
+ }
35
+ else {
36
+ /**
37
+ * 音频事件
38
+ */
39
+ e.event = 'AUDIO_FREQUENCY';
40
+ if (!new RegExp(/^AUDIO_START$/).test(event.eventType)) {
41
+ /**
42
+ * 音频播放结束时
43
+ */
44
+ e.eventType = 'DELETE';
45
+ }
46
+ }
47
+ await typeMessage(e)
48
+ .then(() => {
49
+ console.info(`\n[${e.event}] [${e.eventType}] [${true}]`);
50
+ return true;
51
+ })
52
+ .catch(err => {
53
+ console.error(err);
54
+ console.info(`\n[${e.event}] [${e.eventType}]\n${false}`);
55
+ return false;
56
+ });
57
+ };
@@ -0,0 +1,202 @@
1
+ import { typeMessage, InstructionMatching } from '../../../alemon/index.js';
2
+ import { ClientAPIByQQ as Client } from 'qq-channel';
3
+ import { segmentQQ } from '../segment.js';
4
+ import { getBotMsgByQQ } from '../bot.js';
5
+ /**
6
+ * *
7
+ * 私信
8
+ * *
9
+ */
10
+ /**
11
+ DIRECT_MESSAGE (1 << 12)
12
+ - DIRECT_MESSAGE_CREATE // 当收到用户发给机器人的私信消息时
13
+ - DIRECT_MESSAGE_DELETE // 删除(撤回)消息事件
14
+ */
15
+ export const DIRECT_MESSAGE = async (event) => {
16
+ const e = {
17
+ platform: 'qq',
18
+ bot: getBotMsgByQQ(),
19
+ event: 'MESSAGES',
20
+ eventType: 'CREATE',
21
+ isPrivate: false,
22
+ isRecall: false,
23
+ isGroup: false
24
+ };
25
+ /**
26
+ * 撤回事件
27
+ */
28
+ if (new RegExp(/^DIRECT_MESSAGE_DELETE$/).test(event.eventType)) {
29
+ e.eventType = 'DELETE';
30
+ e.isRecall = true;
31
+ /**
32
+ * 只匹配类型
33
+ */
34
+ await typeMessage(e)
35
+ .then(() => {
36
+ console.info(`\n[${e.event}] [${e.eventType}] [${true}]`);
37
+ return true;
38
+ })
39
+ .catch(err => {
40
+ console.error(err);
41
+ console.error(`\n[${e.event}] [${e.eventType}] [${false}]`);
42
+ return false;
43
+ });
44
+ return;
45
+ }
46
+ /**
47
+ * 优化接口
48
+ */
49
+ await directMessage(e, event).catch(err => {
50
+ console.error(err);
51
+ return;
52
+ });
53
+ console.info(`\n[${event.msg.author.username}][${event.msg.author.id}][${e.isGroup}] ${event.msg.content ? event.msg.content : ''}`);
54
+ };
55
+ async function directMessage(e, event) {
56
+ /* 消息发送机制 */
57
+ e.reply = async (msg, img, name) => {
58
+ if (Buffer.isBuffer(msg)) {
59
+ try {
60
+ return await Client.postDirectImage({
61
+ id: event.msg.guild_id,
62
+ msg_id: event.msg.id,
63
+ image: msg,
64
+ name: typeof img == 'string' ? img : undefined
65
+ })
66
+ .then(() => true)
67
+ .catch((err) => {
68
+ console.error(err);
69
+ return false;
70
+ });
71
+ }
72
+ catch (err) {
73
+ console.error(err);
74
+ return false;
75
+ }
76
+ }
77
+ const content = Array.isArray(msg)
78
+ ? msg.join('')
79
+ : typeof msg === 'string'
80
+ ? msg
81
+ : undefined;
82
+ if (Buffer.isBuffer(img)) {
83
+ try {
84
+ return await Client.postDirectImage({
85
+ id: event.msg.guild_id,
86
+ msg_id: event.msg.id,
87
+ image: img,
88
+ content,
89
+ name: name
90
+ })
91
+ .then(() => true)
92
+ .catch((err) => {
93
+ console.error(err);
94
+ return false;
95
+ });
96
+ }
97
+ catch (err) {
98
+ console.error(err);
99
+ return false;
100
+ }
101
+ }
102
+ return await clientApiByQQ.directMessageApi
103
+ .postDirectMessage(event.msg.guild_id, {
104
+ msg_id: event.msg.id,
105
+ content
106
+ })
107
+ .then(() => true)
108
+ .catch((err) => {
109
+ console.error(err);
110
+ return false;
111
+ });
112
+ };
113
+ e.replyCard = async (arr) => {
114
+ for (const item of arr) {
115
+ try {
116
+ if (item.type == 'qq_ark' || item.type == 'qq_embed') {
117
+ await clientApiByQQ.messageApi
118
+ .postMessage(event.msg.channel_id, {
119
+ msg_id: event.msg.id,
120
+ ...item.card
121
+ })
122
+ .then(() => true)
123
+ .catch((err) => {
124
+ console.error(err);
125
+ return false;
126
+ });
127
+ }
128
+ else {
129
+ return false;
130
+ }
131
+ }
132
+ catch {
133
+ return false;
134
+ }
135
+ }
136
+ return true;
137
+ };
138
+ /**
139
+ * 发送表情表态
140
+ * @param mid
141
+ * @param boj { emoji_type: number; emoji_id: string }
142
+ * @returns
143
+ */
144
+ e.replyEmoji = async (mid, boj) => {
145
+ console.info('不可用');
146
+ return false;
147
+ };
148
+ /**
149
+ * 删除表情表态
150
+ * @param mid
151
+ * @param boj
152
+ * @returns
153
+ */
154
+ e.deleteEmoji = async (mid, boj) => {
155
+ console.info('不可用');
156
+ return false;
157
+ };
158
+ e.msg_txt = event.msg.content;
159
+ e.msg = event.msg.content;
160
+ /**
161
+ * 消息编号
162
+ */
163
+ e.msg_id = event.msg.id;
164
+ e.user_id = event.msg.author.id;
165
+ e.user_avatar = event.msg.author.avatar;
166
+ e.user_name = event.msg.author.username;
167
+ e.channel_id = event.msg.channel_id;
168
+ e.guild_id = event.msg.guild_id;
169
+ e.segment = segmentQQ;
170
+ e.at_users = [];
171
+ e.at_user = {
172
+ id: '0',
173
+ avatar: '0',
174
+ name: '0',
175
+ bot: false
176
+ };
177
+ /**
178
+ * 机器人信息 tudo
179
+ */
180
+ e.bot = {
181
+ id: '',
182
+ name: '',
183
+ avatar: ''
184
+ };
185
+ /**
186
+ * 艾特消息处理
187
+ */
188
+ e.at = false;
189
+ /**
190
+ * 消息处理
191
+ */
192
+ await InstructionMatching(e)
193
+ .then(() => {
194
+ console.info(console.info(`\n[${e.channel_id}] [${e.user_name}] [${true}] \n ${e.msg_txt}`));
195
+ return true;
196
+ })
197
+ .catch((err) => {
198
+ console.error(err);
199
+ console.info(console.info(`\n[${e.channel_id}] [${e.user_name}] [${false}] \n ${e.msg_txt}`));
200
+ return false;
201
+ });
202
+ }
@@ -0,0 +1,66 @@
1
+ import { typeMessage } from '../../../alemon/index.js';
2
+ import { getBotMsgByQQ } from '../bot.js';
3
+ /**
4
+ * ***********
5
+ * THREAD 主题 FORUMS_THREAD
6
+ * POST 帖子 FORUMS_POST
7
+ * REPLY 评论 FORUMS_REPLY
8
+ */
9
+ /**
10
+ * DO
11
+ */
12
+ /**
13
+ FORUMS_EVENT (1 << 28) // 论坛事件,仅 *私域* 机器人能够设置此 intents。
14
+
15
+ - FORUM_THREAD_CREATE // 当用户创建主题时
16
+ - FORUM_THREAD_UPDATE // 当用户更新主题时
17
+ - FORUM_THREAD_DELETE // 当用户删除主题时
18
+
19
+ - FORUM_POST_CREATE // 当用户创建帖子时
20
+ - FORUM_POST_DELETE // 当用户删除帖子时
21
+
22
+ - FORUM_REPLY_CREATE // 当用户回复评论时
23
+ - FORUM_REPLY_DELETE // 当用户删除评论时
24
+
25
+ - FORUM_PUBLISH_AUDIT_RESULT // 当用户发表审核通过时
26
+ */
27
+ export const FORUMS_EVENT = async (event) => {
28
+ const e = {
29
+ platform: 'qq',
30
+ bot: getBotMsgByQQ(),
31
+ event: 'FORUMS_THREAD',
32
+ eventType: 'CREATE',
33
+ isPrivate: false,
34
+ isRecall: false,
35
+ isGroup: false
36
+ };
37
+ /* 事件匹配 */
38
+ if (new RegExp(/^FORUM_THREAD/).test(event.eventType)) {
39
+ e.event = 'FORUMS_THREAD';
40
+ }
41
+ else if (new RegExp(/^FORUM_POST/).test(event.eventType)) {
42
+ e.event = 'FORUMS_POST';
43
+ }
44
+ else {
45
+ e.event = 'FORUMS_REPLY';
46
+ }
47
+ if (new RegExp(/CREATE$/).test(event.eventType)) {
48
+ e.eventType = 'CREATE';
49
+ }
50
+ else if (new RegExp(/UPDATE$/).test(event.eventType)) {
51
+ e.eventType = 'UPDATE';
52
+ }
53
+ else {
54
+ e.eventType = 'DELETE';
55
+ }
56
+ await typeMessage(e)
57
+ .then(() => {
58
+ console.info(`\n[${e.event}] [${e.eventType}] [${true}]`);
59
+ return true;
60
+ })
61
+ .catch(err => {
62
+ console.error(err);
63
+ console.error(`\n[${e.event}] [${e.eventType}] [${false}]`);
64
+ return false;
65
+ });
66
+ };
@@ -0,0 +1,65 @@
1
+ import { typeMessage } from '../../../alemon/index.js';
2
+ import { getBotMsgByQQ } from '../bot.js';
3
+ /**
4
+ * GUILD 频道
5
+ * CHANNEL 子频道
6
+ */
7
+ /**
8
+ * DO
9
+ */
10
+ /**
11
+ GUILDS (1 << 0)
12
+
13
+ - GUILD_CREATE // 当机器人加入新guild时
14
+ - GUILD_UPDATE // 当guild资料发生变更时
15
+ - GUILD_DELETE // 当机器人退出guild时
16
+ -
17
+ - CHANNEL_CREATE // 当channel被创建时
18
+ - CHANNEL_UPDATE // 当channel被更新时
19
+ - CHANNEL_DELETE // 当channel被删除时
20
+ */
21
+ export const GUILDS = async (event) => {
22
+ const e = {
23
+ platform: 'qq',
24
+ bot: getBotMsgByQQ(),
25
+ event: 'GUILD',
26
+ eventType: 'CREATE',
27
+ isPrivate: false,
28
+ isRecall: false,
29
+ isGroup: false
30
+ };
31
+ /**
32
+ * 事件匹配
33
+ */
34
+ if (new RegExp(/^GUILD.*$/).test(event.event)) {
35
+ e.event = 'GUILD';
36
+ }
37
+ else {
38
+ e.event = 'CHANNEL';
39
+ }
40
+ /**
41
+ * 类型匹配
42
+ */
43
+ if (new RegExp(/CREATE$/).test(event.eventType)) {
44
+ e.eventType = 'CREATE';
45
+ }
46
+ else if (new RegExp(/UPDATE$/).test(event.eventType)) {
47
+ e.eventType = 'UPDATE';
48
+ }
49
+ else {
50
+ e.eventType = 'DELETE';
51
+ }
52
+ /**
53
+ * 只匹配类型
54
+ */
55
+ await typeMessage(e)
56
+ .then(() => {
57
+ console.info(`\n[${e.event}] [${e.eventType}] [${true}]`);
58
+ return true;
59
+ })
60
+ .catch(err => {
61
+ console.error(err);
62
+ console.error(`\n[${e.event}] [${e.eventType}] [${false}]`);
63
+ return false;
64
+ });
65
+ };