@gaias/basenode 1.6.2 → 1.6.4
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/libs/koa/KoaLoader.js +1 -1
- package/dist/libs/koa/KoaLoader.js.map +1 -1
- package/dist/libs/openapi/OpenAPIHelpers.d.ts.map +1 -1
- package/dist/libs/openapi/OpenAPIHelpers.js +9 -0
- package/dist/libs/openapi/OpenAPIHelpers.js.map +1 -1
- package/dist/libs/rabbitmq/ReliableDistributedEvents.d.ts.map +1 -1
- package/dist/libs/rabbitmq/ReliableDistributedEvents.js.map +1 -1
- package/dist/libs/service/ServiceLoader.d.ts.map +1 -1
- package/dist/libs/service/ServiceLoader.js +1 -2
- package/dist/libs/service/ServiceLoader.js.map +1 -1
- package/dist/libs/telegram/CaptionItemsBuilder.d.ts +29 -0
- package/dist/libs/telegram/CaptionItemsBuilder.d.ts.map +1 -0
- package/dist/libs/telegram/CaptionItemsBuilder.js +93 -0
- package/dist/libs/telegram/CaptionItemsBuilder.js.map +1 -0
- package/dist/libs/telegram/InputMedia.d.ts +3 -0
- package/dist/libs/telegram/InputMedia.d.ts.map +1 -0
- package/dist/libs/telegram/InputMedia.js +3 -0
- package/dist/libs/telegram/InputMedia.js.map +1 -0
- package/dist/libs/telegram/LinkPreviewOptions.d.ts +8 -0
- package/dist/libs/telegram/LinkPreviewOptions.d.ts.map +1 -0
- package/dist/libs/telegram/LinkPreviewOptions.js +3 -0
- package/dist/libs/telegram/LinkPreviewOptions.js.map +1 -0
- package/dist/libs/telegram/MediaGroupItemBuilder.d.ts +33 -0
- package/dist/libs/telegram/MediaGroupItemBuilder.d.ts.map +1 -0
- package/dist/libs/telegram/MediaGroupItemBuilder.js +200 -0
- package/dist/libs/telegram/MediaGroupItemBuilder.js.map +1 -0
- package/dist/libs/telegram/MediaType.d.ts +8 -0
- package/dist/libs/telegram/MediaType.d.ts.map +1 -0
- package/dist/libs/telegram/MediaType.js +12 -0
- package/dist/libs/telegram/MediaType.js.map +1 -0
- package/dist/libs/telegram/MessageBuilder.d.ts +38 -0
- package/dist/libs/telegram/MessageBuilder.d.ts.map +1 -0
- package/dist/libs/telegram/MessageBuilder.js +147 -0
- package/dist/libs/telegram/MessageBuilder.js.map +1 -0
- package/dist/libs/telegram/MessageExamples.d.ts +52 -0
- package/dist/libs/telegram/MessageExamples.d.ts.map +1 -0
- package/dist/libs/telegram/MessageExamples.js +728 -0
- package/dist/libs/telegram/MessageExamples.js.map +1 -0
- package/dist/libs/telegram/MessageOptionsBuilder.d.ts +51 -0
- package/dist/libs/telegram/MessageOptionsBuilder.d.ts.map +1 -0
- package/dist/libs/telegram/MessageOptionsBuilder.js +169 -0
- package/dist/libs/telegram/MessageOptionsBuilder.js.map +1 -0
- package/dist/libs/telegram/ParseMode.d.ts +6 -0
- package/dist/libs/telegram/ParseMode.d.ts.map +1 -0
- package/dist/libs/telegram/ParseMode.js +10 -0
- package/dist/libs/telegram/ParseMode.js.map +1 -0
- package/dist/libs/telegram/TelegramClient.d.ts +4 -3
- package/dist/libs/telegram/TelegramClient.d.ts.map +1 -1
- package/dist/libs/telegram/TelegramClient.js +62 -28
- package/dist/libs/telegram/TelegramClient.js.map +1 -1
- package/dist/libs/telegram/TelegramLoader.d.ts.map +1 -1
- package/dist/libs/telegram/TelegramLoader.js +5 -0
- package/dist/libs/telegram/TelegramLoader.js.map +1 -1
- package/dist/libs/telegram/TelegramManager.d.ts.map +1 -1
- package/dist/libs/telegram/TelegramManager.js +7 -4
- package/dist/libs/telegram/TelegramManager.js.map +1 -1
- package/dist/libs/telegram/TelegramSender.d.ts +11 -0
- package/dist/libs/telegram/TelegramSender.d.ts.map +1 -0
- package/dist/libs/telegram/TelegramSender.js +74 -0
- package/dist/libs/telegram/TelegramSender.js.map +1 -0
- package/dist/libs/telegram/index.d.ts +10 -0
- package/dist/libs/telegram/index.d.ts.map +1 -1
- package/dist/libs/telegram/index.js +10 -0
- package/dist/libs/telegram/index.js.map +1 -1
- package/dist/server/bootstrap.js +6 -4
- package/dist/server/bootstrap.js.map +1 -1
- package/package.json +1 -1
|
@@ -0,0 +1,728 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
+
exports.MessageExamples = void 0;
|
|
4
|
+
exports.example1_BasicTextMessage = example1_BasicTextMessage;
|
|
5
|
+
exports.example2_RichTextFormatting = example2_RichTextFormatting;
|
|
6
|
+
exports.example3_CodeBlocks = example3_CodeBlocks;
|
|
7
|
+
exports.example4_CaptionItemsBuilder = example4_CaptionItemsBuilder;
|
|
8
|
+
exports.example5_MessageOptionsBuilder = example5_MessageOptionsBuilder;
|
|
9
|
+
exports.example6_InlineKeyboard = example6_InlineKeyboard;
|
|
10
|
+
exports.example7_SinglePhoto = example7_SinglePhoto;
|
|
11
|
+
exports.example8_PhotoGroup = example8_PhotoGroup;
|
|
12
|
+
exports.example9_MediaGroupItemBuilder = example9_MediaGroupItemBuilder;
|
|
13
|
+
exports.example10_ReplyToMessage = example10_ReplyToMessage;
|
|
14
|
+
exports.example11_SendToMultipleBots = example11_SendToMultipleBots;
|
|
15
|
+
exports.example12_StatusReport = example12_StatusReport;
|
|
16
|
+
exports.example13_KeyValuePairs = example13_KeyValuePairs;
|
|
17
|
+
exports.example14_CombiningBuilders = example14_CombiningBuilders;
|
|
18
|
+
exports.example15_ConditionalFormatting = example15_ConditionalFormatting;
|
|
19
|
+
exports.example16_MediaGroupFromPaths = example16_MediaGroupFromPaths;
|
|
20
|
+
exports.example17_MediaGroupChaining = example17_MediaGroupChaining;
|
|
21
|
+
exports.example18_MediaGroupToTelegram = example18_MediaGroupToTelegram;
|
|
22
|
+
exports.example19_MediaGroupInstanceConversion = example19_MediaGroupInstanceConversion;
|
|
23
|
+
exports.example20_MediaGroupMixedTypes = example20_MediaGroupMixedTypes;
|
|
24
|
+
exports.example21_MediaGroupBatchPhotos = example21_MediaGroupBatchPhotos;
|
|
25
|
+
exports.example22_MediaGroupCompleteWorkflow = example22_MediaGroupCompleteWorkflow;
|
|
26
|
+
exports.example23_MediaGroupWithSpoiler = example23_MediaGroupWithSpoiler;
|
|
27
|
+
exports.example24_MediaGroupDynamicBuilding = example24_MediaGroupDynamicBuilding;
|
|
28
|
+
exports.runAllExamples = runAllExamples;
|
|
29
|
+
const typedi_1 = require("typedi");
|
|
30
|
+
const TelegramSender_1 = require("./TelegramSender");
|
|
31
|
+
const ParseMode_1 = require("./ParseMode");
|
|
32
|
+
const CaptionItemsBuilder_1 = require("./CaptionItemsBuilder");
|
|
33
|
+
const MessageOptionsBuilder_1 = require("./MessageOptionsBuilder");
|
|
34
|
+
const MediaGroupItemBuilder_1 = require("./MediaGroupItemBuilder");
|
|
35
|
+
const MediaType_1 = require("./MediaType");
|
|
36
|
+
async function example1_BasicTextMessage() {
|
|
37
|
+
const sender = typedi_1.Container.get(TelegramSender_1.TelegramSender);
|
|
38
|
+
await sender.parseMode(ParseMode_1.ParseMode.HTML).text('Hello ').bold('World').text('!').newLine().text('This is a ').italic('basic').text(' message.').send('ResearchBot');
|
|
39
|
+
console.log('✅ Example 1: Basic text message sent');
|
|
40
|
+
}
|
|
41
|
+
async function example2_RichTextFormatting() {
|
|
42
|
+
const sender = typedi_1.Container.get(TelegramSender_1.TelegramSender);
|
|
43
|
+
await sender.parseMode(ParseMode_1.ParseMode.HTML).bold('粗体文本 Bold Text').newLine().italic('斜体文本 Italic Text').newLine().code('内联代码 Inline Code').newLine().strike('删除线文本 Strikethrough').newLine().underline('下划线文本 Underline').newLine().link('链接文本 Link', 'https://example.com').newLine(2).separator('=', 30).newLine().listItem('列表项 1 List Item 1').listItem('列表项 2 List Item 2').listItem('列表项 3 List Item 3').send('ResearchBot');
|
|
44
|
+
console.log('✅ Example 2: Rich text formatting sent');
|
|
45
|
+
}
|
|
46
|
+
async function example3_CodeBlocks() {
|
|
47
|
+
const sender = typedi_1.Container.get(TelegramSender_1.TelegramSender);
|
|
48
|
+
const code = `function greet(name) {
|
|
49
|
+
console.log(\`Hello, \${name}!\`);
|
|
50
|
+
}
|
|
51
|
+
|
|
52
|
+
greet('World');`;
|
|
53
|
+
await sender.parseMode(ParseMode_1.ParseMode.HTML).bold('代码示例 Code Example:').newLine(2).codeBlock(code, 'javascript').newLine().text('这是一个 JavaScript 函数示例。').send('ResearchBot');
|
|
54
|
+
console.log('✅ Example 3: Code blocks sent');
|
|
55
|
+
}
|
|
56
|
+
async function example4_CaptionItemsBuilder() {
|
|
57
|
+
const sender = typedi_1.Container.get(TelegramSender_1.TelegramSender);
|
|
58
|
+
const caption = CaptionItemsBuilder_1.CaptionItemsBuilder.create()
|
|
59
|
+
.append({
|
|
60
|
+
index: 0,
|
|
61
|
+
key: '*项目名称*',
|
|
62
|
+
value: 'BaseNode Infrastructure',
|
|
63
|
+
hasKey: true,
|
|
64
|
+
hasValue: true,
|
|
65
|
+
})
|
|
66
|
+
.append({
|
|
67
|
+
index: 1,
|
|
68
|
+
key: '*版本*',
|
|
69
|
+
value: 'v1.6.3',
|
|
70
|
+
hasKey: true,
|
|
71
|
+
hasValue: true,
|
|
72
|
+
})
|
|
73
|
+
.append({
|
|
74
|
+
index: 2,
|
|
75
|
+
key: '*状态*',
|
|
76
|
+
value: '✅ 运行中',
|
|
77
|
+
hasKey: true,
|
|
78
|
+
hasValue: true,
|
|
79
|
+
})
|
|
80
|
+
.append({
|
|
81
|
+
index: 3,
|
|
82
|
+
key: '*最后更新*',
|
|
83
|
+
value: '2024-01-20 10:30',
|
|
84
|
+
hasKey: true,
|
|
85
|
+
hasValue: true,
|
|
86
|
+
})
|
|
87
|
+
.sort()
|
|
88
|
+
.toString();
|
|
89
|
+
await sender.parseMode(ParseMode_1.ParseMode.MARKDOWN).text(caption).send('ResearchBot');
|
|
90
|
+
console.log('✅ Example 4: CaptionItemsBuilder sent');
|
|
91
|
+
}
|
|
92
|
+
async function example5_MessageOptionsBuilder() {
|
|
93
|
+
const sender = typedi_1.Container.get(TelegramSender_1.TelegramSender);
|
|
94
|
+
const options = MessageOptionsBuilder_1.MessageOptionsBuilder.create()
|
|
95
|
+
.parseMode(ParseMode_1.ParseMode.MARKDOWN)
|
|
96
|
+
.disableNotification()
|
|
97
|
+
.protectContent()
|
|
98
|
+
.disableWebPagePreview()
|
|
99
|
+
.getOptions();
|
|
100
|
+
await sender.text('*受保护的消息*').newLine(2).text('此消息具有以下特性:').newLine().listItem('静默发送(不会通知用户)').listItem('内容受保护(无法转发)').listItem('禁用链接预览').option(options).send('ResearchBot');
|
|
101
|
+
console.log('✅ Example 5: MessageOptionsBuilder sent');
|
|
102
|
+
}
|
|
103
|
+
async function example6_InlineKeyboard() {
|
|
104
|
+
const sender = typedi_1.Container.get(TelegramSender_1.TelegramSender);
|
|
105
|
+
const caption = CaptionItemsBuilder_1.CaptionItemsBuilder.create()
|
|
106
|
+
.append({
|
|
107
|
+
index: 0,
|
|
108
|
+
key: '*操作提示*',
|
|
109
|
+
value: '请选择要执行的操作',
|
|
110
|
+
hasKey: true,
|
|
111
|
+
hasValue: true,
|
|
112
|
+
})
|
|
113
|
+
.sort()
|
|
114
|
+
.toString();
|
|
115
|
+
const options = MessageOptionsBuilder_1.MessageOptionsBuilder.create()
|
|
116
|
+
.parseMode(ParseMode_1.ParseMode.MARKDOWN)
|
|
117
|
+
.setInlineKeyboard([
|
|
118
|
+
[
|
|
119
|
+
{ text: '✅ 确认', callback_data: 'confirm' },
|
|
120
|
+
{ text: '❌ 取消', callback_data: 'cancel' },
|
|
121
|
+
],
|
|
122
|
+
[
|
|
123
|
+
{ text: '📊 查看详情', callback_data: 'view_details' },
|
|
124
|
+
{ text: '🔄 刷新', callback_data: 'refresh' },
|
|
125
|
+
],
|
|
126
|
+
[{ text: '🔗 访问官网', url: 'https://example.com' }],
|
|
127
|
+
])
|
|
128
|
+
.getOptions();
|
|
129
|
+
await sender.text(caption).option(options).send('ResearchBot');
|
|
130
|
+
console.log('✅ Example 6: Inline keyboard sent');
|
|
131
|
+
}
|
|
132
|
+
async function example7_SinglePhoto() {
|
|
133
|
+
const sender = typedi_1.Container.get(TelegramSender_1.TelegramSender);
|
|
134
|
+
const caption = CaptionItemsBuilder_1.CaptionItemsBuilder.create()
|
|
135
|
+
.append({
|
|
136
|
+
index: 0,
|
|
137
|
+
key: '*图片名称*',
|
|
138
|
+
value: '日落海滩',
|
|
139
|
+
hasKey: true,
|
|
140
|
+
hasValue: true,
|
|
141
|
+
})
|
|
142
|
+
.append({
|
|
143
|
+
index: 1,
|
|
144
|
+
key: '*拍摄地点*',
|
|
145
|
+
value: '加利福尼亚',
|
|
146
|
+
hasKey: true,
|
|
147
|
+
hasValue: true,
|
|
148
|
+
})
|
|
149
|
+
.append({
|
|
150
|
+
index: 2,
|
|
151
|
+
key: '*拍摄日期*',
|
|
152
|
+
value: '2024-01-15',
|
|
153
|
+
hasKey: true,
|
|
154
|
+
hasValue: true,
|
|
155
|
+
})
|
|
156
|
+
.append({
|
|
157
|
+
index: 3,
|
|
158
|
+
key: '*分辨率*',
|
|
159
|
+
value: '4096x2160',
|
|
160
|
+
hasKey: true,
|
|
161
|
+
hasValue: true,
|
|
162
|
+
})
|
|
163
|
+
.sort()
|
|
164
|
+
.toString();
|
|
165
|
+
const options = MessageOptionsBuilder_1.MessageOptionsBuilder.create().parseMode(ParseMode_1.ParseMode.MARKDOWN).disableNotification().getOptions();
|
|
166
|
+
const mediaBuilder = MediaGroupItemBuilder_1.MediaGroupItemBuilder.create().append({
|
|
167
|
+
type: 'photo',
|
|
168
|
+
media: '/path/to/sunset.jpg',
|
|
169
|
+
caption: caption,
|
|
170
|
+
parse_mode: ParseMode_1.ParseMode.MARKDOWN,
|
|
171
|
+
});
|
|
172
|
+
await sender.parseMode(ParseMode_1.ParseMode.MARKDOWN).option(options)
|
|
173
|
+
.photos(mediaBuilder.medias()).sendMedia('ResearchBot');
|
|
174
|
+
console.log('✅ Example 7: Single photo sent');
|
|
175
|
+
}
|
|
176
|
+
async function example8_PhotoGroup() {
|
|
177
|
+
const sender = typedi_1.Container.get(TelegramSender_1.TelegramSender);
|
|
178
|
+
const caption = CaptionItemsBuilder_1.CaptionItemsBuilder.create()
|
|
179
|
+
.append({
|
|
180
|
+
index: 0,
|
|
181
|
+
key: '*相册名称*',
|
|
182
|
+
value: '日落系列',
|
|
183
|
+
hasKey: true,
|
|
184
|
+
hasValue: true,
|
|
185
|
+
})
|
|
186
|
+
.append({
|
|
187
|
+
index: 1,
|
|
188
|
+
key: '*照片数量*',
|
|
189
|
+
value: '3张',
|
|
190
|
+
hasKey: true,
|
|
191
|
+
hasValue: true,
|
|
192
|
+
})
|
|
193
|
+
.append({
|
|
194
|
+
index: 2,
|
|
195
|
+
key: '*拍摄地点*',
|
|
196
|
+
value: '海滩',
|
|
197
|
+
hasKey: true,
|
|
198
|
+
hasValue: true,
|
|
199
|
+
})
|
|
200
|
+
.sort()
|
|
201
|
+
.toString();
|
|
202
|
+
const options = MessageOptionsBuilder_1.MessageOptionsBuilder.create().parseMode(ParseMode_1.ParseMode.MARKDOWN).disableNotification().protectContent().getOptions();
|
|
203
|
+
const photoPaths = ['/path/to/photo1.jpg', '/path/to/photo2.jpg', '/path/to/photo3.jpg'];
|
|
204
|
+
const mediaBuilder = MediaGroupItemBuilder_1.MediaGroupItemBuilder.create().fromImages(photoPaths, {
|
|
205
|
+
captions: [caption],
|
|
206
|
+
parseMode: ParseMode_1.ParseMode.MARKDOWN,
|
|
207
|
+
});
|
|
208
|
+
await sender.parseMode(ParseMode_1.ParseMode.MARKDOWN).option(options).photos(mediaBuilder.medias()).sendMedia('ResearchBot');
|
|
209
|
+
console.log('✅ Example 8: Photo group sent');
|
|
210
|
+
}
|
|
211
|
+
async function example9_MediaGroupItemBuilder() {
|
|
212
|
+
const mediaGroup = MediaGroupItemBuilder_1.MediaGroupItemBuilder.create()
|
|
213
|
+
.append({
|
|
214
|
+
type: MediaType_1.MediaType.PHOTO,
|
|
215
|
+
media: '/path/to/photo1.jpg',
|
|
216
|
+
caption: '第一张照片 - 日出',
|
|
217
|
+
parse_mode: ParseMode_1.ParseMode.MARKDOWN,
|
|
218
|
+
})
|
|
219
|
+
.append({
|
|
220
|
+
type: MediaType_1.MediaType.PHOTO,
|
|
221
|
+
media: '/path/to/photo2.jpg',
|
|
222
|
+
caption: '第二张照片 - 中午',
|
|
223
|
+
parse_mode: ParseMode_1.ParseMode.MARKDOWN,
|
|
224
|
+
})
|
|
225
|
+
.append({
|
|
226
|
+
type: MediaType_1.MediaType.PHOTO,
|
|
227
|
+
media: '/path/to/photo3.jpg',
|
|
228
|
+
caption: '第三张照片 - 日落',
|
|
229
|
+
parse_mode: ParseMode_1.ParseMode.MARKDOWN,
|
|
230
|
+
})
|
|
231
|
+
.sortByType()
|
|
232
|
+
.build();
|
|
233
|
+
const validation = MediaGroupItemBuilder_1.MediaGroupItemBuilder.create().after(mediaGroup).validate();
|
|
234
|
+
if (!validation.isValid) {
|
|
235
|
+
console.error('媒体组验证失败:', validation.errors);
|
|
236
|
+
return;
|
|
237
|
+
}
|
|
238
|
+
console.log('✅ Example 9: MediaGroupItemBuilder completed');
|
|
239
|
+
}
|
|
240
|
+
async function example10_ReplyToMessage() {
|
|
241
|
+
const sender = typedi_1.Container.get(TelegramSender_1.TelegramSender);
|
|
242
|
+
const reply = CaptionItemsBuilder_1.CaptionItemsBuilder.create()
|
|
243
|
+
.append({
|
|
244
|
+
index: 0,
|
|
245
|
+
key: '*回复*',
|
|
246
|
+
value: '已收到您的反馈',
|
|
247
|
+
hasKey: true,
|
|
248
|
+
hasValue: true,
|
|
249
|
+
})
|
|
250
|
+
.append({
|
|
251
|
+
index: 1,
|
|
252
|
+
key: '*状态*',
|
|
253
|
+
value: '✅ 已处理',
|
|
254
|
+
hasKey: true,
|
|
255
|
+
hasValue: true,
|
|
256
|
+
})
|
|
257
|
+
.append({
|
|
258
|
+
index: 2,
|
|
259
|
+
key: '*处理时间*',
|
|
260
|
+
value: '2024-01-20 14:30',
|
|
261
|
+
hasKey: true,
|
|
262
|
+
hasValue: true,
|
|
263
|
+
})
|
|
264
|
+
.sort()
|
|
265
|
+
.toString();
|
|
266
|
+
const options = MessageOptionsBuilder_1.MessageOptionsBuilder.create()
|
|
267
|
+
.parseMode(ParseMode_1.ParseMode.MARKDOWN)
|
|
268
|
+
.replyToMessage(12345)
|
|
269
|
+
.disableNotification()
|
|
270
|
+
.getOptions();
|
|
271
|
+
await sender.text(reply).option(options).send('ResearchBot');
|
|
272
|
+
console.log('✅ Example 10: Reply to message sent');
|
|
273
|
+
}
|
|
274
|
+
async function example11_SendToMultipleBots() {
|
|
275
|
+
const sender = typedi_1.Container.get(TelegramSender_1.TelegramSender);
|
|
276
|
+
const broadcast = CaptionItemsBuilder_1.CaptionItemsBuilder.create()
|
|
277
|
+
.append({
|
|
278
|
+
index: 0,
|
|
279
|
+
key: '*广播通知*',
|
|
280
|
+
value: '系统维护公告',
|
|
281
|
+
hasKey: true,
|
|
282
|
+
hasValue: true,
|
|
283
|
+
})
|
|
284
|
+
.append({
|
|
285
|
+
index: 1,
|
|
286
|
+
key: '*维护时间*',
|
|
287
|
+
value: '2024-01-21 02:00-04:00',
|
|
288
|
+
hasKey: true,
|
|
289
|
+
hasValue: true,
|
|
290
|
+
})
|
|
291
|
+
.append({
|
|
292
|
+
index: 2,
|
|
293
|
+
key: '*影响范围*',
|
|
294
|
+
value: '所有服务暂时不可用',
|
|
295
|
+
hasKey: true,
|
|
296
|
+
hasValue: true,
|
|
297
|
+
})
|
|
298
|
+
.append({
|
|
299
|
+
index: 3,
|
|
300
|
+
key: '*预计恢复*',
|
|
301
|
+
value: '04:00',
|
|
302
|
+
hasKey: true,
|
|
303
|
+
hasValue: true,
|
|
304
|
+
})
|
|
305
|
+
.sort()
|
|
306
|
+
.toString();
|
|
307
|
+
const options = MessageOptionsBuilder_1.MessageOptionsBuilder.create().parseMode(ParseMode_1.ParseMode.MARKDOWN).disableNotification().getOptions();
|
|
308
|
+
await sender.text(broadcast).option(options).sendToMultiple(['ResearchBot', 'UserBot', 'AdminBot']);
|
|
309
|
+
console.log('✅ Example 11: Broadcast to multiple bots sent');
|
|
310
|
+
}
|
|
311
|
+
async function example12_StatusReport() {
|
|
312
|
+
const sender = typedi_1.Container.get(TelegramSender_1.TelegramSender);
|
|
313
|
+
const projectInfo = CaptionItemsBuilder_1.CaptionItemsBuilder.create()
|
|
314
|
+
.append({
|
|
315
|
+
index: 0,
|
|
316
|
+
key: '*项目名称*',
|
|
317
|
+
value: 'BaseNode Infrastructure',
|
|
318
|
+
hasKey: true,
|
|
319
|
+
hasValue: true,
|
|
320
|
+
})
|
|
321
|
+
.append({
|
|
322
|
+
index: 1,
|
|
323
|
+
key: '*版本*',
|
|
324
|
+
value: 'v1.6.3',
|
|
325
|
+
hasKey: true,
|
|
326
|
+
hasValue: true,
|
|
327
|
+
})
|
|
328
|
+
.append({
|
|
329
|
+
index: 2,
|
|
330
|
+
key: '*构建日期*',
|
|
331
|
+
value: '2024-01-20',
|
|
332
|
+
hasKey: true,
|
|
333
|
+
hasValue: true,
|
|
334
|
+
})
|
|
335
|
+
.sort()
|
|
336
|
+
.toString();
|
|
337
|
+
const performance = CaptionItemsBuilder_1.CaptionItemsBuilder.create()
|
|
338
|
+
.append({
|
|
339
|
+
index: 0,
|
|
340
|
+
key: '*CPU 使用率*',
|
|
341
|
+
value: '45%',
|
|
342
|
+
hasKey: true,
|
|
343
|
+
hasValue: true,
|
|
344
|
+
})
|
|
345
|
+
.append({
|
|
346
|
+
index: 1,
|
|
347
|
+
key: '*内存使用*',
|
|
348
|
+
value: '2.5GB / 8GB',
|
|
349
|
+
hasKey: true,
|
|
350
|
+
hasValue: true,
|
|
351
|
+
})
|
|
352
|
+
.append({
|
|
353
|
+
index: 2,
|
|
354
|
+
key: '*磁盘使用*',
|
|
355
|
+
value: '120GB / 500GB',
|
|
356
|
+
hasKey: true,
|
|
357
|
+
hasValue: true,
|
|
358
|
+
})
|
|
359
|
+
.append({
|
|
360
|
+
index: 3,
|
|
361
|
+
key: '*运行时间*',
|
|
362
|
+
value: '15天 3小时',
|
|
363
|
+
hasKey: true,
|
|
364
|
+
hasValue: true,
|
|
365
|
+
})
|
|
366
|
+
.sort()
|
|
367
|
+
.toString();
|
|
368
|
+
const taskStats = CaptionItemsBuilder_1.CaptionItemsBuilder.create()
|
|
369
|
+
.append({
|
|
370
|
+
index: 0,
|
|
371
|
+
key: '*总任务数*',
|
|
372
|
+
value: '150',
|
|
373
|
+
hasKey: true,
|
|
374
|
+
hasValue: true,
|
|
375
|
+
})
|
|
376
|
+
.append({
|
|
377
|
+
index: 1,
|
|
378
|
+
key: '*已完成*',
|
|
379
|
+
value: '145 (96.7%)',
|
|
380
|
+
hasKey: true,
|
|
381
|
+
hasValue: true,
|
|
382
|
+
})
|
|
383
|
+
.append({
|
|
384
|
+
index: 2,
|
|
385
|
+
key: '*进行中*',
|
|
386
|
+
value: '3',
|
|
387
|
+
hasKey: true,
|
|
388
|
+
hasValue: true,
|
|
389
|
+
})
|
|
390
|
+
.append({
|
|
391
|
+
index: 3,
|
|
392
|
+
key: '*待处理*',
|
|
393
|
+
value: '2',
|
|
394
|
+
hasKey: true,
|
|
395
|
+
hasValue: true,
|
|
396
|
+
})
|
|
397
|
+
.sort()
|
|
398
|
+
.toString();
|
|
399
|
+
const fullReport = `📊 *系统状态报告*\n\n` + `🏗️ *项目信息*\n${projectInfo}\n\n` + `⚡ *性能指标*\n${performance}\n\n` + `📋 *任务统计*\n${taskStats}\n\n` + `✅ 系统运行正常`;
|
|
400
|
+
const options = MessageOptionsBuilder_1.MessageOptionsBuilder.create()
|
|
401
|
+
.parseMode(ParseMode_1.ParseMode.MARKDOWN)
|
|
402
|
+
.disableWebPagePreview()
|
|
403
|
+
.setInlineKeyboard([
|
|
404
|
+
[
|
|
405
|
+
{ text: '📈 详细报告', callback_data: 'detailed_report' },
|
|
406
|
+
{ text: '🔄 刷新数据', callback_data: 'refresh_data' },
|
|
407
|
+
],
|
|
408
|
+
[
|
|
409
|
+
{ text: '⚙️ 系统设置', callback_data: 'settings' },
|
|
410
|
+
{ text: '📊 历史数据', callback_data: 'history' },
|
|
411
|
+
],
|
|
412
|
+
])
|
|
413
|
+
.getOptions();
|
|
414
|
+
await sender.text(fullReport).option(options).send('ResearchBot');
|
|
415
|
+
console.log('✅ Example 12: Status report sent');
|
|
416
|
+
}
|
|
417
|
+
async function example13_KeyValuePairs() {
|
|
418
|
+
const sender = typedi_1.Container.get(TelegramSender_1.TelegramSender);
|
|
419
|
+
await sender.parseMode(ParseMode_1.ParseMode.HTML).bold('用户信息 User Information:').newLine(2).keyValue('姓名 Name', 'John Doe').keyValue('年龄 Age', '30').keyValue('邮箱 Email', 'john@example.com').keyValue('电话 Phone', '+1234567890').keyValue('地址 Address', 'California, USA').newLine().separator('─', 40).newLine().keyValue('注册日期 Registered', '2024-01-01').keyValue('最后登录 Last Login', '2024-01-20 10:30').send('ResearchBot');
|
|
420
|
+
console.log('✅ Example 13: Key-value pairs sent');
|
|
421
|
+
}
|
|
422
|
+
async function example14_CombiningBuilders() {
|
|
423
|
+
const sender = typedi_1.Container.get(TelegramSender_1.TelegramSender);
|
|
424
|
+
const header = CaptionItemsBuilder_1.CaptionItemsBuilder.create()
|
|
425
|
+
.append({
|
|
426
|
+
index: 0,
|
|
427
|
+
key: '*通知类型*',
|
|
428
|
+
value: '系统更新',
|
|
429
|
+
hasKey: true,
|
|
430
|
+
hasValue: true,
|
|
431
|
+
})
|
|
432
|
+
.append({
|
|
433
|
+
index: 1,
|
|
434
|
+
key: '*优先级*',
|
|
435
|
+
value: '🔴 高',
|
|
436
|
+
hasKey: true,
|
|
437
|
+
hasValue: true,
|
|
438
|
+
})
|
|
439
|
+
.sort()
|
|
440
|
+
.toString();
|
|
441
|
+
const details = CaptionItemsBuilder_1.CaptionItemsBuilder.create()
|
|
442
|
+
.append({
|
|
443
|
+
index: 0,
|
|
444
|
+
key: '*更新内容*',
|
|
445
|
+
value: '新增功能模块',
|
|
446
|
+
hasKey: true,
|
|
447
|
+
hasValue: true,
|
|
448
|
+
})
|
|
449
|
+
.append({
|
|
450
|
+
index: 1,
|
|
451
|
+
key: '*更新时间*',
|
|
452
|
+
value: '2024-01-20 15:00',
|
|
453
|
+
hasKey: true,
|
|
454
|
+
hasValue: true,
|
|
455
|
+
})
|
|
456
|
+
.append({
|
|
457
|
+
index: 2,
|
|
458
|
+
key: '*影响范围*',
|
|
459
|
+
value: '全部用户',
|
|
460
|
+
hasKey: true,
|
|
461
|
+
hasValue: true,
|
|
462
|
+
})
|
|
463
|
+
.sort()
|
|
464
|
+
.toString();
|
|
465
|
+
const options = MessageOptionsBuilder_1.MessageOptionsBuilder.create()
|
|
466
|
+
.parseMode(ParseMode_1.ParseMode.MARKDOWN)
|
|
467
|
+
.disableNotification(false)
|
|
468
|
+
.protectContent()
|
|
469
|
+
.setInlineKeyboard([
|
|
470
|
+
[
|
|
471
|
+
{ text: '✅ 已知晓', callback_data: 'acknowledged' },
|
|
472
|
+
{ text: '📖 查看详情', callback_data: 'view_more' },
|
|
473
|
+
],
|
|
474
|
+
])
|
|
475
|
+
.getOptions();
|
|
476
|
+
const message = `${header}\n\n📝 *详细信息*\n${details}\n\n请及时查看更新内容。`;
|
|
477
|
+
await sender.text(message).option(options).send('ResearchBot');
|
|
478
|
+
console.log('✅ Example 14: Combined builders sent');
|
|
479
|
+
}
|
|
480
|
+
async function example15_ConditionalFormatting() {
|
|
481
|
+
const sender = typedi_1.Container.get(TelegramSender_1.TelegramSender);
|
|
482
|
+
const status = 'success';
|
|
483
|
+
const percentage = 96.5;
|
|
484
|
+
const statusInfo = CaptionItemsBuilder_1.CaptionItemsBuilder.create()
|
|
485
|
+
.append({
|
|
486
|
+
index: 0,
|
|
487
|
+
key: '*状态*',
|
|
488
|
+
value: status === 'success' ? '✅ 成功' : status === 'warning' ? '⚠️ 警告' : '❌ 错误',
|
|
489
|
+
hasKey: true,
|
|
490
|
+
hasValue: true,
|
|
491
|
+
})
|
|
492
|
+
.append({
|
|
493
|
+
index: 1,
|
|
494
|
+
key: '*完成度*',
|
|
495
|
+
value: `${percentage}%`,
|
|
496
|
+
hasKey: true,
|
|
497
|
+
hasValue: true,
|
|
498
|
+
})
|
|
499
|
+
.append({
|
|
500
|
+
index: 2,
|
|
501
|
+
key: '*评级*',
|
|
502
|
+
value: percentage >= 90 ? '⭐⭐⭐⭐⭐' : percentage >= 70 ? '⭐⭐⭐⭐' : '⭐⭐⭐',
|
|
503
|
+
hasKey: true,
|
|
504
|
+
hasValue: true,
|
|
505
|
+
})
|
|
506
|
+
.sort()
|
|
507
|
+
.toString();
|
|
508
|
+
const options = MessageOptionsBuilder_1.MessageOptionsBuilder.create()
|
|
509
|
+
.parseMode(ParseMode_1.ParseMode.MARKDOWN)
|
|
510
|
+
.disableNotification(status === 'success')
|
|
511
|
+
.getOptions();
|
|
512
|
+
await sender.text(statusInfo).option(options).send('ResearchBot');
|
|
513
|
+
console.log('✅ Example 15: Conditional formatting sent');
|
|
514
|
+
}
|
|
515
|
+
function example16_MediaGroupFromPaths() {
|
|
516
|
+
const imagePaths = ['/path/to/sunset1.jpg', '/path/to/sunset2.jpg', '/path/to/sunset3.jpg'];
|
|
517
|
+
const captions = ['美丽的日出', '中午的阳光', '浪漫的日落'];
|
|
518
|
+
const items = MediaGroupItemBuilder_1.MediaGroupItemBuilder.fromImagePaths(imagePaths, {
|
|
519
|
+
captions,
|
|
520
|
+
parseMode: ParseMode_1.ParseMode.MARKDOWN,
|
|
521
|
+
hasSpoiler: false,
|
|
522
|
+
});
|
|
523
|
+
console.log('✅ Example 16: 构建了', items.length, '个媒体项');
|
|
524
|
+
console.log('第一个项:', items[0]);
|
|
525
|
+
}
|
|
526
|
+
function example17_MediaGroupChaining() {
|
|
527
|
+
const imagePaths = ['/path/to/photo1.jpg', '/path/to/photo2.jpg'];
|
|
528
|
+
const captions = ['照片 1', '照片 2'];
|
|
529
|
+
const builder = MediaGroupItemBuilder_1.MediaGroupItemBuilder.create()
|
|
530
|
+
.fromImages(imagePaths, {
|
|
531
|
+
captions,
|
|
532
|
+
parseMode: ParseMode_1.ParseMode.MARKDOWN,
|
|
533
|
+
})
|
|
534
|
+
.sortByType();
|
|
535
|
+
const items = builder.build();
|
|
536
|
+
console.log('✅ Example 17: 构建并排序了', items.length, '个媒体项');
|
|
537
|
+
console.log(builder.toString());
|
|
538
|
+
}
|
|
539
|
+
function example18_MediaGroupToTelegram() {
|
|
540
|
+
const imagePaths = ['/path/to/photo1.jpg', '/path/to/photo2.jpg', '/path/to/photo3.jpg'];
|
|
541
|
+
const items = MediaGroupItemBuilder_1.MediaGroupItemBuilder.fromImagePaths(imagePaths, {
|
|
542
|
+
captions: ['第一张照片', '第二张照片', '第三张照片'],
|
|
543
|
+
parseMode: ParseMode_1.ParseMode.MARKDOWN,
|
|
544
|
+
});
|
|
545
|
+
const telegramMedia = items;
|
|
546
|
+
console.log('✅ Example 18: 转换为 Telegram 格式');
|
|
547
|
+
console.log('Telegram 媒体数组:', JSON.stringify(telegramMedia, null, 2));
|
|
548
|
+
}
|
|
549
|
+
function example19_MediaGroupInstanceConversion() {
|
|
550
|
+
const builder = MediaGroupItemBuilder_1.MediaGroupItemBuilder.create().fromImages(['/path/to/photo1.jpg', '/path/to/photo2.jpg'], {
|
|
551
|
+
captions: ['Photo 1', 'Photo 2'],
|
|
552
|
+
parseMode: ParseMode_1.ParseMode.HTML,
|
|
553
|
+
});
|
|
554
|
+
const telegramMedia = builder.build();
|
|
555
|
+
console.log('✅ Example 19: 实例方法转换');
|
|
556
|
+
console.log('媒体数量:', telegramMedia.length);
|
|
557
|
+
}
|
|
558
|
+
function example20_MediaGroupMixedTypes() {
|
|
559
|
+
const builder = MediaGroupItemBuilder_1.MediaGroupItemBuilder.create()
|
|
560
|
+
.fromImages(['/path/to/photo1.jpg', '/path/to/photo2.jpg'], {
|
|
561
|
+
captions: ['照片 1', '照片 2'],
|
|
562
|
+
parseMode: ParseMode_1.ParseMode.MARKDOWN,
|
|
563
|
+
type: 'photo',
|
|
564
|
+
})
|
|
565
|
+
.fromImages(['/path/to/video.mp4'], {
|
|
566
|
+
captions: ['视频片段'],
|
|
567
|
+
parseMode: ParseMode_1.ParseMode.MARKDOWN,
|
|
568
|
+
type: 'video',
|
|
569
|
+
})
|
|
570
|
+
.sortByType();
|
|
571
|
+
console.log('✅ Example 20: 混合媒体类型');
|
|
572
|
+
console.log(builder.toString());
|
|
573
|
+
}
|
|
574
|
+
function example21_MediaGroupBatchPhotos() {
|
|
575
|
+
const photosData = [
|
|
576
|
+
{ path: '/path/to/sunrise.jpg', caption: '*日出* - 清晨的第一缕阳光' },
|
|
577
|
+
{ path: '/path/to/noon.jpg', caption: '*正午* - 阳光明媚的时刻' },
|
|
578
|
+
{ path: '/path/to/sunset.jpg', caption: '*日落* - 浪漫的黄昏' },
|
|
579
|
+
{ path: '/path/to/night.jpg', caption: '*夜晚* - 星光璀璨' },
|
|
580
|
+
];
|
|
581
|
+
const imagePaths = photosData.map((photo) => photo.path);
|
|
582
|
+
const captions = photosData.map((photo) => photo.caption);
|
|
583
|
+
const items = MediaGroupItemBuilder_1.MediaGroupItemBuilder.fromImagePaths(imagePaths, {
|
|
584
|
+
captions,
|
|
585
|
+
parseMode: ParseMode_1.ParseMode.MARKDOWN,
|
|
586
|
+
});
|
|
587
|
+
console.log('✅ Example 21: 批量创建了', items.length, '张带标题的照片');
|
|
588
|
+
items.forEach((item, index) => {
|
|
589
|
+
console.log(` ${index + 1}. ${item.media} - ${item.caption}`);
|
|
590
|
+
});
|
|
591
|
+
}
|
|
592
|
+
function example22_MediaGroupCompleteWorkflow() {
|
|
593
|
+
console.log('\n===== MediaGroupItemBuilder 完整工作流程示例 =====\n');
|
|
594
|
+
const imagePaths = ['/path/to/project/screenshot1.png', '/path/to/project/screenshot2.png', '/path/to/project/screenshot3.png'];
|
|
595
|
+
const captions = ['*首页* - 用户登录界面', '*仪表板* - 数据可视化', '*设置* - 系统配置页面'];
|
|
596
|
+
const builder = MediaGroupItemBuilder_1.MediaGroupItemBuilder.create().fromImages(imagePaths, {
|
|
597
|
+
captions,
|
|
598
|
+
parseMode: ParseMode_1.ParseMode.MARKDOWN,
|
|
599
|
+
hasSpoiler: false,
|
|
600
|
+
});
|
|
601
|
+
const validation = builder.validate();
|
|
602
|
+
if (!validation.isValid) {
|
|
603
|
+
console.error('验证失败:', validation.errors);
|
|
604
|
+
return;
|
|
605
|
+
}
|
|
606
|
+
console.log('✅ 验证通过');
|
|
607
|
+
const telegramMedia = builder.build();
|
|
608
|
+
console.log('📤 已转换为 Telegram 格式,共', telegramMedia.length, '项');
|
|
609
|
+
console.log('\n📋 媒体组详情:');
|
|
610
|
+
console.log(builder.toString());
|
|
611
|
+
console.log('\n✅ 完整工作流程完成!');
|
|
612
|
+
}
|
|
613
|
+
function example23_MediaGroupWithSpoiler() {
|
|
614
|
+
const imagePaths = ['/path/to/spoiler1.jpg', '/path/to/spoiler2.jpg', '/path/to/spoiler3.jpg'];
|
|
615
|
+
const items = MediaGroupItemBuilder_1.MediaGroupItemBuilder.fromImagePaths(imagePaths, {
|
|
616
|
+
captions: ['剧透图 1', '剧透图 2', '剧透图 3'],
|
|
617
|
+
parseMode: ParseMode_1.ParseMode.MARKDOWN,
|
|
618
|
+
hasSpoiler: true,
|
|
619
|
+
});
|
|
620
|
+
console.log('✅ Example 23: 带 Spoiler 标记的媒体');
|
|
621
|
+
items.forEach((item, index) => {
|
|
622
|
+
console.log(` ${index + 1}. ${item.media} - Spoiler: ${item.has_spoiler}`);
|
|
623
|
+
});
|
|
624
|
+
}
|
|
625
|
+
function example24_MediaGroupDynamicBuilding() {
|
|
626
|
+
const builder = MediaGroupItemBuilder_1.MediaGroupItemBuilder.create();
|
|
627
|
+
const photoFiles = [
|
|
628
|
+
{ path: '/photos/photo1.jpg', caption: '照片 1' },
|
|
629
|
+
{ path: '/photos/photo2.jpg', caption: '照片 2' },
|
|
630
|
+
];
|
|
631
|
+
const videoFiles = [{ path: '/videos/video1.mp4', caption: '视频 1' }];
|
|
632
|
+
if (photoFiles.length > 0) {
|
|
633
|
+
const photoPaths = photoFiles.map((f) => f.path);
|
|
634
|
+
const photoCaptions = photoFiles.map((f) => f.caption);
|
|
635
|
+
builder.fromImages(photoPaths, {
|
|
636
|
+
captions: photoCaptions,
|
|
637
|
+
type: 'photo',
|
|
638
|
+
parseMode: ParseMode_1.ParseMode.MARKDOWN,
|
|
639
|
+
});
|
|
640
|
+
}
|
|
641
|
+
if (videoFiles.length > 0) {
|
|
642
|
+
const videoPaths = videoFiles.map((f) => f.path);
|
|
643
|
+
const videoCaptions = videoFiles.map((f) => f.caption);
|
|
644
|
+
builder.fromImages(videoPaths, {
|
|
645
|
+
captions: videoCaptions,
|
|
646
|
+
type: 'video',
|
|
647
|
+
parseMode: ParseMode_1.ParseMode.MARKDOWN,
|
|
648
|
+
});
|
|
649
|
+
}
|
|
650
|
+
builder.sortByType();
|
|
651
|
+
const validation = builder.validate();
|
|
652
|
+
console.log('✅ Example 24: 动态构建媒体组');
|
|
653
|
+
console.log('媒体数量:', builder.size());
|
|
654
|
+
console.log('验证结果:', validation.isValid ? '通过' : '失败');
|
|
655
|
+
console.log(builder.toString());
|
|
656
|
+
}
|
|
657
|
+
exports.MessageExamples = {
|
|
658
|
+
example1_BasicTextMessage,
|
|
659
|
+
example2_RichTextFormatting,
|
|
660
|
+
example3_CodeBlocks,
|
|
661
|
+
example4_CaptionItemsBuilder,
|
|
662
|
+
example5_MessageOptionsBuilder,
|
|
663
|
+
example6_InlineKeyboard,
|
|
664
|
+
example7_SinglePhoto,
|
|
665
|
+
example8_PhotoGroup,
|
|
666
|
+
example9_MediaGroupItemBuilder,
|
|
667
|
+
example10_ReplyToMessage,
|
|
668
|
+
example11_SendToMultipleBots,
|
|
669
|
+
example12_StatusReport,
|
|
670
|
+
example13_KeyValuePairs,
|
|
671
|
+
example14_CombiningBuilders,
|
|
672
|
+
example15_ConditionalFormatting,
|
|
673
|
+
example16_MediaGroupFromPaths,
|
|
674
|
+
example17_MediaGroupChaining,
|
|
675
|
+
example18_MediaGroupToTelegram,
|
|
676
|
+
example19_MediaGroupInstanceConversion,
|
|
677
|
+
example20_MediaGroupMixedTypes,
|
|
678
|
+
example21_MediaGroupBatchPhotos,
|
|
679
|
+
example22_MediaGroupCompleteWorkflow,
|
|
680
|
+
example23_MediaGroupWithSpoiler,
|
|
681
|
+
example24_MediaGroupDynamicBuilding,
|
|
682
|
+
};
|
|
683
|
+
async function runAllExamples() {
|
|
684
|
+
console.log('🚀 开始运行 Telegram 消息示例...\n');
|
|
685
|
+
const examples = [
|
|
686
|
+
{ name: '基础文本消息', fn: example1_BasicTextMessage },
|
|
687
|
+
{ name: '富文本格式化', fn: example2_RichTextFormatting },
|
|
688
|
+
{ name: '代码块', fn: example3_CodeBlocks },
|
|
689
|
+
{ name: 'CaptionItemsBuilder', fn: example4_CaptionItemsBuilder },
|
|
690
|
+
{ name: 'MessageOptionsBuilder', fn: example5_MessageOptionsBuilder },
|
|
691
|
+
{ name: '内联键盘', fn: example6_InlineKeyboard },
|
|
692
|
+
{ name: '单张图片', fn: example7_SinglePhoto },
|
|
693
|
+
{ name: '图片组', fn: example8_PhotoGroup },
|
|
694
|
+
{ name: 'MediaGroupItemBuilder', fn: example9_MediaGroupItemBuilder },
|
|
695
|
+
{ name: '回复消息', fn: example10_ReplyToMessage },
|
|
696
|
+
{ name: '多 Bot 发送', fn: example11_SendToMultipleBots },
|
|
697
|
+
{ name: '状态报告', fn: example12_StatusReport },
|
|
698
|
+
{ name: '键值对', fn: example13_KeyValuePairs },
|
|
699
|
+
{ name: '组合 Builders', fn: example14_CombiningBuilders },
|
|
700
|
+
{ name: '条件格式化', fn: example15_ConditionalFormatting },
|
|
701
|
+
{ name: 'MediaGroup - 从路径构建', fn: example16_MediaGroupFromPaths },
|
|
702
|
+
{ name: 'MediaGroup - 链式调用', fn: example17_MediaGroupChaining },
|
|
703
|
+
{ name: 'MediaGroup - Telegram 格式', fn: example18_MediaGroupToTelegram },
|
|
704
|
+
{ name: 'MediaGroup - 实例转换', fn: example19_MediaGroupInstanceConversion },
|
|
705
|
+
{ name: 'MediaGroup - 混合类型', fn: example20_MediaGroupMixedTypes },
|
|
706
|
+
{ name: 'MediaGroup - 批量照片', fn: example21_MediaGroupBatchPhotos },
|
|
707
|
+
{ name: 'MediaGroup - 完整流程', fn: example22_MediaGroupCompleteWorkflow },
|
|
708
|
+
{ name: 'MediaGroup - Spoiler', fn: example23_MediaGroupWithSpoiler },
|
|
709
|
+
{ name: 'MediaGroup - 动态构建', fn: example24_MediaGroupDynamicBuilding },
|
|
710
|
+
];
|
|
711
|
+
for (const example of examples) {
|
|
712
|
+
try {
|
|
713
|
+
console.log(`\n📝 运行示例: ${example.name}...`);
|
|
714
|
+
example.fn();
|
|
715
|
+
}
|
|
716
|
+
catch (error) {
|
|
717
|
+
console.error(`❌ 示例 ${example.name} 失败:`, error);
|
|
718
|
+
}
|
|
719
|
+
}
|
|
720
|
+
console.log('\n✅ 所有示例运行完成!');
|
|
721
|
+
}
|
|
722
|
+
if (require.main === module) {
|
|
723
|
+
runAllExamples().catch((error) => {
|
|
724
|
+
console.error('运行示例时发生错误:', error);
|
|
725
|
+
process.exit(1);
|
|
726
|
+
});
|
|
727
|
+
}
|
|
728
|
+
//# sourceMappingURL=MessageExamples.js.map
|