@fragno-dev/telegram-fragment 0.0.1 → 0.0.3
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/browser/client/react.d.ts +129 -3
- package/dist/browser/client/react.d.ts.map +1 -1
- package/dist/browser/client/react.js +32 -22
- package/dist/browser/client/react.js.map +1 -1
- package/dist/browser/client/solid.d.ts +129 -3
- package/dist/browser/client/solid.d.ts.map +1 -1
- package/dist/browser/client/solid.js +2 -2
- package/dist/browser/client/solid.js.map +1 -1
- package/dist/browser/client/svelte.d.ts +129 -3
- package/dist/browser/client/svelte.d.ts.map +1 -1
- package/dist/browser/client/svelte.js +1 -1
- package/dist/browser/client/vanilla.d.ts +129 -3
- package/dist/browser/client/vanilla.d.ts.map +1 -1
- package/dist/browser/client/vanilla.js +1 -1
- package/dist/browser/client/vue.d.ts +129 -3
- package/dist/browser/client/vue.d.ts.map +1 -1
- package/dist/browser/client/vue.js +1 -1
- package/dist/browser/{client-Bk-J98pf.d.ts → client-BumUy6cu.d.ts} +87 -83
- package/dist/browser/client-BumUy6cu.d.ts.map +1 -0
- package/dist/browser/index.d.ts +697 -48
- package/dist/browser/index.d.ts.map +1 -1
- package/dist/browser/index.js +2 -2
- package/dist/browser/index.js.map +1 -1
- package/dist/browser/{schema-QDMf15Vn.js → schema-IrJsGm4M.js} +264 -41
- package/dist/browser/schema-IrJsGm4M.js.map +1 -0
- package/dist/node/definition.d.ts.map +1 -1
- package/dist/node/index.d.ts +260 -13
- package/dist/node/index.d.ts.map +1 -1
- package/dist/node/index.js +2 -2
- package/dist/node/index.js.map +1 -1
- package/dist/node/routes.d.ts +130 -9
- package/dist/node/routes.d.ts.map +1 -1
- package/dist/node/routes.js +25 -15
- package/dist/node/routes.js.map +1 -1
- package/dist/node/services.js +56 -53
- package/dist/node/services.js.map +1 -1
- package/dist/node/telegram-api.js +80 -16
- package/dist/node/telegram-api.js.map +1 -1
- package/dist/node/telegram-utils.js +284 -9
- package/dist/node/telegram-utils.js.map +1 -1
- package/dist/node/types.d.ts +308 -27
- package/dist/node/types.d.ts.map +1 -1
- package/dist/node/types.js +232 -27
- package/dist/node/types.js.map +1 -1
- package/dist/tsconfig.tsbuildinfo +1 -1
- package/package.json +13 -8
- package/dist/browser/client-Bk-J98pf.d.ts.map +0 -1
- package/dist/browser/schema-QDMf15Vn.js.map +0 -1
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import { telegramCommandBindingsSchema } from "./types.js";
|
|
1
|
+
import { telegramAnimationSchema, telegramAudioSchema, telegramChatSchema, telegramCommandBindingsSchema, telegramDocumentSchema, telegramMessageEntitySchema, telegramMessageSchema, telegramPhotoSizeSchema, telegramStickerSchema, telegramUpdateSchema, telegramUserSchema, telegramVideoNoteSchema, telegramVideoSchema, telegramVoiceSchema } from "./types.js";
|
|
2
2
|
|
|
3
3
|
//#region src/telegram-utils.ts
|
|
4
4
|
const DEFAULT_COMMAND_SCOPES = [
|
|
@@ -7,21 +7,193 @@ const DEFAULT_COMMAND_SCOPES = [
|
|
|
7
7
|
"supergroup",
|
|
8
8
|
"channel"
|
|
9
9
|
];
|
|
10
|
+
function normalizeTelegramPhotoSize(input) {
|
|
11
|
+
const photo = input;
|
|
12
|
+
return telegramPhotoSizeSchema.parse({
|
|
13
|
+
fileId: photo.fileId ?? photo.file_id,
|
|
14
|
+
fileUniqueId: photo.fileUniqueId ?? photo.file_unique_id,
|
|
15
|
+
width: photo.width,
|
|
16
|
+
height: photo.height,
|
|
17
|
+
fileSize: photo.fileSize ?? photo.file_size
|
|
18
|
+
});
|
|
19
|
+
}
|
|
20
|
+
function normalizeTelegramVoice(input) {
|
|
21
|
+
const voice = input;
|
|
22
|
+
return telegramVoiceSchema.parse({
|
|
23
|
+
fileId: voice.fileId ?? voice.file_id,
|
|
24
|
+
fileUniqueId: voice.fileUniqueId ?? voice.file_unique_id,
|
|
25
|
+
duration: voice.duration,
|
|
26
|
+
mimeType: voice.mimeType ?? voice.mime_type,
|
|
27
|
+
fileSize: voice.fileSize ?? voice.file_size
|
|
28
|
+
});
|
|
29
|
+
}
|
|
30
|
+
function normalizeTelegramAudio(input) {
|
|
31
|
+
const audio = input;
|
|
32
|
+
return telegramAudioSchema.parse({
|
|
33
|
+
fileId: audio.fileId ?? audio.file_id,
|
|
34
|
+
fileUniqueId: audio.fileUniqueId ?? audio.file_unique_id,
|
|
35
|
+
duration: audio.duration,
|
|
36
|
+
performer: audio.performer,
|
|
37
|
+
title: audio.title,
|
|
38
|
+
fileName: audio.fileName ?? audio.file_name,
|
|
39
|
+
mimeType: audio.mimeType ?? audio.mime_type,
|
|
40
|
+
fileSize: audio.fileSize ?? audio.file_size,
|
|
41
|
+
thumbnail: audio.thumbnail ? normalizeTelegramPhotoSize(audio.thumbnail) : void 0
|
|
42
|
+
});
|
|
43
|
+
}
|
|
44
|
+
function normalizeTelegramDocument(input) {
|
|
45
|
+
const document = input;
|
|
46
|
+
return telegramDocumentSchema.parse({
|
|
47
|
+
fileId: document.fileId ?? document.file_id,
|
|
48
|
+
fileUniqueId: document.fileUniqueId ?? document.file_unique_id,
|
|
49
|
+
fileName: document.fileName ?? document.file_name,
|
|
50
|
+
mimeType: document.mimeType ?? document.mime_type,
|
|
51
|
+
fileSize: document.fileSize ?? document.file_size,
|
|
52
|
+
thumbnail: document.thumbnail ? normalizeTelegramPhotoSize(document.thumbnail) : void 0
|
|
53
|
+
});
|
|
54
|
+
}
|
|
55
|
+
function normalizeTelegramVideo(input) {
|
|
56
|
+
const video = input;
|
|
57
|
+
return telegramVideoSchema.parse({
|
|
58
|
+
fileId: video.fileId ?? video.file_id,
|
|
59
|
+
fileUniqueId: video.fileUniqueId ?? video.file_unique_id,
|
|
60
|
+
width: video.width,
|
|
61
|
+
height: video.height,
|
|
62
|
+
duration: video.duration,
|
|
63
|
+
fileName: video.fileName ?? video.file_name,
|
|
64
|
+
mimeType: video.mimeType ?? video.mime_type,
|
|
65
|
+
fileSize: video.fileSize ?? video.file_size,
|
|
66
|
+
thumbnail: video.thumbnail ? normalizeTelegramPhotoSize(video.thumbnail) : void 0
|
|
67
|
+
});
|
|
68
|
+
}
|
|
69
|
+
function normalizeTelegramVideoNote(input) {
|
|
70
|
+
const videoNote = input;
|
|
71
|
+
return telegramVideoNoteSchema.parse({
|
|
72
|
+
fileId: videoNote.fileId ?? videoNote.file_id,
|
|
73
|
+
fileUniqueId: videoNote.fileUniqueId ?? videoNote.file_unique_id,
|
|
74
|
+
length: videoNote.length,
|
|
75
|
+
duration: videoNote.duration,
|
|
76
|
+
fileSize: videoNote.fileSize ?? videoNote.file_size,
|
|
77
|
+
thumbnail: videoNote.thumbnail ? normalizeTelegramPhotoSize(videoNote.thumbnail) : void 0
|
|
78
|
+
});
|
|
79
|
+
}
|
|
80
|
+
function normalizeTelegramSticker(input) {
|
|
81
|
+
const sticker = input;
|
|
82
|
+
return telegramStickerSchema.parse({
|
|
83
|
+
fileId: sticker.fileId ?? sticker.file_id,
|
|
84
|
+
fileUniqueId: sticker.fileUniqueId ?? sticker.file_unique_id,
|
|
85
|
+
type: sticker.type,
|
|
86
|
+
width: sticker.width,
|
|
87
|
+
height: sticker.height,
|
|
88
|
+
isAnimated: sticker.isAnimated ?? sticker.is_animated,
|
|
89
|
+
isVideo: sticker.isVideo ?? sticker.is_video,
|
|
90
|
+
thumbnail: sticker.thumbnail ? normalizeTelegramPhotoSize(sticker.thumbnail) : void 0,
|
|
91
|
+
emoji: sticker.emoji,
|
|
92
|
+
setName: sticker.setName ?? sticker.set_name,
|
|
93
|
+
fileSize: sticker.fileSize ?? sticker.file_size
|
|
94
|
+
});
|
|
95
|
+
}
|
|
96
|
+
function normalizeTelegramAnimation(input) {
|
|
97
|
+
const animation = input;
|
|
98
|
+
return telegramAnimationSchema.parse({
|
|
99
|
+
fileId: animation.fileId ?? animation.file_id,
|
|
100
|
+
fileUniqueId: animation.fileUniqueId ?? animation.file_unique_id,
|
|
101
|
+
width: animation.width,
|
|
102
|
+
height: animation.height,
|
|
103
|
+
duration: animation.duration,
|
|
104
|
+
fileName: animation.fileName ?? animation.file_name,
|
|
105
|
+
mimeType: animation.mimeType ?? animation.mime_type,
|
|
106
|
+
fileSize: animation.fileSize ?? animation.file_size,
|
|
107
|
+
thumbnail: animation.thumbnail ? normalizeTelegramPhotoSize(animation.thumbnail) : void 0
|
|
108
|
+
});
|
|
109
|
+
}
|
|
110
|
+
function normalizeTelegramMessageEntity(input) {
|
|
111
|
+
const entity = input;
|
|
112
|
+
return telegramMessageEntitySchema.parse({
|
|
113
|
+
type: entity.type,
|
|
114
|
+
offset: entity.offset,
|
|
115
|
+
length: entity.length
|
|
116
|
+
});
|
|
117
|
+
}
|
|
118
|
+
function normalizeTelegramUser(input) {
|
|
119
|
+
const user = input;
|
|
120
|
+
return telegramUserSchema.parse({
|
|
121
|
+
id: user.id,
|
|
122
|
+
isBot: user.isBot ?? user.is_bot,
|
|
123
|
+
firstName: user.firstName ?? user.first_name,
|
|
124
|
+
lastName: user.lastName ?? user.last_name,
|
|
125
|
+
username: user.username,
|
|
126
|
+
languageCode: user.languageCode ?? user.language_code
|
|
127
|
+
});
|
|
128
|
+
}
|
|
129
|
+
function normalizeTelegramChat(input) {
|
|
130
|
+
const chat = input;
|
|
131
|
+
return telegramChatSchema.parse({
|
|
132
|
+
id: chat.id,
|
|
133
|
+
type: chat.type,
|
|
134
|
+
title: chat.title,
|
|
135
|
+
username: chat.username,
|
|
136
|
+
firstName: chat.firstName ?? chat.first_name,
|
|
137
|
+
lastName: chat.lastName ?? chat.last_name,
|
|
138
|
+
isForum: chat.isForum ?? chat.is_forum
|
|
139
|
+
});
|
|
140
|
+
}
|
|
141
|
+
function normalizeTelegramMessage(input) {
|
|
142
|
+
const message = input;
|
|
143
|
+
return telegramMessageSchema.parse({
|
|
144
|
+
messageId: message.messageId ?? message.message_id,
|
|
145
|
+
date: message.date,
|
|
146
|
+
editDate: message.editDate ?? message.edit_date,
|
|
147
|
+
text: message.text,
|
|
148
|
+
from: message.from ? normalizeTelegramUser(message.from) : void 0,
|
|
149
|
+
senderChat: message.senderChat ?? message.sender_chat ? normalizeTelegramChat(message.senderChat ?? message.sender_chat) : void 0,
|
|
150
|
+
chat: normalizeTelegramChat(message.chat),
|
|
151
|
+
replyToMessage: message.replyToMessage ?? message.reply_to_message ? normalizeTelegramMessage(message.replyToMessage ?? message.reply_to_message) : void 0,
|
|
152
|
+
newChatMembers: (message.newChatMembers ?? message.new_chat_members)?.map(normalizeTelegramUser),
|
|
153
|
+
leftChatMember: message.leftChatMember ?? message.left_chat_member ? normalizeTelegramUser(message.leftChatMember ?? message.left_chat_member) : void 0,
|
|
154
|
+
entities: message.entities?.map(normalizeTelegramMessageEntity),
|
|
155
|
+
mediaGroupId: message.mediaGroupId ?? message.media_group_id,
|
|
156
|
+
photo: message.photo?.map(normalizeTelegramPhotoSize),
|
|
157
|
+
voice: message.voice ? normalizeTelegramVoice(message.voice) : void 0,
|
|
158
|
+
audio: message.audio ? normalizeTelegramAudio(message.audio) : void 0,
|
|
159
|
+
document: message.document ? normalizeTelegramDocument(message.document) : void 0,
|
|
160
|
+
video: message.video ? normalizeTelegramVideo(message.video) : void 0,
|
|
161
|
+
videoNote: message.videoNote ?? message.video_note ? normalizeTelegramVideoNote(message.videoNote ?? message.video_note) : void 0,
|
|
162
|
+
sticker: message.sticker ? normalizeTelegramSticker(message.sticker) : void 0,
|
|
163
|
+
animation: message.animation ? normalizeTelegramAnimation(message.animation) : void 0
|
|
164
|
+
});
|
|
165
|
+
}
|
|
166
|
+
function normalizeTelegramUpdate(input) {
|
|
167
|
+
const update = input;
|
|
168
|
+
return telegramUpdateSchema.parse({
|
|
169
|
+
updateId: update.updateId ?? update.update_id,
|
|
170
|
+
message: update.message ? normalizeTelegramMessage(update.message) : void 0,
|
|
171
|
+
editedMessage: update.editedMessage ?? update.edited_message ? normalizeTelegramMessage(update.editedMessage ?? update.edited_message) : void 0,
|
|
172
|
+
channelPost: update.channelPost ?? update.channel_post ? normalizeTelegramMessage(update.channelPost ?? update.channel_post) : void 0
|
|
173
|
+
});
|
|
174
|
+
}
|
|
175
|
+
function safeNormalizeTelegramMessage(input) {
|
|
176
|
+
try {
|
|
177
|
+
return normalizeTelegramMessage(input);
|
|
178
|
+
} catch {
|
|
179
|
+
return null;
|
|
180
|
+
}
|
|
181
|
+
}
|
|
10
182
|
function parseTelegramUpdate(update) {
|
|
11
183
|
if (update.message) return {
|
|
12
|
-
updateId: update.
|
|
184
|
+
updateId: update.updateId,
|
|
13
185
|
type: "message",
|
|
14
186
|
message: update.message
|
|
15
187
|
};
|
|
16
|
-
if (update.
|
|
17
|
-
updateId: update.
|
|
188
|
+
if (update.editedMessage) return {
|
|
189
|
+
updateId: update.updateId,
|
|
18
190
|
type: "edited_message",
|
|
19
|
-
message: update.
|
|
191
|
+
message: update.editedMessage
|
|
20
192
|
};
|
|
21
|
-
if (update.
|
|
22
|
-
updateId: update.
|
|
193
|
+
if (update.channelPost) return {
|
|
194
|
+
updateId: update.updateId,
|
|
23
195
|
type: "channel_post",
|
|
24
|
-
message: update.
|
|
196
|
+
message: update.channelPost
|
|
25
197
|
};
|
|
26
198
|
return null;
|
|
27
199
|
}
|
|
@@ -31,6 +203,109 @@ function buildMessageId(chatId, messageId) {
|
|
|
31
203
|
function buildChatMemberId(chatId, userId) {
|
|
32
204
|
return `${chatId}:${userId}`;
|
|
33
205
|
}
|
|
206
|
+
const isDefined = (value) => value != null;
|
|
207
|
+
const toAttachmentPhotoSize = (photo) => {
|
|
208
|
+
if (!photo) return null;
|
|
209
|
+
return {
|
|
210
|
+
fileId: photo.fileId,
|
|
211
|
+
fileUniqueId: photo.fileUniqueId,
|
|
212
|
+
fileSize: photo.fileSize,
|
|
213
|
+
width: photo.width,
|
|
214
|
+
height: photo.height
|
|
215
|
+
};
|
|
216
|
+
};
|
|
217
|
+
const readThumbnail = (value) => toAttachmentPhotoSize(value?.thumbnail) ?? void 0;
|
|
218
|
+
function extractTelegramAttachments(message) {
|
|
219
|
+
const attachments = [];
|
|
220
|
+
const photoSizes = message.photo?.map(toAttachmentPhotoSize).filter(isDefined) ?? [];
|
|
221
|
+
const largestPhoto = photoSizes.at(-1);
|
|
222
|
+
if (largestPhoto) attachments.push({
|
|
223
|
+
kind: "photo",
|
|
224
|
+
fileId: largestPhoto.fileId,
|
|
225
|
+
fileUniqueId: largestPhoto.fileUniqueId,
|
|
226
|
+
fileSize: largestPhoto.fileSize,
|
|
227
|
+
width: largestPhoto.width,
|
|
228
|
+
height: largestPhoto.height,
|
|
229
|
+
thumbnail: photoSizes[0],
|
|
230
|
+
sizes: photoSizes
|
|
231
|
+
});
|
|
232
|
+
if (message.voice) attachments.push({
|
|
233
|
+
kind: "voice",
|
|
234
|
+
fileId: message.voice.fileId,
|
|
235
|
+
fileUniqueId: message.voice.fileUniqueId,
|
|
236
|
+
fileSize: message.voice.fileSize,
|
|
237
|
+
duration: message.voice.duration,
|
|
238
|
+
mimeType: message.voice.mimeType
|
|
239
|
+
});
|
|
240
|
+
if (message.audio) attachments.push({
|
|
241
|
+
kind: "audio",
|
|
242
|
+
fileId: message.audio.fileId,
|
|
243
|
+
fileUniqueId: message.audio.fileUniqueId,
|
|
244
|
+
fileSize: message.audio.fileSize,
|
|
245
|
+
duration: message.audio.duration,
|
|
246
|
+
performer: message.audio.performer,
|
|
247
|
+
title: message.audio.title,
|
|
248
|
+
fileName: message.audio.fileName,
|
|
249
|
+
mimeType: message.audio.mimeType,
|
|
250
|
+
thumbnail: readThumbnail(message.audio)
|
|
251
|
+
});
|
|
252
|
+
if (message.document) attachments.push({
|
|
253
|
+
kind: "document",
|
|
254
|
+
fileId: message.document.fileId,
|
|
255
|
+
fileUniqueId: message.document.fileUniqueId,
|
|
256
|
+
fileSize: message.document.fileSize,
|
|
257
|
+
fileName: message.document.fileName,
|
|
258
|
+
mimeType: message.document.mimeType,
|
|
259
|
+
thumbnail: readThumbnail(message.document)
|
|
260
|
+
});
|
|
261
|
+
if (message.video) attachments.push({
|
|
262
|
+
kind: "video",
|
|
263
|
+
fileId: message.video.fileId,
|
|
264
|
+
fileUniqueId: message.video.fileUniqueId,
|
|
265
|
+
fileSize: message.video.fileSize,
|
|
266
|
+
width: message.video.width,
|
|
267
|
+
height: message.video.height,
|
|
268
|
+
duration: message.video.duration,
|
|
269
|
+
fileName: message.video.fileName,
|
|
270
|
+
mimeType: message.video.mimeType,
|
|
271
|
+
thumbnail: readThumbnail(message.video)
|
|
272
|
+
});
|
|
273
|
+
if (message.videoNote) attachments.push({
|
|
274
|
+
kind: "video_note",
|
|
275
|
+
fileId: message.videoNote.fileId,
|
|
276
|
+
fileUniqueId: message.videoNote.fileUniqueId,
|
|
277
|
+
fileSize: message.videoNote.fileSize,
|
|
278
|
+
length: message.videoNote.length,
|
|
279
|
+
duration: message.videoNote.duration,
|
|
280
|
+
thumbnail: readThumbnail(message.videoNote)
|
|
281
|
+
});
|
|
282
|
+
if (message.sticker) attachments.push({
|
|
283
|
+
kind: "sticker",
|
|
284
|
+
fileId: message.sticker.fileId,
|
|
285
|
+
fileUniqueId: message.sticker.fileUniqueId,
|
|
286
|
+
fileSize: message.sticker.fileSize,
|
|
287
|
+
width: message.sticker.width,
|
|
288
|
+
height: message.sticker.height,
|
|
289
|
+
emoji: message.sticker.emoji,
|
|
290
|
+
setName: message.sticker.setName,
|
|
291
|
+
isAnimated: message.sticker.isAnimated,
|
|
292
|
+
isVideo: message.sticker.isVideo,
|
|
293
|
+
thumbnail: readThumbnail(message.sticker)
|
|
294
|
+
});
|
|
295
|
+
if (message.animation) attachments.push({
|
|
296
|
+
kind: "animation",
|
|
297
|
+
fileId: message.animation.fileId,
|
|
298
|
+
fileUniqueId: message.animation.fileUniqueId,
|
|
299
|
+
fileSize: message.animation.fileSize,
|
|
300
|
+
width: message.animation.width,
|
|
301
|
+
height: message.animation.height,
|
|
302
|
+
duration: message.animation.duration,
|
|
303
|
+
fileName: message.animation.fileName,
|
|
304
|
+
mimeType: message.animation.mimeType,
|
|
305
|
+
thumbnail: readThumbnail(message.animation)
|
|
306
|
+
});
|
|
307
|
+
return attachments;
|
|
308
|
+
}
|
|
34
309
|
function parseCommand(message, botUsername) {
|
|
35
310
|
if (!message.text) return null;
|
|
36
311
|
const text = message.text;
|
|
@@ -57,5 +332,5 @@ function parseCommandBindings(value) {
|
|
|
57
332
|
}
|
|
58
333
|
|
|
59
334
|
//#endregion
|
|
60
|
-
export { DEFAULT_COMMAND_SCOPES, buildChatMemberId, buildMessageId, parseCommand, parseCommandBindings, parseTelegramUpdate };
|
|
335
|
+
export { DEFAULT_COMMAND_SCOPES, buildChatMemberId, buildMessageId, extractTelegramAttachments, normalizeTelegramMessage, normalizeTelegramUpdate, parseCommand, parseCommandBindings, parseTelegramUpdate, safeNormalizeTelegramMessage };
|
|
61
336
|
//# sourceMappingURL=telegram-utils.js.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"telegram-utils.js","names":[],"sources":["../../src/telegram-utils.ts"],"sourcesContent":["import type {\n TelegramCommandBindings,\n TelegramCommandScope,\n TelegramMessage,\n TelegramUpdate,\n TelegramUpdateType,\n} from \"./types\";\nimport { telegramCommandBindingsSchema } from \"./types\";\n\nexport const DEFAULT_COMMAND_SCOPES: TelegramCommandScope[] = [\n \"private\",\n \"group\",\n \"supergroup\",\n \"channel\",\n];\n\nexport type ParsedTelegramUpdate = {\n updateId: number;\n type: TelegramUpdateType;\n message: TelegramMessage;\n};\n\nexport function parseTelegramUpdate(update: TelegramUpdate): ParsedTelegramUpdate | null {\n if (update.message) {\n return { updateId: update.update_id, type: \"message\", message: update.message };\n }\n if (update.edited_message) {\n return { updateId: update.update_id, type: \"edited_message\", message: update.edited_message };\n }\n if (update.channel_post) {\n return { updateId: update.update_id, type: \"channel_post\", message: update.channel_post };\n }\n return null;\n}\n\nexport function buildMessageId(chatId: string, messageId: number): string {\n return `${chatId}:${messageId}`;\n}\n\nexport function buildChatMemberId(chatId: string, userId: string): string {\n return `${chatId}:${userId}`;\n}\n\nexport function parseCommand(\n message: TelegramMessage,\n botUsername?: string,\n): { name: string; args: string; raw: string } | null {\n if (!message.text) {\n return null;\n }\n\n const text = message.text;\n let commandToken: string | null = null;\n\n const entity = message.entities?.find(\n (entry) => entry.type === \"bot_command\" && entry.offset === 0,\n );\n if (entity) {\n commandToken = text.slice(0, entity.length);\n }\n\n if (!commandToken && text.startsWith(\"/\")) {\n commandToken = text.split(/\\s+/)[0] ?? null;\n }\n\n if (!commandToken) {\n return null;\n }\n\n const withoutSlash = commandToken.slice(1);\n if (!withoutSlash) {\n return null;\n }\n\n const [name, atBot] = withoutSlash.split(\"@\");\n if (atBot && botUsername && atBot.toLowerCase() !== botUsername.toLowerCase()) {\n return null;\n }\n\n const args = text.slice(commandToken.length).trim();\n\n return {\n name,\n args,\n raw: commandToken,\n };\n}\n\nexport function parseCommandBindings(value: unknown): TelegramCommandBindings {\n if (!value) {\n return {};\n }\n const result = telegramCommandBindingsSchema.safeParse(value);\n if (!result.success) {\n return {};\n }\n return result.data;\n}\n"],"mappings":";;;AASA,MAAa,yBAAiD;CAC5D;CACA;CACA;CACA;CACD;AAQD,SAAgB,oBAAoB,QAAqD;AACvF,KAAI,OAAO,QACT,QAAO;EAAE,UAAU,OAAO;EAAW,MAAM;EAAW,SAAS,OAAO;EAAS;AAEjF,KAAI,OAAO,eACT,QAAO;EAAE,UAAU,OAAO;EAAW,MAAM;EAAkB,SAAS,OAAO;EAAgB;AAE/F,KAAI,OAAO,aACT,QAAO;EAAE,UAAU,OAAO;EAAW,MAAM;EAAgB,SAAS,OAAO;EAAc;AAE3F,QAAO;;AAGT,SAAgB,eAAe,QAAgB,WAA2B;AACxE,QAAO,GAAG,OAAO,GAAG;;AAGtB,SAAgB,kBAAkB,QAAgB,QAAwB;AACxE,QAAO,GAAG,OAAO,GAAG;;AAGtB,SAAgB,aACd,SACA,aACoD;AACpD,KAAI,CAAC,QAAQ,KACX,QAAO;CAGT,MAAM,OAAO,QAAQ;CACrB,IAAI,eAA8B;CAElC,MAAM,SAAS,QAAQ,UAAU,MAC9B,UAAU,MAAM,SAAS,iBAAiB,MAAM,WAAW,EAC7D;AACD,KAAI,OACF,gBAAe,KAAK,MAAM,GAAG,OAAO,OAAO;AAG7C,KAAI,CAAC,gBAAgB,KAAK,WAAW,IAAI,CACvC,gBAAe,KAAK,MAAM,MAAM,CAAC,MAAM;AAGzC,KAAI,CAAC,aACH,QAAO;CAGT,MAAM,eAAe,aAAa,MAAM,EAAE;AAC1C,KAAI,CAAC,aACH,QAAO;CAGT,MAAM,CAAC,MAAM,SAAS,aAAa,MAAM,IAAI;AAC7C,KAAI,SAAS,eAAe,MAAM,aAAa,KAAK,YAAY,aAAa,CAC3E,QAAO;AAKT,QAAO;EACL;EACA,MAJW,KAAK,MAAM,aAAa,OAAO,CAAC,MAAM;EAKjD,KAAK;EACN;;AAGH,SAAgB,qBAAqB,OAAyC;AAC5E,KAAI,CAAC,MACH,QAAO,EAAE;CAEX,MAAM,SAAS,8BAA8B,UAAU,MAAM;AAC7D,KAAI,CAAC,OAAO,QACV,QAAO,EAAE;AAEX,QAAO,OAAO"}
|
|
1
|
+
{"version":3,"file":"telegram-utils.js","names":[],"sources":["../../src/telegram-utils.ts"],"sourcesContent":["import type {\n TelegramAttachment,\n TelegramAttachmentPhotoSize,\n TelegramAudio,\n TelegramChat,\n TelegramCommandBindings,\n TelegramCommandScope,\n TelegramDocument,\n TelegramMessage,\n TelegramMessageEntity,\n TelegramPhotoSize,\n TelegramSticker,\n TelegramUpdate,\n TelegramUpdateType,\n TelegramUser,\n TelegramVideo,\n TelegramVideoNote,\n TelegramVoice,\n TelegramAnimation,\n} from \"./types\";\nimport {\n telegramAudioSchema,\n telegramAnimationSchema,\n telegramChatSchema,\n telegramCommandBindingsSchema,\n telegramDocumentSchema,\n telegramMessageEntitySchema,\n telegramMessageSchema,\n telegramPhotoSizeSchema,\n telegramStickerSchema,\n telegramUpdateSchema,\n telegramUserSchema,\n telegramVideoNoteSchema,\n telegramVideoSchema,\n telegramVoiceSchema,\n} from \"./types\";\n\nexport const DEFAULT_COMMAND_SCOPES: TelegramCommandScope[] = [\n \"private\",\n \"group\",\n \"supergroup\",\n \"channel\",\n];\n\nexport type ParsedTelegramUpdate = {\n updateId: number;\n type: TelegramUpdateType;\n message: TelegramMessage;\n};\n\ntype TelegramPhotoSizeInput = Partial<TelegramPhotoSize> & {\n file_id?: string;\n file_unique_id?: string;\n file_size?: number;\n};\n\ntype TelegramVoiceInput = Partial<TelegramVoice> & {\n file_id?: string;\n file_unique_id?: string;\n mime_type?: string;\n file_size?: number;\n};\n\ntype TelegramAudioInput = Partial<TelegramAudio> & {\n file_id?: string;\n file_unique_id?: string;\n file_name?: string;\n mime_type?: string;\n file_size?: number;\n};\n\ntype TelegramDocumentInput = Partial<TelegramDocument> & {\n file_id?: string;\n file_unique_id?: string;\n file_name?: string;\n mime_type?: string;\n file_size?: number;\n};\n\ntype TelegramVideoInput = Partial<TelegramVideo> & {\n file_id?: string;\n file_unique_id?: string;\n file_name?: string;\n mime_type?: string;\n file_size?: number;\n};\n\ntype TelegramVideoNoteInput = Partial<TelegramVideoNote> & {\n file_id?: string;\n file_unique_id?: string;\n file_size?: number;\n};\n\ntype TelegramStickerInput = Partial<TelegramSticker> & {\n file_id?: string;\n file_unique_id?: string;\n is_animated?: boolean;\n is_video?: boolean;\n set_name?: string;\n file_size?: number;\n};\n\ntype TelegramAnimationInput = Partial<TelegramAnimation> & {\n file_id?: string;\n file_unique_id?: string;\n file_name?: string;\n mime_type?: string;\n file_size?: number;\n};\n\ntype TelegramMessageEntityInput = Partial<TelegramMessageEntity>;\n\ntype TelegramUserInput = Partial<TelegramUser> & {\n is_bot?: boolean;\n first_name?: string;\n last_name?: string;\n language_code?: string;\n};\n\ntype TelegramChatInput = Partial<TelegramChat> & {\n first_name?: string;\n last_name?: string;\n is_forum?: boolean;\n};\n\ntype TelegramMessageInput = Partial<TelegramMessage> & {\n message_id?: number;\n edit_date?: number;\n sender_chat?: unknown;\n reply_to_message?: unknown;\n new_chat_members?: unknown[];\n left_chat_member?: unknown;\n media_group_id?: string;\n video_note?: unknown;\n};\n\ntype TelegramUpdateInput = Partial<TelegramUpdate> & {\n update_id?: number;\n edited_message?: unknown;\n channel_post?: unknown;\n};\n\nexport function normalizeTelegramPhotoSize(input: unknown): TelegramPhotoSize {\n const photo = input as TelegramPhotoSizeInput;\n return telegramPhotoSizeSchema.parse({\n fileId: photo.fileId ?? photo.file_id,\n fileUniqueId: photo.fileUniqueId ?? photo.file_unique_id,\n width: photo.width,\n height: photo.height,\n fileSize: photo.fileSize ?? photo.file_size,\n });\n}\n\nexport function normalizeTelegramVoice(input: unknown): TelegramVoice {\n const voice = input as TelegramVoiceInput;\n return telegramVoiceSchema.parse({\n fileId: voice.fileId ?? voice.file_id,\n fileUniqueId: voice.fileUniqueId ?? voice.file_unique_id,\n duration: voice.duration,\n mimeType: voice.mimeType ?? voice.mime_type,\n fileSize: voice.fileSize ?? voice.file_size,\n });\n}\n\nexport function normalizeTelegramAudio(input: unknown): TelegramAudio {\n const audio = input as TelegramAudioInput;\n return telegramAudioSchema.parse({\n fileId: audio.fileId ?? audio.file_id,\n fileUniqueId: audio.fileUniqueId ?? audio.file_unique_id,\n duration: audio.duration,\n performer: audio.performer,\n title: audio.title,\n fileName: audio.fileName ?? audio.file_name,\n mimeType: audio.mimeType ?? audio.mime_type,\n fileSize: audio.fileSize ?? audio.file_size,\n thumbnail: audio.thumbnail ? normalizeTelegramPhotoSize(audio.thumbnail) : undefined,\n });\n}\n\nexport function normalizeTelegramDocument(input: unknown): TelegramDocument {\n const document = input as TelegramDocumentInput;\n return telegramDocumentSchema.parse({\n fileId: document.fileId ?? document.file_id,\n fileUniqueId: document.fileUniqueId ?? document.file_unique_id,\n fileName: document.fileName ?? document.file_name,\n mimeType: document.mimeType ?? document.mime_type,\n fileSize: document.fileSize ?? document.file_size,\n thumbnail: document.thumbnail ? normalizeTelegramPhotoSize(document.thumbnail) : undefined,\n });\n}\n\nexport function normalizeTelegramVideo(input: unknown): TelegramVideo {\n const video = input as TelegramVideoInput;\n return telegramVideoSchema.parse({\n fileId: video.fileId ?? video.file_id,\n fileUniqueId: video.fileUniqueId ?? video.file_unique_id,\n width: video.width,\n height: video.height,\n duration: video.duration,\n fileName: video.fileName ?? video.file_name,\n mimeType: video.mimeType ?? video.mime_type,\n fileSize: video.fileSize ?? video.file_size,\n thumbnail: video.thumbnail ? normalizeTelegramPhotoSize(video.thumbnail) : undefined,\n });\n}\n\nexport function normalizeTelegramVideoNote(input: unknown): TelegramVideoNote {\n const videoNote = input as TelegramVideoNoteInput;\n return telegramVideoNoteSchema.parse({\n fileId: videoNote.fileId ?? videoNote.file_id,\n fileUniqueId: videoNote.fileUniqueId ?? videoNote.file_unique_id,\n length: videoNote.length,\n duration: videoNote.duration,\n fileSize: videoNote.fileSize ?? videoNote.file_size,\n thumbnail: videoNote.thumbnail ? normalizeTelegramPhotoSize(videoNote.thumbnail) : undefined,\n });\n}\n\nexport function normalizeTelegramSticker(input: unknown): TelegramSticker {\n const sticker = input as TelegramStickerInput;\n return telegramStickerSchema.parse({\n fileId: sticker.fileId ?? sticker.file_id,\n fileUniqueId: sticker.fileUniqueId ?? sticker.file_unique_id,\n type: sticker.type,\n width: sticker.width,\n height: sticker.height,\n isAnimated: sticker.isAnimated ?? sticker.is_animated,\n isVideo: sticker.isVideo ?? sticker.is_video,\n thumbnail: sticker.thumbnail ? normalizeTelegramPhotoSize(sticker.thumbnail) : undefined,\n emoji: sticker.emoji,\n setName: sticker.setName ?? sticker.set_name,\n fileSize: sticker.fileSize ?? sticker.file_size,\n });\n}\n\nexport function normalizeTelegramAnimation(input: unknown): TelegramAnimation {\n const animation = input as TelegramAnimationInput;\n return telegramAnimationSchema.parse({\n fileId: animation.fileId ?? animation.file_id,\n fileUniqueId: animation.fileUniqueId ?? animation.file_unique_id,\n width: animation.width,\n height: animation.height,\n duration: animation.duration,\n fileName: animation.fileName ?? animation.file_name,\n mimeType: animation.mimeType ?? animation.mime_type,\n fileSize: animation.fileSize ?? animation.file_size,\n thumbnail: animation.thumbnail ? normalizeTelegramPhotoSize(animation.thumbnail) : undefined,\n });\n}\n\nexport function normalizeTelegramMessageEntity(input: unknown): TelegramMessageEntity {\n const entity = input as TelegramMessageEntityInput;\n return telegramMessageEntitySchema.parse({\n type: entity.type,\n offset: entity.offset,\n length: entity.length,\n });\n}\n\nexport function normalizeTelegramUser(input: unknown): TelegramUser {\n const user = input as TelegramUserInput;\n return telegramUserSchema.parse({\n id: user.id,\n isBot: user.isBot ?? user.is_bot,\n firstName: user.firstName ?? user.first_name,\n lastName: user.lastName ?? user.last_name,\n username: user.username,\n languageCode: user.languageCode ?? user.language_code,\n });\n}\n\nexport function normalizeTelegramChat(input: unknown): TelegramChat {\n const chat = input as TelegramChatInput;\n return telegramChatSchema.parse({\n id: chat.id,\n type: chat.type,\n title: chat.title,\n username: chat.username,\n firstName: chat.firstName ?? chat.first_name,\n lastName: chat.lastName ?? chat.last_name,\n isForum: chat.isForum ?? chat.is_forum,\n });\n}\n\nexport function normalizeTelegramMessage(input: unknown): TelegramMessage {\n const message = input as TelegramMessageInput;\n return telegramMessageSchema.parse({\n messageId: message.messageId ?? message.message_id,\n date: message.date,\n editDate: message.editDate ?? message.edit_date,\n text: message.text,\n from: message.from ? normalizeTelegramUser(message.from) : undefined,\n senderChat:\n (message.senderChat ?? message.sender_chat)\n ? normalizeTelegramChat(message.senderChat ?? message.sender_chat)\n : undefined,\n chat: normalizeTelegramChat(message.chat),\n replyToMessage:\n (message.replyToMessage ?? message.reply_to_message)\n ? normalizeTelegramMessage(message.replyToMessage ?? message.reply_to_message)\n : undefined,\n newChatMembers: (message.newChatMembers ?? message.new_chat_members)?.map(\n normalizeTelegramUser,\n ),\n leftChatMember:\n (message.leftChatMember ?? message.left_chat_member)\n ? normalizeTelegramUser(message.leftChatMember ?? message.left_chat_member)\n : undefined,\n entities: message.entities?.map(normalizeTelegramMessageEntity),\n mediaGroupId: message.mediaGroupId ?? message.media_group_id,\n photo: message.photo?.map(normalizeTelegramPhotoSize),\n voice: message.voice ? normalizeTelegramVoice(message.voice) : undefined,\n audio: message.audio ? normalizeTelegramAudio(message.audio) : undefined,\n document: message.document ? normalizeTelegramDocument(message.document) : undefined,\n video: message.video ? normalizeTelegramVideo(message.video) : undefined,\n videoNote:\n (message.videoNote ?? message.video_note)\n ? normalizeTelegramVideoNote(message.videoNote ?? message.video_note)\n : undefined,\n sticker: message.sticker ? normalizeTelegramSticker(message.sticker) : undefined,\n animation: message.animation ? normalizeTelegramAnimation(message.animation) : undefined,\n });\n}\n\nexport function normalizeTelegramUpdate(input: unknown): TelegramUpdate {\n const update = input as TelegramUpdateInput;\n return telegramUpdateSchema.parse({\n updateId: update.updateId ?? update.update_id,\n message: update.message ? normalizeTelegramMessage(update.message) : undefined,\n editedMessage:\n (update.editedMessage ?? update.edited_message)\n ? normalizeTelegramMessage(update.editedMessage ?? update.edited_message)\n : undefined,\n channelPost:\n (update.channelPost ?? update.channel_post)\n ? normalizeTelegramMessage(update.channelPost ?? update.channel_post)\n : undefined,\n });\n}\n\nexport function safeNormalizeTelegramMessage(input: unknown): TelegramMessage | null {\n try {\n return normalizeTelegramMessage(input);\n } catch {\n return null;\n }\n}\n\nexport function safeNormalizeTelegramUpdate(input: unknown): TelegramUpdate | null {\n try {\n return normalizeTelegramUpdate(input);\n } catch {\n return null;\n }\n}\n\nexport function parseTelegramUpdate(update: TelegramUpdate): ParsedTelegramUpdate | null {\n if (update.message) {\n return { updateId: update.updateId, type: \"message\", message: update.message };\n }\n if (update.editedMessage) {\n return { updateId: update.updateId, type: \"edited_message\", message: update.editedMessage };\n }\n if (update.channelPost) {\n return { updateId: update.updateId, type: \"channel_post\", message: update.channelPost };\n }\n return null;\n}\n\nexport function buildMessageId(chatId: string, messageId: number): string {\n return `${chatId}:${messageId}`;\n}\n\nexport function buildChatMemberId(chatId: string, userId: string): string {\n return `${chatId}:${userId}`;\n}\n\nconst isDefined = <T>(value: T | null | undefined): value is T => value != null;\n\nconst toAttachmentPhotoSize = (\n photo: TelegramPhotoSize | undefined,\n): TelegramAttachmentPhotoSize | null => {\n if (!photo) {\n return null;\n }\n\n return {\n fileId: photo.fileId,\n fileUniqueId: photo.fileUniqueId,\n fileSize: photo.fileSize,\n width: photo.width,\n height: photo.height,\n };\n};\n\nconst readThumbnail = (\n value:\n | {\n thumbnail?: TelegramPhotoSize;\n }\n | undefined,\n) => toAttachmentPhotoSize(value?.thumbnail) ?? undefined;\n\nexport function extractTelegramAttachments(message: TelegramMessage): TelegramAttachment[] {\n const attachments: TelegramAttachment[] = [];\n\n const photoSizes = message.photo?.map(toAttachmentPhotoSize).filter(isDefined) ?? [];\n const largestPhoto = photoSizes.at(-1);\n if (largestPhoto) {\n attachments.push({\n kind: \"photo\",\n fileId: largestPhoto.fileId,\n fileUniqueId: largestPhoto.fileUniqueId,\n fileSize: largestPhoto.fileSize,\n width: largestPhoto.width,\n height: largestPhoto.height,\n thumbnail: photoSizes[0],\n sizes: photoSizes,\n });\n }\n\n if (message.voice) {\n attachments.push({\n kind: \"voice\",\n fileId: message.voice.fileId,\n fileUniqueId: message.voice.fileUniqueId,\n fileSize: message.voice.fileSize,\n duration: message.voice.duration,\n mimeType: message.voice.mimeType,\n });\n }\n\n if (message.audio) {\n attachments.push({\n kind: \"audio\",\n fileId: message.audio.fileId,\n fileUniqueId: message.audio.fileUniqueId,\n fileSize: message.audio.fileSize,\n duration: message.audio.duration,\n performer: message.audio.performer,\n title: message.audio.title,\n fileName: message.audio.fileName,\n mimeType: message.audio.mimeType,\n thumbnail: readThumbnail(message.audio),\n });\n }\n\n if (message.document) {\n attachments.push({\n kind: \"document\",\n fileId: message.document.fileId,\n fileUniqueId: message.document.fileUniqueId,\n fileSize: message.document.fileSize,\n fileName: message.document.fileName,\n mimeType: message.document.mimeType,\n thumbnail: readThumbnail(message.document),\n });\n }\n\n if (message.video) {\n attachments.push({\n kind: \"video\",\n fileId: message.video.fileId,\n fileUniqueId: message.video.fileUniqueId,\n fileSize: message.video.fileSize,\n width: message.video.width,\n height: message.video.height,\n duration: message.video.duration,\n fileName: message.video.fileName,\n mimeType: message.video.mimeType,\n thumbnail: readThumbnail(message.video),\n });\n }\n\n if (message.videoNote) {\n attachments.push({\n kind: \"video_note\",\n fileId: message.videoNote.fileId,\n fileUniqueId: message.videoNote.fileUniqueId,\n fileSize: message.videoNote.fileSize,\n length: message.videoNote.length,\n duration: message.videoNote.duration,\n thumbnail: readThumbnail(message.videoNote),\n });\n }\n\n if (message.sticker) {\n attachments.push({\n kind: \"sticker\",\n fileId: message.sticker.fileId,\n fileUniqueId: message.sticker.fileUniqueId,\n fileSize: message.sticker.fileSize,\n width: message.sticker.width,\n height: message.sticker.height,\n emoji: message.sticker.emoji,\n setName: message.sticker.setName,\n isAnimated: message.sticker.isAnimated,\n isVideo: message.sticker.isVideo,\n thumbnail: readThumbnail(message.sticker),\n });\n }\n\n if (message.animation) {\n attachments.push({\n kind: \"animation\",\n fileId: message.animation.fileId,\n fileUniqueId: message.animation.fileUniqueId,\n fileSize: message.animation.fileSize,\n width: message.animation.width,\n height: message.animation.height,\n duration: message.animation.duration,\n fileName: message.animation.fileName,\n mimeType: message.animation.mimeType,\n thumbnail: readThumbnail(message.animation),\n });\n }\n\n return attachments;\n}\n\nexport function parseCommand(\n message: TelegramMessage,\n botUsername?: string,\n): { name: string; args: string; raw: string } | null {\n if (!message.text) {\n return null;\n }\n\n const text = message.text;\n let commandToken: string | null = null;\n\n const entity = message.entities?.find(\n (entry) => entry.type === \"bot_command\" && entry.offset === 0,\n );\n if (entity) {\n commandToken = text.slice(0, entity.length);\n }\n\n if (!commandToken && text.startsWith(\"/\")) {\n commandToken = text.split(/\\s+/)[0] ?? null;\n }\n\n if (!commandToken) {\n return null;\n }\n\n const withoutSlash = commandToken.slice(1);\n if (!withoutSlash) {\n return null;\n }\n\n const [name, atBot] = withoutSlash.split(\"@\");\n if (atBot && botUsername && atBot.toLowerCase() !== botUsername.toLowerCase()) {\n return null;\n }\n\n const args = text.slice(commandToken.length).trim();\n\n return {\n name,\n args,\n raw: commandToken,\n };\n}\n\nexport function parseCommandBindings(value: unknown): TelegramCommandBindings {\n if (!value) {\n return {};\n }\n const result = telegramCommandBindingsSchema.safeParse(value);\n if (!result.success) {\n return {};\n }\n return result.data;\n}\n"],"mappings":";;;AAqCA,MAAa,yBAAiD;CAC5D;CACA;CACA;CACA;CACD;AAoGD,SAAgB,2BAA2B,OAAmC;CAC5E,MAAM,QAAQ;AACd,QAAO,wBAAwB,MAAM;EACnC,QAAQ,MAAM,UAAU,MAAM;EAC9B,cAAc,MAAM,gBAAgB,MAAM;EAC1C,OAAO,MAAM;EACb,QAAQ,MAAM;EACd,UAAU,MAAM,YAAY,MAAM;EACnC,CAAC;;AAGJ,SAAgB,uBAAuB,OAA+B;CACpE,MAAM,QAAQ;AACd,QAAO,oBAAoB,MAAM;EAC/B,QAAQ,MAAM,UAAU,MAAM;EAC9B,cAAc,MAAM,gBAAgB,MAAM;EAC1C,UAAU,MAAM;EAChB,UAAU,MAAM,YAAY,MAAM;EAClC,UAAU,MAAM,YAAY,MAAM;EACnC,CAAC;;AAGJ,SAAgB,uBAAuB,OAA+B;CACpE,MAAM,QAAQ;AACd,QAAO,oBAAoB,MAAM;EAC/B,QAAQ,MAAM,UAAU,MAAM;EAC9B,cAAc,MAAM,gBAAgB,MAAM;EAC1C,UAAU,MAAM;EAChB,WAAW,MAAM;EACjB,OAAO,MAAM;EACb,UAAU,MAAM,YAAY,MAAM;EAClC,UAAU,MAAM,YAAY,MAAM;EAClC,UAAU,MAAM,YAAY,MAAM;EAClC,WAAW,MAAM,YAAY,2BAA2B,MAAM,UAAU,GAAG;EAC5E,CAAC;;AAGJ,SAAgB,0BAA0B,OAAkC;CAC1E,MAAM,WAAW;AACjB,QAAO,uBAAuB,MAAM;EAClC,QAAQ,SAAS,UAAU,SAAS;EACpC,cAAc,SAAS,gBAAgB,SAAS;EAChD,UAAU,SAAS,Y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