@mtkruto/node 0.1.132 → 0.1.133
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/esm/3_types.d.ts +3 -0
- package/esm/3_types.js +3 -0
- package/esm/4_constants.d.ts +2 -2
- package/esm/4_constants.js +2 -2
- package/esm/client/0_utilities.d.ts +2 -2
- package/esm/client/0_utilities.js +3 -5
- package/esm/client/3_types.d.ts +10 -5
- package/esm/client/4_composer.d.ts +4 -4
- package/esm/client/4_composer.js +13 -1
- package/esm/client/5_client.d.ts +36 -36
- package/esm/client/5_client.js +181 -177
- package/esm/tl/2_types.d.ts +313 -24
- package/esm/tl/2_types.js +982 -46
- package/esm/tl/3_functions.d.ts +95 -32
- package/esm/tl/3_functions.js +227 -66
- package/esm/types/0_chat_photo.d.ts +22 -21
- package/esm/types/0_giveaway_parameters.d.ts +9 -0
- package/esm/types/0_giveaway_parameters.js +9 -0
- package/esm/types/0_message_entity.d.ts +93 -74
- package/esm/types/0_reaction.d.ts +13 -10
- package/esm/types/0_reaction.js +16 -1
- package/esm/types/1_bot_command_scope.d.ts +32 -27
- package/esm/types/1_chat_p.d.ts +76 -68
- package/esm/types/1_giveaway.d.ts +8 -0
- package/esm/types/1_giveaway.js +7 -0
- package/esm/types/1_keyboard_button.d.ts +62 -56
- package/esm/types/1_keyboard_button.js +3 -0
- package/esm/types/1_message_reaction.d.ts +14 -0
- package/esm/types/1_message_reaction.js +22 -0
- package/esm/types/1_user.d.ts +2 -2
- package/esm/types/2_inline_keyboard_button.d.ts +44 -37
- package/esm/types/3_message.d.ts +170 -113
- package/esm/types/3_message.js +218 -121
- package/esm/types/4_chat.d.ts +32 -29
- package/package.json +1 -1
- package/script/3_types.d.ts +3 -0
- package/script/3_types.js +3 -0
- package/script/4_constants.d.ts +2 -2
- package/script/4_constants.js +2 -2
- package/script/client/0_utilities.d.ts +2 -2
- package/script/client/0_utilities.js +3 -5
- package/script/client/3_types.d.ts +10 -5
- package/script/client/4_composer.d.ts +4 -4
- package/script/client/4_composer.js +13 -1
- package/script/client/5_client.d.ts +36 -36
- package/script/client/5_client.js +180 -176
- package/script/tl/2_types.d.ts +313 -24
- package/script/tl/2_types.js +1169 -217
- package/script/tl/3_functions.d.ts +95 -32
- package/script/tl/3_functions.js +241 -77
- package/script/types/0_chat_photo.d.ts +22 -21
- package/script/types/0_giveaway_parameters.d.ts +9 -0
- package/script/types/0_giveaway_parameters.js +13 -0
- package/script/types/0_message_entity.d.ts +93 -74
- package/script/types/0_reaction.d.ts +13 -10
- package/script/types/0_reaction.js +19 -0
- package/script/types/1_bot_command_scope.d.ts +32 -27
- package/script/types/1_chat_p.d.ts +76 -68
- package/script/types/1_giveaway.d.ts +8 -0
- package/script/types/1_giveaway.js +11 -0
- package/script/types/1_keyboard_button.d.ts +62 -56
- package/script/types/1_keyboard_button.js +3 -0
- package/script/types/1_message_reaction.d.ts +14 -0
- package/script/types/1_message_reaction.js +26 -0
- package/script/types/1_user.d.ts +2 -2
- package/script/types/2_inline_keyboard_button.d.ts +44 -37
- package/script/types/3_message.d.ts +170 -113
- package/script/types/3_message.js +220 -122
- package/script/types/4_chat.d.ts +32 -29
package/esm/types/3_message.js
CHANGED
|
@@ -12,19 +12,68 @@ import { constructReplyKeyboardRemove } from "./0_reply_keyboard_remove.js";
|
|
|
12
12
|
import { constructVenue } from "./0_venue.js";
|
|
13
13
|
import { constructVoice } from "./0_voice.js";
|
|
14
14
|
import { constructAnimation } from "./1_animation.js";
|
|
15
|
-
import { constructReplyQuote } from "./1_reply_quote.js";
|
|
16
15
|
import { constructChatP } from "./1_chat_p.js";
|
|
17
16
|
import { constructDocument } from "./1_document.js";
|
|
17
|
+
import { constructReplyQuote } from "./1_reply_quote.js";
|
|
18
18
|
import { constructPhoto } from "./1_photo.js";
|
|
19
19
|
import { constructPoll } from "./1_poll.js";
|
|
20
20
|
import { constructSticker } from "./1_sticker.js";
|
|
21
21
|
import { constructUser } from "./1_user.js";
|
|
22
22
|
import { constructVideoNote } from "./1_video_note.js";
|
|
23
23
|
import { constructVideo } from "./1_video.js";
|
|
24
|
+
import { constructMessageReaction } from "./1_message_reaction.js";
|
|
25
|
+
import { constructGiveaway } from "./1_giveaway.js";
|
|
24
26
|
import { constructGame } from "./2_game.js";
|
|
25
27
|
import { constructReplyKeyboardMarkup } from "./2_reply_keyboard_markup.js";
|
|
26
28
|
import { constructInlineKeyboardMarkup } from "./3_inline_keyboard_markup.js";
|
|
27
29
|
const d = debug("types/Message");
|
|
30
|
+
const keys = {
|
|
31
|
+
text: ["text"],
|
|
32
|
+
photo: ["photo"],
|
|
33
|
+
document: ["document"],
|
|
34
|
+
video: ["video"],
|
|
35
|
+
sticker: ["sticker"],
|
|
36
|
+
animation: ["animation"],
|
|
37
|
+
voice: ["voice"],
|
|
38
|
+
audio: ["audio"],
|
|
39
|
+
dice: ["dice"],
|
|
40
|
+
videoNote: ["videoNote"],
|
|
41
|
+
contact: ["contact"],
|
|
42
|
+
game: ["game"],
|
|
43
|
+
poll: ["poll"],
|
|
44
|
+
venue: ["venue"],
|
|
45
|
+
location: ["location"],
|
|
46
|
+
newChatMembers: ["newChatMembers"],
|
|
47
|
+
leftChatMember: ["leftChatMember"],
|
|
48
|
+
newChatTitle: ["newChatTitle"],
|
|
49
|
+
newChatPhoto: ["newChatPhoto"],
|
|
50
|
+
deletedChatPhoto: ["deletedChatPhoto"],
|
|
51
|
+
groupCreated: ["groupCreated", "newChatMembers"],
|
|
52
|
+
supergroupCreated: ["supergroupCreated"],
|
|
53
|
+
channelCreated: ["channelCreated"],
|
|
54
|
+
newAutoDeleteTime: ["newAutoDeleteTime"],
|
|
55
|
+
chatMigratedTo: ["chatMigratedTo"],
|
|
56
|
+
chatMigratedFrom: ["chatMigratedFrom"],
|
|
57
|
+
pinnedMessage: ["pinnedMessage"],
|
|
58
|
+
userShared: ["userShared"],
|
|
59
|
+
writeAccessAllowed: ["writeAccessAllowed"],
|
|
60
|
+
forumTopicCreated: ["forumTopicCreated"],
|
|
61
|
+
forumTopicEdited: ["forumTopicEdited"],
|
|
62
|
+
forumTopicClosed: ["forumTopicClosed"],
|
|
63
|
+
forumTopicReopened: ["forumTopicReopened"],
|
|
64
|
+
videoChatScheduled: ["videoChatScheduled"],
|
|
65
|
+
videoChatStarted: ["videoChatStarted"],
|
|
66
|
+
videoChatEnded: ["videoChatEnded"],
|
|
67
|
+
giveaway: ["giveaway"],
|
|
68
|
+
};
|
|
69
|
+
export function assertMessageType(message, type) {
|
|
70
|
+
for (const key of keys[type]) {
|
|
71
|
+
if (!(key in message) || message[key] === undefined) {
|
|
72
|
+
UNREACHABLE();
|
|
73
|
+
}
|
|
74
|
+
}
|
|
75
|
+
return message;
|
|
76
|
+
}
|
|
28
77
|
async function getSender(message_, getEntity) {
|
|
29
78
|
if (message_.from_id instanceof types.PeerUser) {
|
|
30
79
|
const entity = await getEntity(message_.from_id);
|
|
@@ -71,116 +120,142 @@ async function constructServiceMessage(message_, chat, getEntity, getMessage) {
|
|
|
71
120
|
};
|
|
72
121
|
Object.assign(message, await getSender(message_, getEntity));
|
|
73
122
|
if (message_.action instanceof types.MessageActionChatAddUser) {
|
|
74
|
-
|
|
123
|
+
const newChatMembers = new Array();
|
|
75
124
|
for (const user_ of message_.action.users) {
|
|
76
125
|
const entity = await getEntity(new types.PeerUser({ user_id: user_ }));
|
|
77
126
|
if (entity) {
|
|
78
127
|
const user = constructUser(entity);
|
|
79
|
-
|
|
128
|
+
newChatMembers.push(user);
|
|
80
129
|
}
|
|
81
130
|
else {
|
|
82
131
|
UNREACHABLE();
|
|
83
132
|
}
|
|
84
133
|
}
|
|
134
|
+
return { ...message, newChatMembers };
|
|
85
135
|
}
|
|
86
136
|
else if (message_.action instanceof types.MessageActionChatDeleteUser) {
|
|
87
137
|
const entity = await getEntity(new types.PeerUser({ user_id: message_.action.user_id }));
|
|
88
138
|
if (entity) {
|
|
89
139
|
const user = constructUser(entity);
|
|
90
|
-
|
|
140
|
+
const leftChatMember = user;
|
|
141
|
+
return { ...message, leftChatMember };
|
|
91
142
|
}
|
|
92
143
|
else {
|
|
93
144
|
UNREACHABLE();
|
|
94
145
|
}
|
|
95
146
|
}
|
|
96
147
|
else if (message_.action instanceof types.MessageActionChatEditTitle) {
|
|
97
|
-
|
|
148
|
+
const newChatTitle = message_.action.title;
|
|
149
|
+
return { ...message, newChatTitle };
|
|
98
150
|
}
|
|
99
151
|
else if (message_.action instanceof types.MessageActionChatEditPhoto) {
|
|
100
|
-
|
|
152
|
+
const newChatPhoto = constructPhoto(message_.action.photo[as](types.Photo));
|
|
153
|
+
return { ...message, newChatPhoto };
|
|
101
154
|
}
|
|
102
155
|
else if (message_.action instanceof types.MessageActionChatDeletePhoto) {
|
|
103
|
-
|
|
156
|
+
const deletedChatPhoto = true;
|
|
157
|
+
return { ...message, deletedChatPhoto };
|
|
104
158
|
}
|
|
105
159
|
else if (message_.action instanceof types.MessageActionChatCreate) {
|
|
106
|
-
|
|
107
|
-
|
|
160
|
+
const groupCreated = true;
|
|
161
|
+
const newChatMembers = new Array();
|
|
108
162
|
for (const user_ of message_.action.users) {
|
|
109
163
|
const entity = await getEntity(new types.PeerUser({ user_id: user_ }));
|
|
110
164
|
if (entity) {
|
|
111
165
|
const user = constructUser(entity);
|
|
112
|
-
|
|
166
|
+
newChatMembers.push(user);
|
|
113
167
|
}
|
|
114
168
|
else {
|
|
115
169
|
UNREACHABLE();
|
|
116
170
|
}
|
|
117
171
|
}
|
|
172
|
+
return { ...message, groupCreated, newChatMembers };
|
|
118
173
|
}
|
|
119
174
|
else if (message_.action instanceof types.MessageActionChannelCreate) {
|
|
120
175
|
if (message.chat.type == "channel") {
|
|
121
|
-
|
|
176
|
+
const channelCreated = true;
|
|
177
|
+
return { ...message, channelCreated };
|
|
122
178
|
}
|
|
123
179
|
else if (message.chat.type == "supergroup") {
|
|
124
|
-
|
|
180
|
+
const supergroupCreated = true;
|
|
181
|
+
return { ...message, supergroupCreated };
|
|
125
182
|
}
|
|
126
183
|
else {
|
|
127
184
|
UNREACHABLE();
|
|
128
185
|
}
|
|
129
186
|
}
|
|
130
187
|
else if (message_.action instanceof types.MessageActionChatMigrateTo) {
|
|
131
|
-
|
|
188
|
+
const chatMigratedTo = ZERO_CHANNEL_ID + Number(-message_.action.channel_id);
|
|
189
|
+
return { ...message, chatMigratedTo };
|
|
132
190
|
}
|
|
133
191
|
else if (message_.action instanceof types.MessageActionChannelMigrateFrom) {
|
|
134
|
-
|
|
192
|
+
const chatMigratedFrom = Number(-message_.action.chat_id);
|
|
193
|
+
return { ...message, chatMigratedFrom };
|
|
135
194
|
}
|
|
136
195
|
else if (message_.action instanceof types.MessageActionPinMessage) {
|
|
137
196
|
const { replyToMessage } = await getReply(message_, chat, getMessage);
|
|
138
|
-
|
|
197
|
+
if (!replyToMessage) {
|
|
198
|
+
UNREACHABLE();
|
|
199
|
+
}
|
|
200
|
+
const pinnedMessage = replyToMessage;
|
|
201
|
+
return { ...message, pinnedMessage };
|
|
139
202
|
}
|
|
140
203
|
else if (message_.action instanceof types.MessageActionRequestedPeer) {
|
|
141
|
-
const user = message_.action.
|
|
142
|
-
|
|
204
|
+
const user = message_.action.peers[0][as](types.PeerUser);
|
|
205
|
+
const userShared = { requestId: message_.action.button_id, userId: Number(user.user_id) };
|
|
206
|
+
return { ...message, userShared };
|
|
143
207
|
}
|
|
144
208
|
else if (message_.action instanceof types.MessageActionBotAllowed) {
|
|
145
209
|
const webAppName = message_.action.app ? message_.action.app[as](types.BotApp).title : undefined;
|
|
146
|
-
|
|
210
|
+
const writeAccessAllowed = { webAppName };
|
|
211
|
+
return { ...message, writeAccessAllowed };
|
|
147
212
|
}
|
|
148
213
|
else if (message_.action instanceof types.MessageActionTopicCreate) {
|
|
149
|
-
|
|
214
|
+
const forumTopicCreated = {
|
|
150
215
|
name: message_.action.title,
|
|
151
216
|
iconColor: "#" + message_.action.icon_color.toString(16).padStart(6, "0"),
|
|
152
217
|
iconCutsomEmojiId: message_.action.icon_emoji_id ? String(message_.action.icon_emoji_id) : undefined,
|
|
153
218
|
};
|
|
219
|
+
return { ...message, forumTopicCreated };
|
|
154
220
|
}
|
|
155
221
|
else if (message_.action instanceof types.MessageActionTopicEdit) {
|
|
156
222
|
if (message_.action.closed) {
|
|
157
|
-
|
|
223
|
+
const forumTopicClosed = true;
|
|
224
|
+
return { ...message, forumTopicClosed };
|
|
158
225
|
}
|
|
159
226
|
else if (message_.action.title || message_.action.icon_emoji_id) {
|
|
160
|
-
|
|
161
|
-
name: message_.action.title,
|
|
227
|
+
const forumTopicEdited = {
|
|
228
|
+
name: message_.action.title ?? "",
|
|
162
229
|
iconCutsomEmojiId: message_.action.icon_emoji_id ? String(message_.action.icon_emoji_id) : undefined,
|
|
163
230
|
};
|
|
231
|
+
return { ...message, forumTopicEdited };
|
|
164
232
|
}
|
|
165
233
|
else {
|
|
166
|
-
|
|
234
|
+
const forumTopicReopened = true;
|
|
235
|
+
return { ...message, forumTopicReopened };
|
|
167
236
|
}
|
|
168
237
|
}
|
|
169
238
|
else if (message_.action instanceof types.MessageActionGroupCallScheduled) {
|
|
170
|
-
|
|
239
|
+
const videoChatScheduled = { startDate: new Date(message_.action.schedule_date * 1000) };
|
|
240
|
+
return { ...message, videoChatScheduled };
|
|
171
241
|
}
|
|
172
242
|
else if (message_.action instanceof types.MessageActionGroupCall) {
|
|
173
243
|
if (message_.action.duration) {
|
|
174
|
-
|
|
244
|
+
const videoChatEnded = { duration: message_.action.duration };
|
|
245
|
+
return { ...message, videoChatEnded };
|
|
175
246
|
}
|
|
176
247
|
else {
|
|
177
|
-
|
|
248
|
+
const videoChatStarted = true;
|
|
249
|
+
return { ...message, videoChatStarted };
|
|
178
250
|
}
|
|
179
251
|
}
|
|
180
252
|
else if (message_.action instanceof types.MessageActionSetMessagesTTL) {
|
|
181
|
-
|
|
253
|
+
const newAutoDeleteTime = message_.action.period || 0;
|
|
254
|
+
return { ...message, newAutoDeleteTime };
|
|
255
|
+
}
|
|
256
|
+
else {
|
|
257
|
+
UNREACHABLE();
|
|
182
258
|
}
|
|
183
|
-
return cleanObject(message);
|
|
184
259
|
}
|
|
185
260
|
export async function constructMessage(message_, getEntity, getMessage, getStickerSetName, getReply_ = true) {
|
|
186
261
|
if (!(message_ instanceof types.Message) && !(message_ instanceof types.MessageService)) {
|
|
@@ -232,6 +307,10 @@ export async function constructMessage(message_, getEntity, getMessage, getStick
|
|
|
232
307
|
isTopicMessage: false,
|
|
233
308
|
hasProtectedContent: message_.noforwards || false,
|
|
234
309
|
};
|
|
310
|
+
if (message_.reactions) {
|
|
311
|
+
const recentReactions = message_.reactions.recent_reactions ?? [];
|
|
312
|
+
message.reactions = message_.reactions.results.map((v) => constructMessageReaction(v, recentReactions));
|
|
313
|
+
}
|
|
235
314
|
if (message_.reply_to instanceof types.MessageReplyHeader && message_.reply_to.reply_to_msg_id) {
|
|
236
315
|
if (message_.reply_to.quote) {
|
|
237
316
|
message.replyQuote = constructReplyQuote(message_.reply_to.quote_text, message_.reply_to.quote_offset, message_.reply_to.quote_entities);
|
|
@@ -242,31 +321,6 @@ export async function constructMessage(message_, getEntity, getMessage, getStick
|
|
|
242
321
|
Object.assign(message, await getReply(message_, chat_, getMessage));
|
|
243
322
|
}
|
|
244
323
|
Object.assign(message, await getSender(message_, getEntity));
|
|
245
|
-
if (message_.media instanceof types.MessageMediaPhoto || message_.media instanceof types.MessageMediaDocument) {
|
|
246
|
-
message.hasMediaSpoiler = message_.media.spoiler || false;
|
|
247
|
-
}
|
|
248
|
-
if (message_.grouped_id != undefined) {
|
|
249
|
-
message.mediaGroupId = String(message_.grouped_id);
|
|
250
|
-
}
|
|
251
|
-
if (message_.message) {
|
|
252
|
-
if (message_.media == undefined) {
|
|
253
|
-
message.text = message_.message;
|
|
254
|
-
}
|
|
255
|
-
else {
|
|
256
|
-
message.caption = message_.message;
|
|
257
|
-
}
|
|
258
|
-
}
|
|
259
|
-
if (message_.entities != undefined) {
|
|
260
|
-
if (message_.media == undefined) {
|
|
261
|
-
message.entities = message_.entities.map(constructMessageEntity).filter((v) => v);
|
|
262
|
-
}
|
|
263
|
-
else {
|
|
264
|
-
message.captionEntities = message_.entities.map(constructMessageEntity).filter((v) => v);
|
|
265
|
-
}
|
|
266
|
-
}
|
|
267
|
-
if (message_.edit_date != undefined) {
|
|
268
|
-
message.editDate = new Date(message_.edit_date * 1000);
|
|
269
|
-
}
|
|
270
324
|
if (message_.reply_markup) {
|
|
271
325
|
if (message_.reply_markup instanceof types.ReplyKeyboardMarkup) {
|
|
272
326
|
message.replyMarkup = constructReplyKeyboardMarkup(message_.reply_markup);
|
|
@@ -321,81 +375,124 @@ export async function constructMessage(message_, getEntity, getMessage, getStick
|
|
|
321
375
|
}
|
|
322
376
|
}
|
|
323
377
|
}
|
|
324
|
-
if (message_.
|
|
325
|
-
|
|
326
|
-
|
|
327
|
-
|
|
328
|
-
|
|
378
|
+
if (message_.grouped_id != undefined) {
|
|
379
|
+
message.mediaGroupId = String(message_.grouped_id);
|
|
380
|
+
}
|
|
381
|
+
if (message_.edit_date != undefined) {
|
|
382
|
+
message.editDate = new Date(message_.edit_date * 1000);
|
|
383
|
+
}
|
|
384
|
+
if (message_.message && message_.media === undefined) {
|
|
385
|
+
return {
|
|
386
|
+
...message,
|
|
387
|
+
text: message_.message,
|
|
388
|
+
entities: message_.entities?.map(constructMessageEntity).filter((v) => !!v) ?? [],
|
|
389
|
+
};
|
|
390
|
+
}
|
|
391
|
+
const messageMedia = {
|
|
392
|
+
...message,
|
|
393
|
+
caption: message_.message,
|
|
394
|
+
captionEntities: message_.entities?.map(constructMessageEntity).filter((v) => !!v) ?? [],
|
|
395
|
+
};
|
|
396
|
+
if (message_.media instanceof types.MessageMediaPhoto || message_.media instanceof types.MessageMediaDocument) {
|
|
397
|
+
messageMedia.hasMediaSpoiler = message_.media.spoiler || false;
|
|
398
|
+
}
|
|
399
|
+
let m = null;
|
|
400
|
+
if (message_.media instanceof types.MessageMediaPhoto) {
|
|
401
|
+
if (!message_.media.photo) {
|
|
402
|
+
UNREACHABLE();
|
|
329
403
|
}
|
|
330
|
-
|
|
331
|
-
|
|
332
|
-
|
|
333
|
-
|
|
334
|
-
|
|
335
|
-
|
|
336
|
-
|
|
337
|
-
|
|
338
|
-
|
|
339
|
-
|
|
340
|
-
|
|
341
|
-
|
|
342
|
-
|
|
343
|
-
|
|
344
|
-
|
|
345
|
-
|
|
346
|
-
|
|
347
|
-
|
|
348
|
-
|
|
349
|
-
|
|
350
|
-
|
|
351
|
-
|
|
352
|
-
|
|
353
|
-
|
|
354
|
-
|
|
355
|
-
|
|
356
|
-
|
|
357
|
-
|
|
358
|
-
|
|
359
|
-
if (audio.voice) {
|
|
360
|
-
message.voice = constructVoice(document, audio, getFileId(FileType.Voice), fileUniqueId);
|
|
361
|
-
}
|
|
362
|
-
else {
|
|
363
|
-
message.audio = constructAudio(document, audio, getFileId(FileType.Audio), fileUniqueId);
|
|
364
|
-
}
|
|
404
|
+
const photo = constructPhoto(message_.media.photo[as](types.Photo));
|
|
405
|
+
m = { ...messageMedia, photo };
|
|
406
|
+
}
|
|
407
|
+
else if (message_.media instanceof types.MessageMediaDice) {
|
|
408
|
+
const dice = constructDice(message_.media);
|
|
409
|
+
m = { ...message, dice };
|
|
410
|
+
}
|
|
411
|
+
else if (message_.media instanceof types.MessageMediaDocument) {
|
|
412
|
+
const { document } = message_.media;
|
|
413
|
+
if (document instanceof types.Document) {
|
|
414
|
+
const getFileId = (type) => new FileID(null, null, type, document.dc_id, {
|
|
415
|
+
mediaId: document.id,
|
|
416
|
+
accessHash: document.access_hash,
|
|
417
|
+
fileReference: document.file_reference,
|
|
418
|
+
}).encode();
|
|
419
|
+
const fileUniqueId = new FileUniqueID(FileUniqueType.Document, { mediaId: document.id }).encode();
|
|
420
|
+
const animated = document.attributes.find((v) => v instanceof types.DocumentAttributeAnimated);
|
|
421
|
+
const audio = document.attributes.find((v) => v instanceof types.DocumentAttributeAudio);
|
|
422
|
+
const fileName = document.attributes.find((v) => v instanceof types.DocumentAttributeFilename);
|
|
423
|
+
const sticker = document.attributes.find((v) => v instanceof types.DocumentAttributeSticker);
|
|
424
|
+
const video = document.attributes.find((v) => v instanceof types.DocumentAttributeVideo);
|
|
425
|
+
if (animated) {
|
|
426
|
+
const animation = constructAnimation(document, video, fileName, getFileId(FileType.Animation), fileUniqueId);
|
|
427
|
+
m = { ...messageMedia, animation };
|
|
428
|
+
}
|
|
429
|
+
else if (video) {
|
|
430
|
+
if (video.round_message) {
|
|
431
|
+
const videoNote = constructVideoNote(document, video, getFileId(FileType.VideoNote), fileUniqueId);
|
|
432
|
+
m = { ...message, videoNote };
|
|
365
433
|
}
|
|
366
|
-
else
|
|
367
|
-
|
|
434
|
+
else {
|
|
435
|
+
const video_ = constructVideo(document, video, fileName?.file_name, getFileId(FileType.Video), fileUniqueId);
|
|
436
|
+
m = { ...messageMedia, video: video_ };
|
|
368
437
|
}
|
|
369
|
-
|
|
370
|
-
|
|
438
|
+
}
|
|
439
|
+
else if (audio) {
|
|
440
|
+
if (audio.voice) {
|
|
441
|
+
const voice = constructVoice(document, audio, getFileId(FileType.Voice), fileUniqueId);
|
|
442
|
+
m = { ...messageMedia, voice };
|
|
371
443
|
}
|
|
372
444
|
else {
|
|
373
|
-
|
|
445
|
+
const audio_ = constructAudio(document, audio, getFileId(FileType.Audio), fileUniqueId);
|
|
446
|
+
m = { ...messageMedia, audio: audio_ };
|
|
374
447
|
}
|
|
375
448
|
}
|
|
449
|
+
else if (sticker) {
|
|
450
|
+
const sticker = await constructSticker(document, getFileId(FileType.Sticker), fileUniqueId, getStickerSetName);
|
|
451
|
+
m = { ...message, sticker };
|
|
452
|
+
}
|
|
453
|
+
else if (fileName) {
|
|
454
|
+
const document_ = constructDocument(document, fileName, getFileId(FileType.Document), fileUniqueId);
|
|
455
|
+
m = { ...messageMedia, document: document_ };
|
|
456
|
+
}
|
|
457
|
+
else {
|
|
458
|
+
const document_ = constructDocument(document, new types.DocumentAttributeFilename({ file_name: "Unknown" }), getFileId(FileType.Document), fileUniqueId);
|
|
459
|
+
m = { ...messageMedia, document: document_ };
|
|
460
|
+
}
|
|
376
461
|
}
|
|
377
|
-
else if (message_.media instanceof types.MessageMediaContact) {
|
|
378
|
-
message.contact = constructContact(message_.media);
|
|
379
|
-
}
|
|
380
|
-
else if (message_.media instanceof types.MessageMediaGame) {
|
|
381
|
-
message.game = constructGame(message_.media);
|
|
382
|
-
}
|
|
383
|
-
else if (message_.media instanceof types.MessageMediaPoll) {
|
|
384
|
-
message.poll = constructPoll(message_.media);
|
|
385
|
-
}
|
|
386
|
-
else if (message_.media instanceof types.MessageMediaVenue) {
|
|
387
|
-
message.venue = constructVenue(message_.media);
|
|
388
|
-
}
|
|
389
|
-
else if (message_.media instanceof types.MessageMediaGeo || message_.media instanceof types.MessageMediaGeoLive) {
|
|
390
|
-
message.location = constructLocation(message_.media);
|
|
391
|
-
}
|
|
392
|
-
else if (message_.media instanceof types.MessageMediaWebPage) {
|
|
393
|
-
//
|
|
394
|
-
}
|
|
395
|
-
else {
|
|
396
|
-
// not implemented
|
|
397
|
-
UNREACHABLE();
|
|
398
|
-
}
|
|
399
462
|
}
|
|
400
|
-
|
|
463
|
+
else if (message_.media instanceof types.MessageMediaContact) {
|
|
464
|
+
const contact = constructContact(message_.media);
|
|
465
|
+
m = { ...messageMedia, contact };
|
|
466
|
+
}
|
|
467
|
+
else if (message_.media instanceof types.MessageMediaGame) {
|
|
468
|
+
const game = constructGame(message_.media);
|
|
469
|
+
m = { ...message, game };
|
|
470
|
+
}
|
|
471
|
+
else if (message_.media instanceof types.MessageMediaPoll) {
|
|
472
|
+
const poll = constructPoll(message_.media);
|
|
473
|
+
m = { ...message, poll };
|
|
474
|
+
}
|
|
475
|
+
else if (message_.media instanceof types.MessageMediaVenue) {
|
|
476
|
+
const venue = constructVenue(message_.media);
|
|
477
|
+
m = { ...message, venue };
|
|
478
|
+
}
|
|
479
|
+
else if (message_.media instanceof types.MessageMediaGeo || message_.media instanceof types.MessageMediaGeoLive) {
|
|
480
|
+
const location = constructLocation(message_.media);
|
|
481
|
+
m = { ...message, location };
|
|
482
|
+
}
|
|
483
|
+
else if (message_.media instanceof types.MessageMediaWebPage) {
|
|
484
|
+
UNREACHABLE(); // TODO: implement
|
|
485
|
+
}
|
|
486
|
+
else if (message_.media instanceof types.MessageMediaGiveaway) {
|
|
487
|
+
const giveaway = constructGiveaway(message_.media);
|
|
488
|
+
m = { ...message, giveaway };
|
|
489
|
+
}
|
|
490
|
+
else {
|
|
491
|
+
// not implemented
|
|
492
|
+
UNREACHABLE();
|
|
493
|
+
}
|
|
494
|
+
if (m == null) {
|
|
495
|
+
UNREACHABLE();
|
|
496
|
+
}
|
|
497
|
+
return cleanObject(m);
|
|
401
498
|
}
|
package/esm/types/4_chat.d.ts
CHANGED
|
@@ -1,34 +1,37 @@
|
|
|
1
1
|
import { enums, types } from "../2_tl.js";
|
|
2
|
-
import {
|
|
3
|
-
import {
|
|
2
|
+
import { ChatPChannel, ChatPGroup, ChatPPrivate, ChatPSupergroup } from "./1_chat_p.js";
|
|
3
|
+
import { ChatPhotoChat, ChatPhotoUser } from "./0_chat_photo.js";
|
|
4
4
|
import { Message, MessageGetter } from "./3_message.js";
|
|
5
5
|
import { StickerSetNameGetter } from "./1_sticker.js";
|
|
6
6
|
import { EntityGetter } from "./1__getters.js";
|
|
7
|
-
|
|
8
|
-
|
|
9
|
-
|
|
10
|
-
|
|
11
|
-
|
|
12
|
-
}
|
|
13
|
-
interface Channel extends Base, ChatP.Channel {
|
|
14
|
-
also?: string[];
|
|
15
|
-
photo?: ChatPhoto.Chat;
|
|
16
|
-
}
|
|
17
|
-
interface Supergroup extends Base, ChatP.Supergroup {
|
|
18
|
-
also?: string[];
|
|
19
|
-
photo?: ChatPhoto.Chat;
|
|
20
|
-
}
|
|
21
|
-
interface Group extends Base, ChatP.Group {
|
|
22
|
-
photo?: ChatPhoto.Chat;
|
|
23
|
-
}
|
|
24
|
-
interface Private extends Base, ChatP.Private {
|
|
25
|
-
also?: string[];
|
|
26
|
-
photo?: ChatPhoto.User;
|
|
27
|
-
}
|
|
7
|
+
/** @unlisted */
|
|
8
|
+
export interface ChatBase {
|
|
9
|
+
order: string;
|
|
10
|
+
lastMessage?: Omit<Message, "replyToMessage">;
|
|
11
|
+
pinned: number;
|
|
28
12
|
}
|
|
29
|
-
|
|
30
|
-
export
|
|
31
|
-
|
|
32
|
-
|
|
33
|
-
|
|
34
|
-
|
|
13
|
+
/** @unlisted */
|
|
14
|
+
export interface ChatChannel extends ChatBase, ChatPChannel {
|
|
15
|
+
also?: string[];
|
|
16
|
+
photo?: ChatPhotoChat;
|
|
17
|
+
}
|
|
18
|
+
/** @unlisted */
|
|
19
|
+
export interface ChatSupergroup extends ChatBase, ChatPSupergroup {
|
|
20
|
+
also?: string[];
|
|
21
|
+
photo?: ChatPhotoChat;
|
|
22
|
+
}
|
|
23
|
+
/** @unlisted */
|
|
24
|
+
export interface ChatGroup extends ChatBase, ChatPGroup {
|
|
25
|
+
photo?: ChatPhotoChat;
|
|
26
|
+
}
|
|
27
|
+
/** @unlisted */
|
|
28
|
+
export interface ChatPrivate extends ChatBase, ChatPPrivate {
|
|
29
|
+
also?: string[];
|
|
30
|
+
photo?: ChatPhotoUser;
|
|
31
|
+
}
|
|
32
|
+
export type Chat = ChatChannel | ChatSupergroup | ChatGroup | ChatPrivate;
|
|
33
|
+
export declare function getChatOrder(lastMessage: Omit<Message, "replyToMessage"> | undefined, pinned: number): string;
|
|
34
|
+
export declare function constructChat(dialog: enums.Dialog, dialogs: types.messages.Dialogs | types.messages.DialogsSlice, pinnedChats: number[], getEntity: EntityGetter, getMessage: MessageGetter, getStickerSetName: StickerSetNameGetter): Promise<Chat>;
|
|
35
|
+
export declare function constructChat2(entity: types.User | types.Chat | types.ChatForbidden | types.Channel | types.ChannelForbidden, pinned: number, lastMessage: Omit<Message, "replyToMessage"> | undefined): Chat;
|
|
36
|
+
export declare function constructChat3(chatId: number, pinned: number, lastMessage: Omit<Message, "replyToMessage"> | undefined, getEntity: EntityGetter): Promise<Chat | null>;
|
|
37
|
+
export declare function constructChat4(chatId: number, pinned: number, lastMessageId: number, getEntity: EntityGetter, getMessage: MessageGetter): Promise<Chat | null>;
|
package/package.json
CHANGED
package/script/3_types.d.ts
CHANGED
|
@@ -8,6 +8,7 @@ export * from "./types/0_contact.js";
|
|
|
8
8
|
export * from "./types/0_dice.js";
|
|
9
9
|
export * from "./types/0__file_id.js";
|
|
10
10
|
export * from "./types/0_force_reply.js";
|
|
11
|
+
export * from "./types/0_giveaway_parameters.js";
|
|
11
12
|
export * from "./types/0_input_contact_message_content.js";
|
|
12
13
|
export * from "./types/0_input_location_message_content.js";
|
|
13
14
|
export * from "./types/0_input_venue_message_content.js";
|
|
@@ -30,11 +31,13 @@ export * from "./types/1_animation.js";
|
|
|
30
31
|
export * from "./types/1_bot_command_scope.js";
|
|
31
32
|
export * from "./types/1_chat_p.js";
|
|
32
33
|
export * from "./types/1_document.js";
|
|
34
|
+
export * from "./types/1_giveaway.js";
|
|
33
35
|
export * from "./types/1__getters.js";
|
|
34
36
|
export * from "./types/1_inline_query_result_button.js";
|
|
35
37
|
export * from "./types/1_input_invoice_message_content.js";
|
|
36
38
|
export * from "./types/1_input_text_message_content.js";
|
|
37
39
|
export * from "./types/1_keyboard_button.js";
|
|
40
|
+
export * from "./types/1_message_reaction.js";
|
|
38
41
|
export * from "./types/1_photo.js";
|
|
39
42
|
export * from "./types/1_poll.js";
|
|
40
43
|
export * from "./types/1_reply_quote.js";
|
package/script/3_types.js
CHANGED
|
@@ -24,6 +24,7 @@ __exportStar(require("./types/0_contact.js"), exports);
|
|
|
24
24
|
__exportStar(require("./types/0_dice.js"), exports);
|
|
25
25
|
__exportStar(require("./types/0__file_id.js"), exports);
|
|
26
26
|
__exportStar(require("./types/0_force_reply.js"), exports);
|
|
27
|
+
__exportStar(require("./types/0_giveaway_parameters.js"), exports);
|
|
27
28
|
__exportStar(require("./types/0_input_contact_message_content.js"), exports);
|
|
28
29
|
__exportStar(require("./types/0_input_location_message_content.js"), exports);
|
|
29
30
|
__exportStar(require("./types/0_input_venue_message_content.js"), exports);
|
|
@@ -46,11 +47,13 @@ __exportStar(require("./types/1_animation.js"), exports);
|
|
|
46
47
|
__exportStar(require("./types/1_bot_command_scope.js"), exports);
|
|
47
48
|
__exportStar(require("./types/1_chat_p.js"), exports);
|
|
48
49
|
__exportStar(require("./types/1_document.js"), exports);
|
|
50
|
+
__exportStar(require("./types/1_giveaway.js"), exports);
|
|
49
51
|
__exportStar(require("./types/1__getters.js"), exports);
|
|
50
52
|
__exportStar(require("./types/1_inline_query_result_button.js"), exports);
|
|
51
53
|
__exportStar(require("./types/1_input_invoice_message_content.js"), exports);
|
|
52
54
|
__exportStar(require("./types/1_input_text_message_content.js"), exports);
|
|
53
55
|
__exportStar(require("./types/1_keyboard_button.js"), exports);
|
|
56
|
+
__exportStar(require("./types/1_message_reaction.js"), exports);
|
|
54
57
|
__exportStar(require("./types/1_photo.js"), exports);
|
|
55
58
|
__exportStar(require("./types/1_poll.js"), exports);
|
|
56
59
|
__exportStar(require("./types/1_reply_quote.js"), exports);
|
package/script/4_constants.d.ts
CHANGED
|
@@ -3,8 +3,8 @@ export declare const ACK_THRESHOLD = 10;
|
|
|
3
3
|
export type PublicKeys = readonly [bigint, [bigint, bigint]][];
|
|
4
4
|
export declare const PUBLIC_KEYS: PublicKeys;
|
|
5
5
|
export declare const INITIAL_DC: DC;
|
|
6
|
-
export declare const LAYER =
|
|
7
|
-
export declare const APP_VERSION = "MTKruto 0.1.
|
|
6
|
+
export declare const LAYER = 169;
|
|
7
|
+
export declare const APP_VERSION = "MTKruto 0.1.133";
|
|
8
8
|
export declare const DEVICE_MODEL: string;
|
|
9
9
|
export declare const LANG_CODE: string;
|
|
10
10
|
export declare const LANG_PACK = "";
|
package/script/4_constants.js
CHANGED
|
@@ -78,8 +78,8 @@ exports.PUBLIC_KEYS = Object.freeze([
|
|
|
78
78
|
],
|
|
79
79
|
]);
|
|
80
80
|
exports.INITIAL_DC = "2";
|
|
81
|
-
exports.LAYER =
|
|
82
|
-
exports.APP_VERSION = "MTKruto 0.1.
|
|
81
|
+
exports.LAYER = 169;
|
|
82
|
+
exports.APP_VERSION = "MTKruto 0.1.133";
|
|
83
83
|
// @ts-ignore: lib
|
|
84
84
|
exports.DEVICE_MODEL = typeof dntShim.Deno === "undefined" ? typeof navigator === "undefined" ? typeof process === "undefined" ? "Unknown" : process.platform + "-" + process.arch : navigator.userAgent.split(" ")[0] : dntShim.Deno.build.os + "-" + dntShim.Deno.build.arch;
|
|
85
85
|
exports.LANG_CODE = typeof navigator === "undefined" ? "en" : navigator.language.split("-")[0];
|
|
@@ -1,8 +1,8 @@
|
|
|
1
1
|
import { enums, types } from "../2_tl.js";
|
|
2
2
|
export declare const resolve: () => Promise<void>;
|
|
3
3
|
export type With<T, K extends keyof T> = T & Required<Pick<T, K>>;
|
|
4
|
-
export declare function isPtsUpdate(v: enums.Update
|
|
5
|
-
export declare function isChannelPtsUpdate(v: enums.Update | enums.Updates): v is types.UpdateNewChannelMessage | types.UpdateEditChannelMessage | types.UpdateDeleteChannelMessages;
|
|
4
|
+
export declare function isPtsUpdate(v: enums.Update): v is types.UpdateNewMessage | types.UpdateDeleteMessages | types.UpdateReadHistoryInbox | types.UpdateReadHistoryOutbox | types.UpdatePinnedChannelMessages | types.UpdatePinnedMessages | types.UpdateFolderPeers | types.UpdateChannelWebPage | types.UpdateEditMessage | types.UpdateReadMessagesContents | types.UpdateWebPage;
|
|
5
|
+
export declare function isChannelPtsUpdate(v: enums.Update | enums.Updates): v is types.UpdateNewChannelMessage | types.UpdateEditChannelMessage | types.UpdateDeleteChannelMessages | types.UpdateChannelTooLong;
|
|
6
6
|
/**
|
|
7
7
|
* Source to a file. Can be a file ID, a file path, URL, or a `Uint8Array`, unless otherwise noted.
|
|
8
8
|
*/
|