node-karin 0.12.1 → 0.12.2-5.pr.206.027f2f2

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 (254) hide show
  1. package/CHANGELOG.md +1029 -0
  2. package/default/comment/config.json +34 -0
  3. package/default/comment/friendDirect.json +10 -0
  4. package/default/comment/groupGuild.json +11 -0
  5. package/default/comment/server.json +17 -0
  6. package/default/config/adapter.json +28 -0
  7. package/default/config/config.json +47 -0
  8. package/default/config/groups.json +47 -0
  9. package/default/config/groups.yaml +70 -0
  10. package/default/config/pm2.json +16 -0
  11. package/default/config/privates.json +23 -0
  12. package/default/config/privates.yaml +31 -0
  13. package/default/config/redis.json +10 -0
  14. package/default/config/render.json +19 -0
  15. package/default/view/group.yaml +73 -0
  16. package/dist/index.d.ts +9869 -0
  17. package/dist/index.js +12643 -0
  18. package/dist/module/art-template.cjs +11 -0
  19. package/dist/module/art-template.d.ts +1 -0
  20. package/dist/module/axios.cjs +22 -0
  21. package/dist/module/axios.d.ts +2 -0
  22. package/dist/module/chalk.cjs +22 -0
  23. package/dist/module/chalk.d.ts +2 -0
  24. package/dist/module/chokidar.cjs +22 -0
  25. package/dist/module/chokidar.d.ts +2 -0
  26. package/dist/module/commander.cjs +35 -0
  27. package/dist/module/commander.d.ts +3 -0
  28. package/dist/module/commander.js +3 -0
  29. package/dist/module/dotenv.cjs +22 -0
  30. package/dist/module/dotenv.d.ts +2 -0
  31. package/dist/module/dotenv.js +2 -0
  32. package/dist/module/express.cjs +112 -0
  33. package/dist/module/express.d.ts +1 -0
  34. package/dist/module/express.js +1 -0
  35. package/dist/module/level.cjs +22 -0
  36. package/dist/module/level.d.ts +2 -0
  37. package/dist/module/lodash.cjs +11 -0
  38. package/dist/module/lodash.d.ts +1 -0
  39. package/dist/module/log4js.cjs +22 -0
  40. package/dist/module/log4js.d.ts +2 -0
  41. package/dist/module/moment.cjs +11 -0
  42. package/dist/module/moment.d.ts +1 -0
  43. package/dist/module/node-schedule.cjs +22 -0
  44. package/dist/module/node-schedule.d.ts +2 -0
  45. package/dist/module/redis.cjs +22 -0
  46. package/dist/module/redis.d.ts +2 -0
  47. package/dist/module/ws.cjs +28 -0
  48. package/dist/module/ws.d.ts +1 -0
  49. package/dist/module/ws.js +1 -0
  50. package/dist/module/yaml.cjs +22 -0
  51. package/dist/module/yaml.d.ts +2 -0
  52. package/dist/root.d.ts +40 -0
  53. package/dist/root.js +44 -0
  54. package/package.json +142 -127
  55. package/LICENSE +0 -674
  56. package/README.md +0 -56
  57. package/config/defSet/App.yaml +0 -42
  58. package/config/defSet/config.yaml +0 -65
  59. package/config/defSet/group.yaml +0 -56
  60. package/config/defSet/pm2.yaml +0 -21
  61. package/config/defSet/redis.yaml +0 -18
  62. package/config/defSet/server.yaml +0 -42
  63. package/config/view/group.yaml +0 -92
  64. package/lib/adapter/index.d.ts +0 -2
  65. package/lib/adapter/index.js +0 -2
  66. package/lib/adapter/input/index.d.ts +0 -78
  67. package/lib/adapter/input/index.js +0 -205
  68. package/lib/adapter/onebot/11/convert.d.ts +0 -12
  69. package/lib/adapter/onebot/11/convert.js +0 -167
  70. package/lib/adapter/onebot/11/event.d.ts +0 -25
  71. package/lib/adapter/onebot/11/event.js +0 -442
  72. package/lib/adapter/onebot/11/index.d.ts +0 -508
  73. package/lib/adapter/onebot/11/index.js +0 -1047
  74. package/lib/cli/index.d.ts +0 -92
  75. package/lib/cli/index.js +0 -307
  76. package/lib/cli/init.d.ts +0 -2
  77. package/lib/cli/init.js +0 -22
  78. package/lib/cli/karin.d.ts +0 -2
  79. package/lib/cli/karin.js +0 -16
  80. package/lib/cli/pkg.d.ts +0 -4
  81. package/lib/cli/pkg.js +0 -14
  82. package/lib/cli/start.d.ts +0 -1
  83. package/lib/cli/start.js +0 -8
  84. package/lib/core/index.d.ts +0 -10
  85. package/lib/core/index.js +0 -10
  86. package/lib/core/init/config.d.ts +0 -43
  87. package/lib/core/init/config.js +0 -201
  88. package/lib/core/init/dir.d.ts +0 -4
  89. package/lib/core/init/dir.js +0 -7
  90. package/lib/core/init/init.d.ts +0 -1
  91. package/lib/core/init/init.js +0 -47
  92. package/lib/core/karin/karin.d.ts +0 -198
  93. package/lib/core/karin/karin.js +0 -226
  94. package/lib/core/listener/listener.d.ts +0 -145
  95. package/lib/core/listener/listener.js +0 -235
  96. package/lib/core/plugin/base.d.ts +0 -156
  97. package/lib/core/plugin/base.js +0 -131
  98. package/lib/core/plugin/loader.d.ts +0 -141
  99. package/lib/core/plugin/loader.js +0 -618
  100. package/lib/core/process/process.d.ts +0 -18
  101. package/lib/core/process/process.js +0 -96
  102. package/lib/core/server/server.d.ts +0 -25
  103. package/lib/core/server/server.js +0 -295
  104. package/lib/db/index.d.ts +0 -2
  105. package/lib/db/index.js +0 -2
  106. package/lib/db/level/level.d.ts +0 -19
  107. package/lib/db/level/level.js +0 -36
  108. package/lib/db/redis/redis.d.ts +0 -2
  109. package/lib/db/redis/redis.js +0 -135
  110. package/lib/db/redis/redis_level.d.ts +0 -112
  111. package/lib/db/redis/redis_level.js +0 -281
  112. package/lib/event/handler/base.d.ts +0 -42
  113. package/lib/event/handler/base.js +0 -200
  114. package/lib/event/handler/message.d.ts +0 -25
  115. package/lib/event/handler/message.js +0 -302
  116. package/lib/event/handler/notice.d.ts +0 -18
  117. package/lib/event/handler/notice.js +0 -214
  118. package/lib/event/handler/request.d.ts +0 -18
  119. package/lib/event/handler/request.js +0 -115
  120. package/lib/event/handler/review.d.ts +0 -55
  121. package/lib/event/handler/review.js +0 -386
  122. package/lib/event/index.d.ts +0 -5
  123. package/lib/event/index.js +0 -5
  124. package/lib/index.d.ts +0 -8
  125. package/lib/index.js +0 -8
  126. package/lib/modules/art-template.d.ts +0 -1
  127. package/lib/modules/axios.d.ts +0 -2
  128. package/lib/modules/chalk.d.ts +0 -2
  129. package/lib/modules/chokidar.d.ts +0 -2
  130. package/lib/modules/commander.d.ts +0 -2
  131. package/lib/modules/commander.js +0 -2
  132. package/lib/modules/express.d.ts +0 -3
  133. package/lib/modules/express.js +0 -3
  134. package/lib/modules/level.d.ts +0 -2
  135. package/lib/modules/lodash.d.ts +0 -1
  136. package/lib/modules/log4js.d.ts +0 -2
  137. package/lib/modules/moment.d.ts +0 -1
  138. package/lib/modules/node-schedule.d.ts +0 -2
  139. package/lib/modules/redis.d.ts +0 -2
  140. package/lib/modules/ws.d.ts +0 -3
  141. package/lib/modules/ws.js +0 -3
  142. package/lib/modules/yaml.d.ts +0 -2
  143. package/lib/modules.d.ts +0 -15
  144. package/lib/modules.js +0 -15
  145. package/lib/render/app.d.ts +0 -56
  146. package/lib/render/app.js +0 -120
  147. package/lib/render/base.d.ts +0 -30
  148. package/lib/render/base.js +0 -69
  149. package/lib/render/client.d.ts +0 -41
  150. package/lib/render/client.js +0 -238
  151. package/lib/render/http.d.ts +0 -19
  152. package/lib/render/http.js +0 -50
  153. package/lib/render/index.d.ts +0 -6
  154. package/lib/render/index.js +0 -6
  155. package/lib/render/server.d.ts +0 -25
  156. package/lib/render/server.js +0 -101
  157. package/lib/render/wormhole.d.ts +0 -1
  158. package/lib/render/wormhole.js +0 -156
  159. package/lib/types/adapter/api.d.ts +0 -399
  160. package/lib/types/adapter/api.js +0 -1
  161. package/lib/types/adapter/base.d.ts +0 -560
  162. package/lib/types/adapter/base.js +0 -1
  163. package/lib/types/config/config.d.ts +0 -379
  164. package/lib/types/config/config.js +0 -1
  165. package/lib/types/element/element.d.ts +0 -565
  166. package/lib/types/element/element.js +0 -1
  167. package/lib/types/element/qqbot.d.ts +0 -123
  168. package/lib/types/element/qqbot.js +0 -1
  169. package/lib/types/event/contact.d.ts +0 -28
  170. package/lib/types/event/contact.js +0 -1
  171. package/lib/types/event/event.d.ts +0 -305
  172. package/lib/types/event/event.js +0 -1
  173. package/lib/types/event/index.d.ts +0 -12
  174. package/lib/types/event/index.js +0 -7
  175. package/lib/types/event/message.d.ts +0 -109
  176. package/lib/types/event/message.js +0 -74
  177. package/lib/types/event/notice.d.ts +0 -513
  178. package/lib/types/event/notice.js +0 -52
  179. package/lib/types/event/reply.d.ts +0 -50
  180. package/lib/types/event/reply.js +0 -1
  181. package/lib/types/event/request.d.ts +0 -126
  182. package/lib/types/event/request.js +0 -52
  183. package/lib/types/event/sender.d.ts +0 -44
  184. package/lib/types/event/sender.js +0 -1
  185. package/lib/types/index.d.ts +0 -13
  186. package/lib/types/index.js +0 -13
  187. package/lib/types/logger/logger.d.ts +0 -110
  188. package/lib/types/logger/logger.js +0 -1
  189. package/lib/types/onebot11/api.d.ts +0 -53
  190. package/lib/types/onebot11/api.js +0 -1
  191. package/lib/types/onebot11/event.d.ts +0 -619
  192. package/lib/types/onebot11/event.js +0 -2
  193. package/lib/types/onebot11/index.d.ts +0 -6
  194. package/lib/types/onebot11/index.js +0 -6
  195. package/lib/types/onebot11/params.d.ts +0 -609
  196. package/lib/types/onebot11/params.js +0 -1
  197. package/lib/types/onebot11/response.d.ts +0 -516
  198. package/lib/types/onebot11/response.js +0 -1
  199. package/lib/types/onebot11/segment.d.ts +0 -269
  200. package/lib/types/onebot11/segment.js +0 -1
  201. package/lib/types/onebot11/sender.d.ts +0 -59
  202. package/lib/types/onebot11/sender.js +0 -1
  203. package/lib/types/plugin/app.d.ts +0 -71
  204. package/lib/types/plugin/app.js +0 -1
  205. package/lib/types/plugin/plugin.d.ts +0 -473
  206. package/lib/types/plugin/plugin.js +0 -1
  207. package/lib/types/render/render.d.ts +0 -118
  208. package/lib/types/render/render.js +0 -1
  209. package/lib/types/type/global.d.ts +0 -25
  210. package/lib/types/type/global.js +0 -1
  211. package/lib/utils/common/common.d.ts +0 -236
  212. package/lib/utils/common/common.js +0 -708
  213. package/lib/utils/config/config.d.ts +0 -193
  214. package/lib/utils/config/config.js +0 -328
  215. package/lib/utils/config/updateVersion.d.ts +0 -33
  216. package/lib/utils/config/updateVersion.js +0 -145
  217. package/lib/utils/config/yamlEditor.d.ts +0 -101
  218. package/lib/utils/config/yamlEditor.js +0 -330
  219. package/lib/utils/core/handler.d.ts +0 -18
  220. package/lib/utils/core/handler.js +0 -46
  221. package/lib/utils/core/logger.d.ts +0 -3
  222. package/lib/utils/core/logger.js +0 -105
  223. package/lib/utils/core/segment.d.ts +0 -279
  224. package/lib/utils/core/segment.js +0 -451
  225. package/lib/utils/index.d.ts +0 -13
  226. package/lib/utils/index.js +0 -13
  227. package/lib/utils/tools/button.d.ts +0 -2
  228. package/lib/utils/tools/button.js +0 -27
  229. package/lib/utils/tools/exec.d.ts +0 -20
  230. package/lib/utils/tools/exec.js +0 -54
  231. package/lib/utils/tools/ffmpeg.d.ts +0 -12
  232. package/lib/utils/tools/ffmpeg.js +0 -25
  233. package/lib/utils/tools/restart.d.ts +0 -15
  234. package/lib/utils/tools/restart.js +0 -39
  235. package/lib/utils/tools/stop.d.ts +0 -7
  236. package/lib/utils/tools/stop.js +0 -13
  237. package/lib/utils/tools/update.d.ts +0 -67
  238. package/lib/utils/tools/update.js +0 -151
  239. /package/{config → default}/view/App.yaml +0 -0
  240. /package/{config → default}/view/config.yaml +0 -0
  241. /package/{config → default}/view/pm2.yaml +0 -0
  242. /package/{config → default}/view/redis.yaml +0 -0
  243. /package/{config → default}/view/server.yaml +0 -0
  244. /package/{lib/modules → dist/module}/art-template.js +0 -0
  245. /package/{lib/modules → dist/module}/axios.js +0 -0
  246. /package/{lib/modules → dist/module}/chalk.js +0 -0
  247. /package/{lib/modules → dist/module}/chokidar.js +0 -0
  248. /package/{lib/modules → dist/module}/level.js +0 -0
  249. /package/{lib/modules → dist/module}/lodash.js +0 -0
  250. /package/{lib/modules → dist/module}/log4js.js +0 -0
  251. /package/{lib/modules → dist/module}/moment.js +0 -0
  252. /package/{lib/modules → dist/module}/node-schedule.js +0 -0
  253. /package/{lib/modules → dist/module}/redis.js +0 -0
  254. /package/{lib/modules → dist/module}/yaml.js +0 -0
@@ -1,279 +0,0 @@
1
- import { TextElement, AtElement, ImageElement, FaceElement, BubbleFaceElement, ReplyElement, VideoElement, BasketballElement, DiceElement, RpsElement, PokeElement, MusicElement, WeatherElement, LocationElement, ShareElement, GiftElement, MarketFaceElement, ForwardElement, ContactElement, JsonElement, XmlElement, FileElement, ButtonElement, CustomMusicElemen, TplMarkdownElement, RawMarkdownElement, NodeElement, KarinElement, LongMsgElement, RecordElement, KeyBoardElement, Button } from '../../types/index.js';
2
- export declare const segment: {
3
- /**
4
- * 纯文本
5
- * @param text - 文本内容
6
- * @returns {TextElement} 纯文本元素
7
- */
8
- text(text: string): TextElement;
9
- /**
10
- * 提及
11
- * 提供一个uid即可
12
- * @param uid - uid
13
- * @param uin - uin
14
- * @param name - 名称
15
- * @returns {AtElement} 提及元素
16
- */
17
- at(uid: string, uin?: string, name?: string): AtElement;
18
- /**
19
- * 表情
20
- * @param id - 表情ID
21
- * @param is_big - 是否大表情,默认不是
22
- * @returns {FaceElement} 表情元素
23
- */
24
- face(id: number, is_big?: boolean): FaceElement;
25
- /**
26
- * 弹射表情
27
- * @param id - 表情ID
28
- * @param count - 数量
29
- * @returns {BubbleFaceElement} 弹射表情元素
30
- */
31
- bubble_face(id: number, count?: number): BubbleFaceElement;
32
- /**
33
- * 引用回复
34
- * @param message_id - 消息ID
35
- * @returns {ReplyElement} 引用回复元素
36
- */
37
- reply(message_id: string): ReplyElement;
38
- /**
39
- * 图片
40
- * - 一般情况提供一个file参数即可,其他参数一般为收到的消息中的参数
41
- * @param file - 图片URL或路径、Base64
42
- * @param options - 图片类型、名称、MD5、子类型、宽度、高度
43
- * @returns {ImageElement} 图片元素
44
- */
45
- image(file: string, options?: {
46
- /**
47
- * - 图片类型,show: 展示图片,flash: 闪照,original: 原图
48
- */
49
- file_type?: "show" | "flash" | "original";
50
- /**
51
- * - 图片名称
52
- */
53
- name?: string;
54
- /**
55
- * - 图片MD5
56
- */
57
- md5?: string;
58
- /**
59
- * - 图片子类型
60
- */
61
- sub_type?: string;
62
- /**
63
- * - 图片宽度
64
- */
65
- width?: number;
66
- /**
67
- * - 图片高度
68
- */
69
- height?: number;
70
- }): ImageElement;
71
- /**
72
- * 语音
73
- * @param file - 语音URL或路径、Base64
74
- * @param magic - 是否魔法语音,默认为 false
75
- * @param md5 - 语音md5
76
- * @param name - 语音名称
77
- */
78
- record(file: string, magic?: boolean, md5?: string, name?: string): RecordElement;
79
- /**
80
- * 语音 即将废弃 请使用segment.record
81
- * @param file - 语音URL或路径、Base64
82
- * @param magic - 是否魔法语音,默认为 false
83
- * @param md5 - 语音md5
84
- * @param name - 语音名称
85
- */
86
- voice(file: string, magic?: boolean, md5?: string, name?: string): RecordElement;
87
- /**
88
- * 视频
89
- * @param file - 视频URL或路径、Base64
90
- * @param md5 - 视频md5
91
- * @param name - 视频名称
92
- * @returns {VideoElement} 视频元素
93
- */
94
- video(file: string, md5?: string, name?: string): VideoElement;
95
- /**
96
- * 篮球
97
- * @param id - 篮球ID
98
- * @returns {BasketballElement} 篮球元素
99
- */
100
- basketball(id: number): BasketballElement;
101
- /**
102
- * 骰子
103
- * @param id - 骰子ID
104
- * @returns {DiceElement} 骰子元素
105
- */
106
- dice(id: number): DiceElement;
107
- /**
108
- * 石头剪刀布
109
- * @param id - 石头剪刀布ID
110
- * @returns {RpsElement} 石头剪刀布元素
111
- */
112
- rps(id: number): RpsElement;
113
- /**
114
- * 戳一戳
115
- * @param id - 戳一戳ID
116
- * @param poke_type - 戳一戳类型
117
- * @param strength - 戳一戳强度(1-5 默认1)
118
- * @returns {PokeElement} 戳一戳元素
119
- */
120
- poke(id: number, poke_type: number, strength?: number): PokeElement;
121
- /**
122
- * 自定义音乐
123
- * @param url - 跳转链接
124
- * @param audio - 音乐音频链接
125
- * @param title - 标题
126
- * @param author - 歌手
127
- * @param pic - 封面
128
- * @returns {CustomMusicElemen} 自定义音乐元素
129
- */
130
- customMusic(url: string, audio: string, title: string, author: string, pic: string, id: string): CustomMusicElemen;
131
- /**
132
- * 音乐
133
- * @param platform - 音乐平台
134
- * @param id - 音乐ID
135
- * @returns {MusicElement} 音乐元素
136
- */
137
- music(platform: "QQ" | "netease" | "custom", id: string): MusicElement;
138
- /**
139
- * 天气
140
- * @param city - 城市名称
141
- * @param code - 城市代码
142
- * @returns {WeatherElement} 天气元素
143
- */
144
- weather(city: string, code: string): WeatherElement;
145
- /**
146
- * 位置
147
- * @param lat - 纬度
148
- * @param lon - 经度
149
- * @param title - 标题
150
- * @param address - 地址
151
- * @returns {LocationElement} 位置元素
152
- */
153
- location(lat: number, lon: number, title: string, address: string): LocationElement;
154
- /**
155
- * 分享
156
- * @param url - 分享链接
157
- * @param title - 分享标题
158
- * @param content - 分享内容
159
- * @param image - 分享图片
160
- * @returns {ShareElement} 分享元素
161
- */
162
- share(url: string, title: string, content: string, image: string): ShareElement;
163
- /**
164
- * 礼物
165
- * @param qq - QQ 号
166
- * @param id - 礼物ID
167
- * @returns {GiftElement} 礼物元素
168
- */
169
- gift(qq: number, id: number): GiftElement;
170
- /**
171
- * 商城表情
172
- * @param id - 表情ID
173
- * @returns {MarketFaceElement} 商城表情元素
174
- */
175
- marketFace(id: string): MarketFaceElement;
176
- /**
177
- * 转发
178
- * @param res_id - 资源ID
179
- * @param uniseq - 序列号(可能不对?)
180
- * @param summary - 摘要
181
- * @param description - 描述
182
- * @returns {ForwardElement} 转发元素
183
- */
184
- forward(res_id: string, uniseq?: string, summary?: string, description?: string): ForwardElement;
185
- /**
186
- * 分享名片
187
- * @param scene - 分享类型
188
- * @param peer - 被推荐人的QQ号或者被推荐群的群号
189
- * @returns {ContactElement} 分享名片元素
190
- */
191
- contact(scene: "group" | "friend", peer: string): ContactElement;
192
- /**
193
- * JSON
194
- * @param data - JSON序列化过的字符串
195
- * @returns {JsonElement} JSON元素
196
- */
197
- json(data: string): JsonElement;
198
- /**
199
- * XML
200
- * @param data - XML字符串
201
- * @returns {XmlElement} XML元素
202
- */
203
- xml(data: string): XmlElement;
204
- /**
205
- * 文件
206
- */
207
- file(options: {
208
- /**
209
- * - 文件URL
210
- */
211
- url: string;
212
- /**
213
- * - 文件名称
214
- */
215
- name?: string;
216
- /**
217
- * - 文件大小
218
- */
219
- size?: number;
220
- /**
221
- * - 文件过期时间
222
- */
223
- expire_time?: number;
224
- /**
225
- * - 文件ID
226
- */
227
- id?: string;
228
- /**
229
- * - 未知
230
- */
231
- biz?: number;
232
- /**
233
- * - 文件子ID
234
- */
235
- sub_id?: string;
236
- /**
237
- * - 文件MD5
238
- */
239
- md5?: string;
240
- }): FileElement;
241
- /**
242
- * 长消息
243
- * @param id - ID
244
- */
245
- long_msg(id: string): LongMsgElement;
246
- /**
247
- * Markdown
248
- * @param content - 原生markdown内容
249
- * @param config - 未知的参数
250
- */
251
- markdown(content: RawMarkdownElement["content"], config?: RawMarkdownElement["config"]): RawMarkdownElement;
252
- /**
253
- * 构建模板Markdown
254
- * @param custom_template_id - 模板ID
255
- * @param params - 模板markdown参数
256
- */
257
- markdown_tpl(custom_template_id: TplMarkdownElement["custom_template_id"], params: TplMarkdownElement["params"]): TplMarkdownElement;
258
- /**
259
- * 按钮 构建单行单个(obj)、多个按钮(obj[])
260
- * @param data - 按钮数据
261
- * @returns {ButtonElement} 按钮元素
262
- */
263
- button(data: Button | Array<Button>): {
264
- type: ButtonElement["type"];
265
- data: Array<Button>;
266
- };
267
- /**
268
- * 多维按钮
269
- * @param data - 按钮数据
270
- */
271
- keyboard(data: Array<Button> | Array<Array<Button>>): KeyBoardElement;
272
- /**
273
- * 转发自定义节点
274
- * @param user_id - 用户ID
275
- * @param nickname - 用户昵称
276
- * @param content - 节点内容
277
- */
278
- node(user_id: string, nickname: string, content: KarinElement | Array<KarinElement>): NodeElement;
279
- };
@@ -1,451 +0,0 @@
1
- export const segment = new (class Segment {
2
- /**
3
- * 纯文本
4
- * @param text - 文本内容
5
- * @returns {TextElement} 纯文本元素
6
- */
7
- text(text) {
8
- return {
9
- type: 'text',
10
- text: text + '',
11
- };
12
- }
13
- /**
14
- * 提及
15
- * 提供一个uid即可
16
- * @param uid - uid
17
- * @param uin - uin
18
- * @param name - 名称
19
- * @returns {AtElement} 提及元素
20
- */
21
- at(uid, uin, name) {
22
- return {
23
- type: 'at',
24
- uid: uid + '',
25
- uin: (uin || '') + '',
26
- name,
27
- };
28
- }
29
- /**
30
- * 表情
31
- * @param id - 表情ID
32
- * @param is_big - 是否大表情,默认不是
33
- * @returns {FaceElement} 表情元素
34
- */
35
- face(id, is_big = false) {
36
- return {
37
- type: 'face',
38
- id: Number(id),
39
- is_big,
40
- };
41
- }
42
- /**
43
- * 弹射表情
44
- * @param id - 表情ID
45
- * @param count - 数量
46
- * @returns {BubbleFaceElement} 弹射表情元素
47
- */
48
- bubble_face(id, count = 1) {
49
- return {
50
- type: 'bubble_face',
51
- id: Number(id),
52
- count: Number(count),
53
- };
54
- }
55
- /**
56
- * 引用回复
57
- * @param message_id - 消息ID
58
- * @returns {ReplyElement} 引用回复元素
59
- */
60
- reply(message_id) {
61
- return {
62
- type: 'reply',
63
- message_id: message_id + '',
64
- };
65
- }
66
- /**
67
- * 图片
68
- * - 一般情况提供一个file参数即可,其他参数一般为收到的消息中的参数
69
- * @param file - 图片URL或路径、Base64
70
- * @param options - 图片类型、名称、MD5、子类型、宽度、高度
71
- * @returns {ImageElement} 图片元素
72
- */
73
- image(file, options = {}) {
74
- const file_type = options.file_type || 'original';
75
- const name = options.name || '';
76
- const md5 = options.md5 || '';
77
- const sub_type = options.sub_type || '';
78
- const width = options.width || 0;
79
- const height = options.height || 0;
80
- return {
81
- type: 'image',
82
- file,
83
- file_type,
84
- name,
85
- md5,
86
- sub_type,
87
- width,
88
- height,
89
- };
90
- }
91
- /**
92
- * 语音
93
- * @param file - 语音URL或路径、Base64
94
- * @param magic - 是否魔法语音,默认为 false
95
- * @param md5 - 语音md5
96
- * @param name - 语音名称
97
- */
98
- record(file, magic = false, md5 = '', name = '') {
99
- return {
100
- type: 'record',
101
- file,
102
- magic,
103
- md5,
104
- name,
105
- };
106
- }
107
- /**
108
- * 语音 即将废弃 请使用segment.record
109
- * @param file - 语音URL或路径、Base64
110
- * @param magic - 是否魔法语音,默认为 false
111
- * @param md5 - 语音md5
112
- * @param name - 语音名称
113
- */
114
- voice(file, magic = false, md5 = '', name = '') {
115
- return {
116
- type: 'record',
117
- file,
118
- magic,
119
- md5,
120
- name,
121
- };
122
- }
123
- /**
124
- * 视频
125
- * @param file - 视频URL或路径、Base64
126
- * @param md5 - 视频md5
127
- * @param name - 视频名称
128
- * @returns {VideoElement} 视频元素
129
- */
130
- video(file, md5 = '', name = '') {
131
- return {
132
- type: 'video',
133
- file,
134
- md5,
135
- name,
136
- };
137
- }
138
- /**
139
- * 篮球
140
- * @param id - 篮球ID
141
- * @returns {BasketballElement} 篮球元素
142
- */
143
- basketball(id) {
144
- return {
145
- type: 'basketball',
146
- id,
147
- };
148
- }
149
- /**
150
- * 骰子
151
- * @param id - 骰子ID
152
- * @returns {DiceElement} 骰子元素
153
- */
154
- dice(id) {
155
- return {
156
- type: 'dice',
157
- id,
158
- };
159
- }
160
- /**
161
- * 石头剪刀布
162
- * @param id - 石头剪刀布ID
163
- * @returns {RpsElement} 石头剪刀布元素
164
- */
165
- rps(id) {
166
- return {
167
- type: 'rps',
168
- id,
169
- };
170
- }
171
- /**
172
- * 戳一戳
173
- * @param id - 戳一戳ID
174
- * @param poke_type - 戳一戳类型
175
- * @param strength - 戳一戳强度(1-5 默认1)
176
- * @returns {PokeElement} 戳一戳元素
177
- */
178
- poke(id, poke_type, strength = 1) {
179
- return {
180
- type: 'poke',
181
- id,
182
- poke_type,
183
- strength,
184
- };
185
- }
186
- /**
187
- * 自定义音乐
188
- * @param url - 跳转链接
189
- * @param audio - 音乐音频链接
190
- * @param title - 标题
191
- * @param author - 歌手
192
- * @param pic - 封面
193
- * @returns {CustomMusicElemen} 自定义音乐元素
194
- */
195
- customMusic(url, audio, title, author, pic, id) {
196
- return {
197
- type: 'music',
198
- platform: 'custom',
199
- url,
200
- audio,
201
- title,
202
- author,
203
- pic,
204
- id,
205
- };
206
- }
207
- /**
208
- * 音乐
209
- * @param platform - 音乐平台
210
- * @param id - 音乐ID
211
- * @returns {MusicElement} 音乐元素
212
- */
213
- music(platform, id) {
214
- return {
215
- type: 'music',
216
- platform,
217
- id,
218
- };
219
- }
220
- /**
221
- * 天气
222
- * @param city - 城市名称
223
- * @param code - 城市代码
224
- * @returns {WeatherElement} 天气元素
225
- */
226
- weather(city, code) {
227
- return {
228
- type: 'weather',
229
- city,
230
- code,
231
- };
232
- }
233
- /**
234
- * 位置
235
- * @param lat - 纬度
236
- * @param lon - 经度
237
- * @param title - 标题
238
- * @param address - 地址
239
- * @returns {LocationElement} 位置元素
240
- */
241
- location(lat, lon, title, address) {
242
- return {
243
- type: 'location',
244
- lat,
245
- lon,
246
- title,
247
- address,
248
- };
249
- }
250
- /**
251
- * 分享
252
- * @param url - 分享链接
253
- * @param title - 分享标题
254
- * @param content - 分享内容
255
- * @param image - 分享图片
256
- * @returns {ShareElement} 分享元素
257
- */
258
- share(url, title, content, image) {
259
- return {
260
- type: 'share',
261
- url,
262
- title,
263
- content,
264
- image,
265
- };
266
- }
267
- /**
268
- * 礼物
269
- * @param qq - QQ 号
270
- * @param id - 礼物ID
271
- * @returns {GiftElement} 礼物元素
272
- */
273
- gift(qq, id) {
274
- return {
275
- type: 'gift',
276
- qq,
277
- id,
278
- };
279
- }
280
- /**
281
- * 商城表情
282
- * @param id - 表情ID
283
- * @returns {MarketFaceElement} 商城表情元素
284
- */
285
- marketFace(id) {
286
- return {
287
- type: 'market_face',
288
- id,
289
- };
290
- }
291
- /**
292
- * 转发
293
- * @param res_id - 资源ID
294
- * @param uniseq - 序列号(可能不对?)
295
- * @param summary - 摘要
296
- * @param description - 描述
297
- * @returns {ForwardElement} 转发元素
298
- */
299
- forward(res_id, uniseq, summary, description) {
300
- return {
301
- type: 'forward',
302
- res_id,
303
- uniseq: uniseq || '',
304
- summary: summary || '',
305
- description: description || '',
306
- };
307
- }
308
- /**
309
- * 分享名片
310
- * @param scene - 分享类型
311
- * @param peer - 被推荐人的QQ号或者被推荐群的群号
312
- * @returns {ContactElement} 分享名片元素
313
- */
314
- contact(scene, peer) {
315
- return {
316
- type: 'contact',
317
- scene,
318
- peer,
319
- };
320
- }
321
- /**
322
- * JSON
323
- * @param data - JSON序列化过的字符串
324
- * @returns {JsonElement} JSON元素
325
- */
326
- json(data) {
327
- return {
328
- type: 'json',
329
- data,
330
- };
331
- }
332
- /**
333
- * XML
334
- * @param data - XML字符串
335
- * @returns {XmlElement} XML元素
336
- */
337
- xml(data) {
338
- return {
339
- type: 'xml',
340
- data,
341
- };
342
- }
343
- /**
344
- * 文件
345
- */
346
- file(options) {
347
- return {
348
- type: 'file',
349
- file: options.url,
350
- name: options.name || '',
351
- size: options.size || 0,
352
- expire_time: options.expire_time || 0,
353
- id: options.id || '',
354
- url: options.url,
355
- biz: options.biz || 0,
356
- sub_id: options.sub_id || '',
357
- md5: options.md5 || '',
358
- };
359
- }
360
- /**
361
- * 长消息
362
- * @param id - ID
363
- */
364
- long_msg(id) {
365
- return {
366
- type: 'long_msg',
367
- id,
368
- };
369
- }
370
- /**
371
- * Markdown
372
- * @param content - 原生markdown内容
373
- * @param config - 未知的参数
374
- */
375
- markdown(content, config) {
376
- return {
377
- type: 'markdown',
378
- content,
379
- config,
380
- };
381
- }
382
- /**
383
- * 构建模板Markdown
384
- * @param custom_template_id - 模板ID
385
- * @param params - 模板markdown参数
386
- */
387
- markdown_tpl(
388
- /**
389
- * - 模板ID
390
- */
391
- custom_template_id,
392
- /**
393
- * - 模板markdown参数
394
- */
395
- params) {
396
- return {
397
- type: 'markdown_tpl',
398
- custom_template_id,
399
- params,
400
- };
401
- }
402
- /**
403
- * 按钮 构建单行单个(obj)、多个按钮(obj[])
404
- * @param data - 按钮数据
405
- * @returns {ButtonElement} 按钮元素
406
- */
407
- button(data) {
408
- return {
409
- type: 'button',
410
- data: Array.isArray(data) ? data : [data],
411
- };
412
- }
413
- /**
414
- * 多维按钮
415
- * @param data - 按钮数据
416
- */
417
- keyboard(data) {
418
- /** 每一个元素为一行按钮 每一行按钮存在多个 */
419
- const rows = [];
420
- if (!Array.isArray(data))
421
- data = [data];
422
- for (const i of data) {
423
- /** 如果还是数组 说明是单行多个按钮 */
424
- if (Array.isArray(i)) {
425
- const button = [];
426
- for (const v of i)
427
- button.push(v);
428
- rows.push(button);
429
- }
430
- else {
431
- /** 单行 单个按钮 */
432
- rows.push([i]);
433
- }
434
- }
435
- return { type: 'keyboard', rows };
436
- }
437
- /**
438
- * 转发自定义节点
439
- * @param user_id - 用户ID
440
- * @param nickname - 用户昵称
441
- * @param content - 节点内容
442
- */
443
- node(user_id, nickname, content) {
444
- return {
445
- type: 'node',
446
- user_id,
447
- nickname,
448
- content,
449
- };
450
- }
451
- })();