@mtcute/core 0.29.6 → 0.30.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/client.cjs +8 -0
- package/client.js +8 -0
- package/highlevel/client.d.cts +23 -7
- package/highlevel/client.d.ts +23 -7
- package/highlevel/methods/bots/answer-bot-guest-chat-query.cjs +26 -0
- package/highlevel/methods/bots/answer-bot-guest-chat-query.d.cts +12 -0
- package/highlevel/methods/bots/answer-bot-guest-chat-query.d.ts +12 -0
- package/highlevel/methods/bots/answer-bot-guest-chat-query.js +21 -0
- package/highlevel/methods/chats/join-chat.cjs +38 -16
- package/highlevel/methods/chats/join-chat.d.cts +20 -6
- package/highlevel/methods/chats/join-chat.d.ts +20 -6
- package/highlevel/methods/chats/join-chat.js +38 -16
- package/highlevel/methods/chats/save-draft.d.cts +4 -1
- package/highlevel/methods/chats/save-draft.d.ts +4 -1
- package/highlevel/methods/messages/send-copy-group.cjs +5 -9
- package/highlevel/methods/messages/send-copy-group.js +5 -9
- package/highlevel/methods.d.cts +3 -0
- package/highlevel/methods.d.ts +3 -0
- package/highlevel/storage/service/peers.cjs +2 -0
- package/highlevel/storage/service/peers.js +2 -0
- package/highlevel/types/files/utils.d.cts +1 -1
- package/highlevel/types/files/utils.d.ts +1 -1
- package/highlevel/types/media/poll.cjs +14 -0
- package/highlevel/types/media/poll.d.cts +6 -0
- package/highlevel/types/media/poll.d.ts +6 -0
- package/highlevel/types/media/poll.js +14 -0
- package/highlevel/types/messages/index.d.cts +1 -0
- package/highlevel/types/messages/index.d.ts +1 -0
- package/highlevel/types/messages/message.cjs +15 -1
- package/highlevel/types/messages/message.d.cts +8 -0
- package/highlevel/types/messages/message.d.ts +8 -0
- package/highlevel/types/messages/message.js +15 -1
- package/highlevel/types/messages/rich-message.cjs +50 -0
- package/highlevel/types/messages/rich-message.d.cts +18 -0
- package/highlevel/types/messages/rich-message.d.ts +18 -0
- package/highlevel/types/messages/rich-message.js +45 -0
- package/highlevel/types/peers/chat-permissions.cjs +6 -0
- package/highlevel/types/peers/chat-permissions.d.cts +4 -0
- package/highlevel/types/peers/chat-permissions.d.ts +4 -0
- package/highlevel/types/peers/chat-permissions.js +6 -0
- package/highlevel/types/peers/full-chat.cjs +6 -0
- package/highlevel/types/peers/full-chat.d.cts +2 -0
- package/highlevel/types/peers/full-chat.d.ts +2 -0
- package/highlevel/types/peers/full-chat.js +6 -0
- package/highlevel/types/peers/user.cjs +8 -0
- package/highlevel/types/peers/user.d.cts +4 -0
- package/highlevel/types/peers/user.d.ts +4 -0
- package/highlevel/types/peers/user.js +8 -0
- package/highlevel/types/updates/bot-guest-chat-query.cjs +39 -0
- package/highlevel/types/updates/bot-guest-chat-query.d.cts +21 -0
- package/highlevel/types/updates/bot-guest-chat-query.d.ts +21 -0
- package/highlevel/types/updates/bot-guest-chat-query.js +34 -0
- package/highlevel/types/updates/index.d.cts +5 -1
- package/highlevel/types/updates/index.d.ts +5 -1
- package/highlevel/types/updates/parse-update.cjs +3 -0
- package/highlevel/types/updates/parse-update.js +3 -0
- package/highlevel/types/updates/user-typing-update.cjs +2 -0
- package/highlevel/types/updates/user-typing-update.js +2 -0
- package/highlevel/updates/manager.cjs +214 -3
- package/highlevel/updates/manager.d.cts +1 -0
- package/highlevel/updates/manager.d.ts +1 -0
- package/highlevel/updates/manager.js +214 -3
- package/highlevel/utils/inspectable.cjs +1 -0
- package/highlevel/utils/inspectable.d.cts +1 -0
- package/highlevel/utils/inspectable.d.ts +1 -0
- package/highlevel/utils/inspectable.js +1 -0
- package/index.cjs +4 -0
- package/index.js +4 -0
- package/methods.cjs +2 -0
- package/methods.js +2 -0
- package/network/flood-control.cjs +149 -0
- package/network/flood-control.d.cts +79 -0
- package/network/flood-control.d.ts +79 -0
- package/network/flood-control.js +144 -0
- package/network/flood-control.test.d.cts +1 -0
- package/network/flood-control.test.d.ts +1 -0
- package/network/mtproto-session.cjs +1 -21
- package/network/mtproto-session.d.cts +1 -5
- package/network/mtproto-session.d.ts +1 -5
- package/network/mtproto-session.js +2 -22
- package/network/multi-session-connection.cjs +26 -16
- package/network/multi-session-connection.d.cts +1 -1
- package/network/multi-session-connection.d.ts +1 -1
- package/network/multi-session-connection.js +26 -16
- package/network/multi-session-connection.test.d.cts +1 -0
- package/network/multi-session-connection.test.d.ts +1 -0
- package/network/network-manager.cjs +3 -2
- package/network/network-manager.d.cts +12 -0
- package/network/network-manager.d.ts +12 -0
- package/network/network-manager.js +3 -2
- package/network/persistent-connection.cjs +25 -1
- package/network/persistent-connection.d.cts +5 -0
- package/network/persistent-connection.d.ts +5 -0
- package/network/persistent-connection.js +25 -1
- package/network/session-connection.cjs +5 -10
- package/network/session-connection.d.cts +0 -2
- package/network/session-connection.d.ts +0 -2
- package/network/session-connection.js +5 -10
- package/package.json +1 -1
- package/tl/api-schema.json +1 -1
- package/tl/binary/reader.cjs +257 -62
- package/tl/binary/reader.js +257 -62
- package/tl/binary/writer.cjs +837 -212
- package/tl/binary/writer.js +837 -212
- package/tl/compat/reader.cjs +31 -0
- package/tl/compat/reader.js +31 -0
- package/tl/index.d.cts +2478 -186
- package/tl/index.d.ts +2478 -186
- package/tl/inner-tl.cjs +34 -10
- package/tl/inner-tl.js +34 -10
- package/utils/binary/compat.cjs +84 -0
- package/utils/binary/compat.js +84 -0
- package/utils/index.d.cts +1 -0
- package/utils/index.d.ts +1 -0
- package/utils/long-utils.cjs +10 -0
- package/utils/long-utils.js +10 -0
- package/utils.cjs +7 -0
- package/utils.js +8 -1
package/client.cjs
CHANGED
|
@@ -20,6 +20,7 @@ const signIn = require("./highlevel/methods/auth/sign-in.cjs");
|
|
|
20
20
|
const startTest = require("./highlevel/methods/auth/start-test.cjs");
|
|
21
21
|
const start = require("./highlevel/methods/auth/start.cjs");
|
|
22
22
|
const utils$1 = require("./highlevel/methods/auth/utils.cjs");
|
|
23
|
+
const answerBotGuestChatQuery = require("./highlevel/methods/bots/answer-bot-guest-chat-query.cjs");
|
|
23
24
|
const answerCallbackQuery = require("./highlevel/methods/bots/answer-callback-query.cjs");
|
|
24
25
|
const answerInlineQuery = require("./highlevel/methods/bots/answer-inline-query.cjs");
|
|
25
26
|
const answerPreCheckoutQuery = require("./highlevel/methods/bots/answer-pre-checkout-query.cjs");
|
|
@@ -303,6 +304,7 @@ class TelegramClient {
|
|
|
303
304
|
this.onDeleteMessage = new utils.Emitter();
|
|
304
305
|
this.onChatMemberUpdate = new utils.Emitter();
|
|
305
306
|
this.onInlineQuery = new utils.Emitter();
|
|
307
|
+
this.onBotGuestChatQuery = new utils.Emitter();
|
|
306
308
|
this.onChosenInlineResult = new utils.Emitter();
|
|
307
309
|
this.onCallbackQuery = new utils.Emitter();
|
|
308
310
|
this.onInlineCallbackQuery = new utils.Emitter();
|
|
@@ -373,6 +375,9 @@ class TelegramClient {
|
|
|
373
375
|
case "inline_query":
|
|
374
376
|
this.onInlineQuery.emit(update.data);
|
|
375
377
|
break;
|
|
378
|
+
case "bot_guest_chat_query":
|
|
379
|
+
this.onBotGuestChatQuery.emit(update.data);
|
|
380
|
+
break;
|
|
376
381
|
case "chosen_inline_result":
|
|
377
382
|
this.onChosenInlineResult.emit(update.data);
|
|
378
383
|
break;
|
|
@@ -488,6 +493,9 @@ TelegramClient.prototype.start = function(...args) {
|
|
|
488
493
|
TelegramClient.prototype.isSelfPeer = function(...args) {
|
|
489
494
|
return utils$1.isSelfPeer(this._client, ...args);
|
|
490
495
|
};
|
|
496
|
+
TelegramClient.prototype.answerBotGuestChatQuery = function(...args) {
|
|
497
|
+
return answerBotGuestChatQuery.answerBotGuestChatQuery(this._client, ...args);
|
|
498
|
+
};
|
|
491
499
|
TelegramClient.prototype.answerCallbackQuery = function(...args) {
|
|
492
500
|
return answerCallbackQuery.answerCallbackQuery(this._client, ...args);
|
|
493
501
|
};
|
package/client.js
CHANGED
|
@@ -13,6 +13,7 @@ import { signIn } from "./highlevel/methods/auth/sign-in.js";
|
|
|
13
13
|
import { startTest } from "./highlevel/methods/auth/start-test.js";
|
|
14
14
|
import { start } from "./highlevel/methods/auth/start.js";
|
|
15
15
|
import { isSelfPeer } from "./highlevel/methods/auth/utils.js";
|
|
16
|
+
import { answerBotGuestChatQuery } from "./highlevel/methods/bots/answer-bot-guest-chat-query.js";
|
|
16
17
|
import { answerCallbackQuery } from "./highlevel/methods/bots/answer-callback-query.js";
|
|
17
18
|
import { answerInlineQuery } from "./highlevel/methods/bots/answer-inline-query.js";
|
|
18
19
|
import { answerPreCheckoutQuery } from "./highlevel/methods/bots/answer-pre-checkout-query.js";
|
|
@@ -296,6 +297,7 @@ class TelegramClient {
|
|
|
296
297
|
this.onDeleteMessage = new Emitter();
|
|
297
298
|
this.onChatMemberUpdate = new Emitter();
|
|
298
299
|
this.onInlineQuery = new Emitter();
|
|
300
|
+
this.onBotGuestChatQuery = new Emitter();
|
|
299
301
|
this.onChosenInlineResult = new Emitter();
|
|
300
302
|
this.onCallbackQuery = new Emitter();
|
|
301
303
|
this.onInlineCallbackQuery = new Emitter();
|
|
@@ -366,6 +368,9 @@ class TelegramClient {
|
|
|
366
368
|
case "inline_query":
|
|
367
369
|
this.onInlineQuery.emit(update.data);
|
|
368
370
|
break;
|
|
371
|
+
case "bot_guest_chat_query":
|
|
372
|
+
this.onBotGuestChatQuery.emit(update.data);
|
|
373
|
+
break;
|
|
369
374
|
case "chosen_inline_result":
|
|
370
375
|
this.onChosenInlineResult.emit(update.data);
|
|
371
376
|
break;
|
|
@@ -481,6 +486,9 @@ TelegramClient.prototype.start = function(...args) {
|
|
|
481
486
|
TelegramClient.prototype.isSelfPeer = function(...args) {
|
|
482
487
|
return isSelfPeer(this._client, ...args);
|
|
483
488
|
};
|
|
489
|
+
TelegramClient.prototype.answerBotGuestChatQuery = function(...args) {
|
|
490
|
+
return answerBotGuestChatQuery(this._client, ...args);
|
|
491
|
+
};
|
|
484
492
|
TelegramClient.prototype.answerCallbackQuery = function(...args) {
|
|
485
493
|
return answerCallbackQuery(this._client, ...args);
|
|
486
494
|
};
|
package/highlevel/client.d.cts
CHANGED
|
@@ -6,6 +6,8 @@ import { BaseTelegramClientOptions } from './base.js';
|
|
|
6
6
|
import { ITelegramClient } from './client.types.js';
|
|
7
7
|
import { LogOutResult } from './methods/auth/log-out.js';
|
|
8
8
|
import { CreateGroupResult } from './methods/chats/create-group.js';
|
|
9
|
+
import { JoinChatResult } from './methods/chats/join-chat.js';
|
|
10
|
+
import { DraftMessageInput } from './methods/chats/save-draft.js';
|
|
9
11
|
import { GetForumTopicsOffset, getForumTopics } from './methods/forums/get-forum-topics.js';
|
|
10
12
|
import { InputStarGiftAttributeIds, ResaleStarGiftsMeta } from './methods/gifts/get-resale-star-gifts.js';
|
|
11
13
|
import { StarGiftUpgradeOptions } from './methods/gifts/get-star-gift-upgrade-options.js';
|
|
@@ -27,7 +29,7 @@ import { InputStarsAmount } from './methods/premium/_normalize-stars-amount.js';
|
|
|
27
29
|
import { CanApplyBoostResult } from './methods/premium/can-apply-boost.js';
|
|
28
30
|
import { CanSendStoryResult } from './methods/stories/can-send-story.js';
|
|
29
31
|
import { ITelegramStorageProvider } from './storage/provider.js';
|
|
30
|
-
import { AllStories, ArrayPaginated, ArrayPaginatedWithMeta, ArrayWithTotal, Audio, Boost, BoostSlot, BoostStats, BotChatJoinRequestUpdate, BotCommands, BotReactionCountUpdate, BotReactionUpdate, BotStoppedUpdate, BusinessCallbackQuery, BusinessChatLink, BusinessConnection, BusinessMessage, BusinessWorkHoursDay, CallbackQuery, Chat, ChatEvent, ChatInviteLink, ChatInviteLinkMember, ChatJoinRequestUpdate, ChatlistPreview, ChatMember, ChatMemberUpdate, ChatPreview, ChosenInlineResult, CollectibleInfo, DeleteBusinessMessageUpdate, DeleteMessageUpdate, DeleteStoryUpdate, Dialog, FactCheck, FileDownloadLocation, FileDownloadParameters, ForumTopic, FullChat, FullUser, GameHighScore, HistoryReadUpdate, InlineCallbackQuery, InlineQuery, InputChatEventFilters, InputDialogFolder, InputDocumentId, InputFileLike, InputInlineResult, InputMediaAudio, InputMediaLike, InputMediaSticker, InputMessageId, InputPeerLike, InputPrivacyRule, InputReaction, InputStarGift, InputStickerSet, InputStickerSetItem, InputText, InputWebview, MaybeDynamic, Message, MessageEffect, MessageMedia, MessageReactions, ParametersSkip2, ParsedUpdate, Peer, PeerReaction, PeerSettings, PeerStories, Photo, Poll, PollUpdate, PollVoteUpdate, PreCheckoutQuery, RawDocument, ReplyMarkup, SavedStarGift, SentCode, StarGift, StarGiftUnique, StarGiftValue, StarsStatus, StarsTransaction, Sticker, StickerSet, StickerType, StoriesStealthMode, Story, StoryInteractions, StoryUpdate, StoryViewer, StoryViewersList, TakeoutSession, TextWithEntities, TypingStatus, UploadedFile, UploadFileLike, User, UserStatusUpdate, UserTypingUpdate, WebPageMedia, WebviewResult } from './types/index.js';
|
|
32
|
+
import { AllStories, ArrayPaginated, ArrayPaginatedWithMeta, ArrayWithTotal, Audio, Boost, BoostSlot, BoostStats, BotChatJoinRequestUpdate, BotCommands, BotGuestChatQuery, BotReactionCountUpdate, BotReactionUpdate, BotStoppedUpdate, BusinessCallbackQuery, BusinessChatLink, BusinessConnection, BusinessMessage, BusinessWorkHoursDay, CallbackQuery, Chat, ChatEvent, ChatInviteLink, ChatInviteLinkMember, ChatJoinRequestUpdate, ChatlistPreview, ChatMember, ChatMemberUpdate, ChatPreview, ChosenInlineResult, CollectibleInfo, DeleteBusinessMessageUpdate, DeleteMessageUpdate, DeleteStoryUpdate, Dialog, FactCheck, FileDownloadLocation, FileDownloadParameters, ForumTopic, FullChat, FullUser, GameHighScore, HistoryReadUpdate, InlineCallbackQuery, InlineQuery, InputChatEventFilters, InputDialogFolder, InputDocumentId, InputFileLike, InputInlineMessage, InputInlineResult, InputMediaAudio, InputMediaLike, InputMediaSticker, InputMessageId, InputPeerLike, InputPrivacyRule, InputReaction, InputStarGift, InputStickerSet, InputStickerSetItem, InputText, InputWebview, MaybeDynamic, Message, MessageEffect, MessageMedia, MessageReactions, ParametersSkip2, ParsedUpdate, Peer, PeerReaction, PeerSettings, PeerStories, Photo, Poll, PollUpdate, PollVoteUpdate, PreCheckoutQuery, RawDocument, ReplyMarkup, SavedStarGift, SentCode, StarGift, StarGiftUnique, StarGiftValue, StarsStatus, StarsTransaction, Sticker, StickerSet, StickerType, StoriesStealthMode, Story, StoryInteractions, StoryUpdate, StoryViewer, StoryViewersList, TakeoutSession, TextWithEntities, TypingStatus, UploadedFile, UploadFileLike, User, UserStatusUpdate, UserTypingUpdate, WebPageMedia, WebviewResult } from './types/index.js';
|
|
31
33
|
import { ParsedUpdateHandlerParams } from './updates/parsed.js';
|
|
32
34
|
import { RawUpdateInfo } from './updates/types.js';
|
|
33
35
|
import { InputStringSessionData } from './utils/string-session.js';
|
|
@@ -91,6 +93,8 @@ export interface TelegramClient extends ITelegramClient {
|
|
|
91
93
|
readonly onChatMemberUpdate: Emitter<ChatMemberUpdate>;
|
|
92
94
|
/** an inline query handler */
|
|
93
95
|
readonly onInlineQuery: Emitter<InlineQuery>;
|
|
96
|
+
/** a bot guest chat query handler */
|
|
97
|
+
readonly onBotGuestChatQuery: Emitter<BotGuestChatQuery>;
|
|
94
98
|
/** a chosen inline result handler */
|
|
95
99
|
readonly onChosenInlineResult: Emitter<ChosenInlineResult>;
|
|
96
100
|
/** a callback query handler */
|
|
@@ -412,6 +416,14 @@ export interface TelegramClient extends ITelegramClient {
|
|
|
412
416
|
*
|
|
413
417
|
*/
|
|
414
418
|
isSelfPeer(peer: tl.TypeInputPeer | tl.TypePeer | tl.TypeInputUser): boolean;
|
|
419
|
+
/**
|
|
420
|
+
* Answer a bot guest chat query with a result.
|
|
421
|
+
*
|
|
422
|
+
* @param queryId Query ID
|
|
423
|
+
* @param result Result of the query
|
|
424
|
+
* @returns ID of the inline message that was sent
|
|
425
|
+
*/
|
|
426
|
+
answerBotGuestChatQuery(queryId: tl.Long | BotGuestChatQuery, result: InputInlineMessage | InputInlineResult): Promise<tl.TypeInputBotInlineMessageID>;
|
|
415
427
|
/**
|
|
416
428
|
* Send an answer to a callback query.
|
|
417
429
|
*
|
|
@@ -1113,6 +1125,8 @@ export interface TelegramClient extends ITelegramClient {
|
|
|
1113
1125
|
}): Promise<void>;
|
|
1114
1126
|
/**
|
|
1115
1127
|
* Edit the custom rank (title) of a group chat participant.
|
|
1128
|
+
* **Available**: 👤 users only
|
|
1129
|
+
*
|
|
1116
1130
|
*/
|
|
1117
1131
|
editChatMemberRank(params: {
|
|
1118
1132
|
/** Chat ID */
|
|
@@ -1283,6 +1297,8 @@ export interface TelegramClient extends ITelegramClient {
|
|
|
1283
1297
|
* Get the user who will be made the creator of the chat/channel/supergroup if you were to leave it.
|
|
1284
1298
|
*
|
|
1285
1299
|
* You must be the creator of the chat/channel/supergroup to use this method.
|
|
1300
|
+
* **Available**: 👤 users only
|
|
1301
|
+
*
|
|
1286
1302
|
*/
|
|
1287
1303
|
getCreatorAfterLeave(chatId: InputPeerLike): Promise<User | null>;
|
|
1288
1304
|
/**
|
|
@@ -1385,17 +1401,13 @@ export interface TelegramClient extends ITelegramClient {
|
|
|
1385
1401
|
/**
|
|
1386
1402
|
* Join a channel or supergroup
|
|
1387
1403
|
*
|
|
1388
|
-
* When using with invite links, this method may throw RPC error
|
|
1389
|
-
* `INVITE_REQUEST_SENT`, which means that you need to wait for admin approval.
|
|
1390
|
-
* You will get into the chat once they do so.
|
|
1391
|
-
*
|
|
1392
1404
|
* **Available**: 👤 users only
|
|
1393
1405
|
*
|
|
1394
1406
|
* @param chatId
|
|
1395
1407
|
* Chat identifier. Either an invite link (`t.me/joinchat/*`), a username (`@username`)
|
|
1396
1408
|
* or ID of the linked supergroup or channel.
|
|
1397
1409
|
*/
|
|
1398
|
-
joinChat(chatId: InputPeerLike): Promise<
|
|
1410
|
+
joinChat(chatId: InputPeerLike): Promise<JoinChatResult>;
|
|
1399
1411
|
/**
|
|
1400
1412
|
* Kick a user from a chat.
|
|
1401
1413
|
*
|
|
@@ -1503,7 +1515,7 @@ export interface TelegramClient extends ITelegramClient {
|
|
|
1503
1515
|
* @param chatId ID of the chat, its username, phone or `"me"` or `"self"`
|
|
1504
1516
|
* @param draft Draft message, or `null` to delete.
|
|
1505
1517
|
*/
|
|
1506
|
-
saveDraft(chatId: InputPeerLike, draft: null |
|
|
1518
|
+
saveDraft(chatId: InputPeerLike, draft: null | DraftMessageInput): Promise<void>;
|
|
1507
1519
|
/**
|
|
1508
1520
|
* Set peer color and optionally background pattern
|
|
1509
1521
|
* **Available**: 👤 users only
|
|
@@ -1689,6 +1701,8 @@ export interface TelegramClient extends ITelegramClient {
|
|
|
1689
1701
|
*
|
|
1690
1702
|
* You must be the creator of the chat to use this method,
|
|
1691
1703
|
* and your account must have 2FA enabled.
|
|
1704
|
+
* **Available**: 👤 users only
|
|
1705
|
+
*
|
|
1692
1706
|
*/
|
|
1693
1707
|
transferChatOwnership(params: {
|
|
1694
1708
|
/** ID of the chat/channel/supergroup to transfer */
|
|
@@ -3100,6 +3114,8 @@ export interface TelegramClient extends ITelegramClient {
|
|
|
3100
3114
|
*
|
|
3101
3115
|
* - `append` - appends the text to the previous draft
|
|
3102
3116
|
* - `replace` - replaces the previous draft with the new one
|
|
3117
|
+
*
|
|
3118
|
+
* @default `replace`
|
|
3103
3119
|
*/
|
|
3104
3120
|
mode?: 'append' | 'replace';
|
|
3105
3121
|
}): Promise<StreamingDraft>;
|
package/highlevel/client.d.ts
CHANGED
|
@@ -6,6 +6,8 @@ import { BaseTelegramClientOptions } from './base.js';
|
|
|
6
6
|
import { ITelegramClient } from './client.types.js';
|
|
7
7
|
import { LogOutResult } from './methods/auth/log-out.js';
|
|
8
8
|
import { CreateGroupResult } from './methods/chats/create-group.js';
|
|
9
|
+
import { JoinChatResult } from './methods/chats/join-chat.js';
|
|
10
|
+
import { DraftMessageInput } from './methods/chats/save-draft.js';
|
|
9
11
|
import { GetForumTopicsOffset, getForumTopics } from './methods/forums/get-forum-topics.js';
|
|
10
12
|
import { InputStarGiftAttributeIds, ResaleStarGiftsMeta } from './methods/gifts/get-resale-star-gifts.js';
|
|
11
13
|
import { StarGiftUpgradeOptions } from './methods/gifts/get-star-gift-upgrade-options.js';
|
|
@@ -27,7 +29,7 @@ import { InputStarsAmount } from './methods/premium/_normalize-stars-amount.js';
|
|
|
27
29
|
import { CanApplyBoostResult } from './methods/premium/can-apply-boost.js';
|
|
28
30
|
import { CanSendStoryResult } from './methods/stories/can-send-story.js';
|
|
29
31
|
import { ITelegramStorageProvider } from './storage/provider.js';
|
|
30
|
-
import { AllStories, ArrayPaginated, ArrayPaginatedWithMeta, ArrayWithTotal, Audio, Boost, BoostSlot, BoostStats, BotChatJoinRequestUpdate, BotCommands, BotReactionCountUpdate, BotReactionUpdate, BotStoppedUpdate, BusinessCallbackQuery, BusinessChatLink, BusinessConnection, BusinessMessage, BusinessWorkHoursDay, CallbackQuery, Chat, ChatEvent, ChatInviteLink, ChatInviteLinkMember, ChatJoinRequestUpdate, ChatlistPreview, ChatMember, ChatMemberUpdate, ChatPreview, ChosenInlineResult, CollectibleInfo, DeleteBusinessMessageUpdate, DeleteMessageUpdate, DeleteStoryUpdate, Dialog, FactCheck, FileDownloadLocation, FileDownloadParameters, ForumTopic, FullChat, FullUser, GameHighScore, HistoryReadUpdate, InlineCallbackQuery, InlineQuery, InputChatEventFilters, InputDialogFolder, InputDocumentId, InputFileLike, InputInlineResult, InputMediaAudio, InputMediaLike, InputMediaSticker, InputMessageId, InputPeerLike, InputPrivacyRule, InputReaction, InputStarGift, InputStickerSet, InputStickerSetItem, InputText, InputWebview, MaybeDynamic, Message, MessageEffect, MessageMedia, MessageReactions, ParametersSkip2, ParsedUpdate, Peer, PeerReaction, PeerSettings, PeerStories, Photo, Poll, PollUpdate, PollVoteUpdate, PreCheckoutQuery, RawDocument, ReplyMarkup, SavedStarGift, SentCode, StarGift, StarGiftUnique, StarGiftValue, StarsStatus, StarsTransaction, Sticker, StickerSet, StickerType, StoriesStealthMode, Story, StoryInteractions, StoryUpdate, StoryViewer, StoryViewersList, TakeoutSession, TextWithEntities, TypingStatus, UploadedFile, UploadFileLike, User, UserStatusUpdate, UserTypingUpdate, WebPageMedia, WebviewResult } from './types/index.js';
|
|
32
|
+
import { AllStories, ArrayPaginated, ArrayPaginatedWithMeta, ArrayWithTotal, Audio, Boost, BoostSlot, BoostStats, BotChatJoinRequestUpdate, BotCommands, BotGuestChatQuery, BotReactionCountUpdate, BotReactionUpdate, BotStoppedUpdate, BusinessCallbackQuery, BusinessChatLink, BusinessConnection, BusinessMessage, BusinessWorkHoursDay, CallbackQuery, Chat, ChatEvent, ChatInviteLink, ChatInviteLinkMember, ChatJoinRequestUpdate, ChatlistPreview, ChatMember, ChatMemberUpdate, ChatPreview, ChosenInlineResult, CollectibleInfo, DeleteBusinessMessageUpdate, DeleteMessageUpdate, DeleteStoryUpdate, Dialog, FactCheck, FileDownloadLocation, FileDownloadParameters, ForumTopic, FullChat, FullUser, GameHighScore, HistoryReadUpdate, InlineCallbackQuery, InlineQuery, InputChatEventFilters, InputDialogFolder, InputDocumentId, InputFileLike, InputInlineMessage, InputInlineResult, InputMediaAudio, InputMediaLike, InputMediaSticker, InputMessageId, InputPeerLike, InputPrivacyRule, InputReaction, InputStarGift, InputStickerSet, InputStickerSetItem, InputText, InputWebview, MaybeDynamic, Message, MessageEffect, MessageMedia, MessageReactions, ParametersSkip2, ParsedUpdate, Peer, PeerReaction, PeerSettings, PeerStories, Photo, Poll, PollUpdate, PollVoteUpdate, PreCheckoutQuery, RawDocument, ReplyMarkup, SavedStarGift, SentCode, StarGift, StarGiftUnique, StarGiftValue, StarsStatus, StarsTransaction, Sticker, StickerSet, StickerType, StoriesStealthMode, Story, StoryInteractions, StoryUpdate, StoryViewer, StoryViewersList, TakeoutSession, TextWithEntities, TypingStatus, UploadedFile, UploadFileLike, User, UserStatusUpdate, UserTypingUpdate, WebPageMedia, WebviewResult } from './types/index.js';
|
|
31
33
|
import { ParsedUpdateHandlerParams } from './updates/parsed.js';
|
|
32
34
|
import { RawUpdateInfo } from './updates/types.js';
|
|
33
35
|
import { InputStringSessionData } from './utils/string-session.js';
|
|
@@ -91,6 +93,8 @@ export interface TelegramClient extends ITelegramClient {
|
|
|
91
93
|
readonly onChatMemberUpdate: Emitter<ChatMemberUpdate>;
|
|
92
94
|
/** an inline query handler */
|
|
93
95
|
readonly onInlineQuery: Emitter<InlineQuery>;
|
|
96
|
+
/** a bot guest chat query handler */
|
|
97
|
+
readonly onBotGuestChatQuery: Emitter<BotGuestChatQuery>;
|
|
94
98
|
/** a chosen inline result handler */
|
|
95
99
|
readonly onChosenInlineResult: Emitter<ChosenInlineResult>;
|
|
96
100
|
/** a callback query handler */
|
|
@@ -412,6 +416,14 @@ export interface TelegramClient extends ITelegramClient {
|
|
|
412
416
|
*
|
|
413
417
|
*/
|
|
414
418
|
isSelfPeer(peer: tl.TypeInputPeer | tl.TypePeer | tl.TypeInputUser): boolean;
|
|
419
|
+
/**
|
|
420
|
+
* Answer a bot guest chat query with a result.
|
|
421
|
+
*
|
|
422
|
+
* @param queryId Query ID
|
|
423
|
+
* @param result Result of the query
|
|
424
|
+
* @returns ID of the inline message that was sent
|
|
425
|
+
*/
|
|
426
|
+
answerBotGuestChatQuery(queryId: tl.Long | BotGuestChatQuery, result: InputInlineMessage | InputInlineResult): Promise<tl.TypeInputBotInlineMessageID>;
|
|
415
427
|
/**
|
|
416
428
|
* Send an answer to a callback query.
|
|
417
429
|
*
|
|
@@ -1113,6 +1125,8 @@ export interface TelegramClient extends ITelegramClient {
|
|
|
1113
1125
|
}): Promise<void>;
|
|
1114
1126
|
/**
|
|
1115
1127
|
* Edit the custom rank (title) of a group chat participant.
|
|
1128
|
+
* **Available**: 👤 users only
|
|
1129
|
+
*
|
|
1116
1130
|
*/
|
|
1117
1131
|
editChatMemberRank(params: {
|
|
1118
1132
|
/** Chat ID */
|
|
@@ -1283,6 +1297,8 @@ export interface TelegramClient extends ITelegramClient {
|
|
|
1283
1297
|
* Get the user who will be made the creator of the chat/channel/supergroup if you were to leave it.
|
|
1284
1298
|
*
|
|
1285
1299
|
* You must be the creator of the chat/channel/supergroup to use this method.
|
|
1300
|
+
* **Available**: 👤 users only
|
|
1301
|
+
*
|
|
1286
1302
|
*/
|
|
1287
1303
|
getCreatorAfterLeave(chatId: InputPeerLike): Promise<User | null>;
|
|
1288
1304
|
/**
|
|
@@ -1385,17 +1401,13 @@ export interface TelegramClient extends ITelegramClient {
|
|
|
1385
1401
|
/**
|
|
1386
1402
|
* Join a channel or supergroup
|
|
1387
1403
|
*
|
|
1388
|
-
* When using with invite links, this method may throw RPC error
|
|
1389
|
-
* `INVITE_REQUEST_SENT`, which means that you need to wait for admin approval.
|
|
1390
|
-
* You will get into the chat once they do so.
|
|
1391
|
-
*
|
|
1392
1404
|
* **Available**: 👤 users only
|
|
1393
1405
|
*
|
|
1394
1406
|
* @param chatId
|
|
1395
1407
|
* Chat identifier. Either an invite link (`t.me/joinchat/*`), a username (`@username`)
|
|
1396
1408
|
* or ID of the linked supergroup or channel.
|
|
1397
1409
|
*/
|
|
1398
|
-
joinChat(chatId: InputPeerLike): Promise<
|
|
1410
|
+
joinChat(chatId: InputPeerLike): Promise<JoinChatResult>;
|
|
1399
1411
|
/**
|
|
1400
1412
|
* Kick a user from a chat.
|
|
1401
1413
|
*
|
|
@@ -1503,7 +1515,7 @@ export interface TelegramClient extends ITelegramClient {
|
|
|
1503
1515
|
* @param chatId ID of the chat, its username, phone or `"me"` or `"self"`
|
|
1504
1516
|
* @param draft Draft message, or `null` to delete.
|
|
1505
1517
|
*/
|
|
1506
|
-
saveDraft(chatId: InputPeerLike, draft: null |
|
|
1518
|
+
saveDraft(chatId: InputPeerLike, draft: null | DraftMessageInput): Promise<void>;
|
|
1507
1519
|
/**
|
|
1508
1520
|
* Set peer color and optionally background pattern
|
|
1509
1521
|
* **Available**: 👤 users only
|
|
@@ -1689,6 +1701,8 @@ export interface TelegramClient extends ITelegramClient {
|
|
|
1689
1701
|
*
|
|
1690
1702
|
* You must be the creator of the chat to use this method,
|
|
1691
1703
|
* and your account must have 2FA enabled.
|
|
1704
|
+
* **Available**: 👤 users only
|
|
1705
|
+
*
|
|
1692
1706
|
*/
|
|
1693
1707
|
transferChatOwnership(params: {
|
|
1694
1708
|
/** ID of the chat/channel/supergroup to transfer */
|
|
@@ -3100,6 +3114,8 @@ export interface TelegramClient extends ITelegramClient {
|
|
|
3100
3114
|
*
|
|
3101
3115
|
* - `append` - appends the text to the previous draft
|
|
3102
3116
|
* - `replace` - replaces the previous draft with the new one
|
|
3117
|
+
*
|
|
3118
|
+
* @default `replace`
|
|
3103
3119
|
*/
|
|
3104
3120
|
mode?: 'append' | 'replace';
|
|
3105
3121
|
}): Promise<StreamingDraft>;
|
|
@@ -0,0 +1,26 @@
|
|
|
1
|
+
if (typeof globalThis !== "undefined" && !globalThis._MTCUTE_CJS_DEPRECATION_WARNED) {
|
|
2
|
+
globalThis._MTCUTE_CJS_DEPRECATION_WARNED = true;
|
|
3
|
+
console.warn("[@mtcute/core] CommonJS bundles are deprecated. They will be removed completely in one of the upcoming releases. No support is provided for CommonJS users. Please consider switching to ESM, it's " + (/* @__PURE__ */ new Date()).getFullYear() + " already.");
|
|
4
|
+
console.warn("[@mtcute/core] Learn more about switching to ESM: https://gist.github.com/sindresorhus/a39789f98801d908bbc7ff3ecc99d99c");
|
|
5
|
+
}
|
|
6
|
+
"use strict";
|
|
7
|
+
Object.defineProperty(exports, Symbol.toStringTag, { value: "Module" });
|
|
8
|
+
const Long = require("long");
|
|
9
|
+
const factories = require("../../types/bots/inline-result/factories.cjs");
|
|
10
|
+
async function answerBotGuestChatQuery(client, queryId, result) {
|
|
11
|
+
if (!("id" in result)) {
|
|
12
|
+
result = {
|
|
13
|
+
type: "article",
|
|
14
|
+
id: "guest",
|
|
15
|
+
title: "guest",
|
|
16
|
+
message: result
|
|
17
|
+
};
|
|
18
|
+
}
|
|
19
|
+
const [, tlResults] = await factories._convertToTl(client, [result]);
|
|
20
|
+
return client.call({
|
|
21
|
+
_: "messages.setBotGuestChatResult",
|
|
22
|
+
queryId: Long.isLong(queryId) ? queryId : queryId.id,
|
|
23
|
+
result: tlResults[0]
|
|
24
|
+
});
|
|
25
|
+
}
|
|
26
|
+
exports.answerBotGuestChatQuery = answerBotGuestChatQuery;
|
|
@@ -0,0 +1,12 @@
|
|
|
1
|
+
import { tl } from '../../../tl/index.js';
|
|
2
|
+
import { ITelegramClient } from '../../client.types.js';
|
|
3
|
+
import { InputInlineMessage, InputInlineResult } from '../../types/bots/index.js';
|
|
4
|
+
import { BotGuestChatQuery } from '../../types/updates/bot-guest-chat-query.js';
|
|
5
|
+
/**
|
|
6
|
+
* Answer a bot guest chat query with a result.
|
|
7
|
+
*
|
|
8
|
+
* @param queryId Query ID
|
|
9
|
+
* @param result Result of the query
|
|
10
|
+
* @returns ID of the inline message that was sent
|
|
11
|
+
*/
|
|
12
|
+
export declare function answerBotGuestChatQuery(client: ITelegramClient, queryId: tl.Long | BotGuestChatQuery, result: InputInlineMessage | InputInlineResult): Promise<tl.TypeInputBotInlineMessageID>;
|
|
@@ -0,0 +1,12 @@
|
|
|
1
|
+
import { tl } from '../../../tl/index.js';
|
|
2
|
+
import { ITelegramClient } from '../../client.types.js';
|
|
3
|
+
import { InputInlineMessage, InputInlineResult } from '../../types/bots/index.js';
|
|
4
|
+
import { BotGuestChatQuery } from '../../types/updates/bot-guest-chat-query.js';
|
|
5
|
+
/**
|
|
6
|
+
* Answer a bot guest chat query with a result.
|
|
7
|
+
*
|
|
8
|
+
* @param queryId Query ID
|
|
9
|
+
* @param result Result of the query
|
|
10
|
+
* @returns ID of the inline message that was sent
|
|
11
|
+
*/
|
|
12
|
+
export declare function answerBotGuestChatQuery(client: ITelegramClient, queryId: tl.Long | BotGuestChatQuery, result: InputInlineMessage | InputInlineResult): Promise<tl.TypeInputBotInlineMessageID>;
|
|
@@ -0,0 +1,21 @@
|
|
|
1
|
+
import Long from "long";
|
|
2
|
+
import { _convertToTl } from "../../types/bots/inline-result/factories.js";
|
|
3
|
+
async function answerBotGuestChatQuery(client, queryId, result) {
|
|
4
|
+
if (!("id" in result)) {
|
|
5
|
+
result = {
|
|
6
|
+
type: "article",
|
|
7
|
+
id: "guest",
|
|
8
|
+
title: "guest",
|
|
9
|
+
message: result
|
|
10
|
+
};
|
|
11
|
+
}
|
|
12
|
+
const [, tlResults] = await _convertToTl(client, [result]);
|
|
13
|
+
return client.call({
|
|
14
|
+
_: "messages.setBotGuestChatResult",
|
|
15
|
+
queryId: Long.isLong(queryId) ? queryId : queryId.id,
|
|
16
|
+
result: tlResults[0]
|
|
17
|
+
});
|
|
18
|
+
}
|
|
19
|
+
export {
|
|
20
|
+
answerBotGuestChatQuery
|
|
21
|
+
};
|
|
@@ -8,26 +8,48 @@ Object.defineProperty(exports, Symbol.toStringTag, { value: "Module" });
|
|
|
8
8
|
const utils = require("../../updates/utils.cjs");
|
|
9
9
|
const peerUtils = require("../../utils/peer-utils.cjs");
|
|
10
10
|
const resolvePeer = require("../users/resolve-peer.cjs");
|
|
11
|
+
const innerTl = require("../../../tl/inner-tl.cjs");
|
|
12
|
+
const peersIndex = require("../../types/peers/peers-index.cjs");
|
|
13
|
+
const user = require("../../types/peers/user.cjs");
|
|
11
14
|
const chat = require("../../types/peers/chat.cjs");
|
|
12
15
|
async function joinChat(client, chatId) {
|
|
13
|
-
|
|
14
|
-
|
|
15
|
-
if (
|
|
16
|
-
const
|
|
17
|
-
|
|
18
|
-
|
|
16
|
+
let res;
|
|
17
|
+
try {
|
|
18
|
+
if (typeof chatId === "string") {
|
|
19
|
+
const m = chatId.match(peerUtils.INVITE_LINK_REGEX);
|
|
20
|
+
if (m) {
|
|
21
|
+
res = await client.call({
|
|
22
|
+
_: "messages.importChatInvite",
|
|
23
|
+
hash: m[1]
|
|
24
|
+
});
|
|
25
|
+
}
|
|
26
|
+
}
|
|
27
|
+
if (!res) {
|
|
28
|
+
res = await client.call({
|
|
29
|
+
_: "channels.joinChannel",
|
|
30
|
+
channel: await resolvePeer.resolveChannel(client, chatId)
|
|
19
31
|
});
|
|
20
|
-
|
|
21
|
-
|
|
22
|
-
|
|
32
|
+
}
|
|
33
|
+
} catch (e) {
|
|
34
|
+
if (innerTl.RpcError.is(e, "INVITE_REQUEST_SENT")) {
|
|
35
|
+
return { status: "request_sent" };
|
|
36
|
+
} else {
|
|
37
|
+
throw e;
|
|
38
|
+
}
|
|
39
|
+
}
|
|
40
|
+
switch (res._) {
|
|
41
|
+
case "messages.chatInviteJoinResultOk":
|
|
42
|
+
utils.assertIsUpdatesGroup("joinChat", res.updates);
|
|
43
|
+
client.handleClientUpdate(res.updates);
|
|
44
|
+
return { status: "ok", chat: new chat.Chat(res.updates.chats[0]) };
|
|
45
|
+
case "messages.chatInviteJoinResultWebView": {
|
|
46
|
+
const peers = peersIndex.PeersIndex.from(res);
|
|
47
|
+
return {
|
|
48
|
+
status: "webview",
|
|
49
|
+
bot: new user.User(peers.user(res.botId)),
|
|
50
|
+
webview: res.webview
|
|
51
|
+
};
|
|
23
52
|
}
|
|
24
53
|
}
|
|
25
|
-
const res = await client.call({
|
|
26
|
-
_: "channels.joinChannel",
|
|
27
|
-
channel: await resolvePeer.resolveChannel(client, chatId)
|
|
28
|
-
});
|
|
29
|
-
utils.assertIsUpdatesGroup("channels.joinChannel", res);
|
|
30
|
-
client.handleClientUpdate(res);
|
|
31
|
-
return new chat.Chat(res.chats[0]);
|
|
32
54
|
}
|
|
33
55
|
exports.joinChat = joinChat;
|
|
@@ -1,14 +1,28 @@
|
|
|
1
1
|
import { ITelegramClient } from '../../client.types.js';
|
|
2
|
-
import { InputPeerLike, Chat } from '../../types/index.js';
|
|
2
|
+
import { InputPeerLike, Chat, User } from '../../types/index.js';
|
|
3
|
+
import { tl } from '../../../tl/index.js';
|
|
3
4
|
/**
|
|
4
|
-
*
|
|
5
|
+
* Result of {@link joinChat}
|
|
5
6
|
*
|
|
6
|
-
*
|
|
7
|
-
* `
|
|
8
|
-
*
|
|
7
|
+
* - `status: 'ok'` - the chat was joined successfully
|
|
8
|
+
* - `status: 'request_sent'` - a join request was sent and needs to be approved by the chat admin
|
|
9
|
+
* - `status: 'webview'` - a guard bot requested you to open a webview before joining the chat
|
|
10
|
+
*/
|
|
11
|
+
export type JoinChatResult = {
|
|
12
|
+
status: 'ok';
|
|
13
|
+
chat: Chat;
|
|
14
|
+
} | {
|
|
15
|
+
status: 'request_sent';
|
|
16
|
+
} | {
|
|
17
|
+
status: 'webview';
|
|
18
|
+
bot: User;
|
|
19
|
+
webview: tl.TypeWebViewResult;
|
|
20
|
+
};
|
|
21
|
+
/**
|
|
22
|
+
* Join a channel or supergroup
|
|
9
23
|
*
|
|
10
24
|
* @param chatId
|
|
11
25
|
* Chat identifier. Either an invite link (`t.me/joinchat/*`), a username (`@username`)
|
|
12
26
|
* or ID of the linked supergroup or channel.
|
|
13
27
|
*/
|
|
14
|
-
export declare function joinChat(client: ITelegramClient, chatId: InputPeerLike): Promise<
|
|
28
|
+
export declare function joinChat(client: ITelegramClient, chatId: InputPeerLike): Promise<JoinChatResult>;
|
|
@@ -1,14 +1,28 @@
|
|
|
1
1
|
import { ITelegramClient } from '../../client.types.js';
|
|
2
|
-
import { InputPeerLike, Chat } from '../../types/index.js';
|
|
2
|
+
import { InputPeerLike, Chat, User } from '../../types/index.js';
|
|
3
|
+
import { tl } from '../../../tl/index.js';
|
|
3
4
|
/**
|
|
4
|
-
*
|
|
5
|
+
* Result of {@link joinChat}
|
|
5
6
|
*
|
|
6
|
-
*
|
|
7
|
-
* `
|
|
8
|
-
*
|
|
7
|
+
* - `status: 'ok'` - the chat was joined successfully
|
|
8
|
+
* - `status: 'request_sent'` - a join request was sent and needs to be approved by the chat admin
|
|
9
|
+
* - `status: 'webview'` - a guard bot requested you to open a webview before joining the chat
|
|
10
|
+
*/
|
|
11
|
+
export type JoinChatResult = {
|
|
12
|
+
status: 'ok';
|
|
13
|
+
chat: Chat;
|
|
14
|
+
} | {
|
|
15
|
+
status: 'request_sent';
|
|
16
|
+
} | {
|
|
17
|
+
status: 'webview';
|
|
18
|
+
bot: User;
|
|
19
|
+
webview: tl.TypeWebViewResult;
|
|
20
|
+
};
|
|
21
|
+
/**
|
|
22
|
+
* Join a channel or supergroup
|
|
9
23
|
*
|
|
10
24
|
* @param chatId
|
|
11
25
|
* Chat identifier. Either an invite link (`t.me/joinchat/*`), a username (`@username`)
|
|
12
26
|
* or ID of the linked supergroup or channel.
|
|
13
27
|
*/
|
|
14
|
-
export declare function joinChat(client: ITelegramClient, chatId: InputPeerLike): Promise<
|
|
28
|
+
export declare function joinChat(client: ITelegramClient, chatId: InputPeerLike): Promise<JoinChatResult>;
|
|
@@ -1,27 +1,49 @@
|
|
|
1
1
|
import { assertIsUpdatesGroup } from "../../updates/utils.js";
|
|
2
2
|
import { INVITE_LINK_REGEX } from "../../utils/peer-utils.js";
|
|
3
3
|
import { resolveChannel } from "../users/resolve-peer.js";
|
|
4
|
+
import { RpcError } from "../../../tl/inner-tl.js";
|
|
5
|
+
import { PeersIndex } from "../../types/peers/peers-index.js";
|
|
6
|
+
import { User as User$2 } from "../../types/peers/user.js";
|
|
4
7
|
import { Chat as Chat$2 } from "../../types/peers/chat.js";
|
|
5
8
|
async function joinChat(client, chatId) {
|
|
6
|
-
|
|
7
|
-
|
|
8
|
-
if (
|
|
9
|
-
const
|
|
10
|
-
|
|
11
|
-
|
|
9
|
+
let res;
|
|
10
|
+
try {
|
|
11
|
+
if (typeof chatId === "string") {
|
|
12
|
+
const m = chatId.match(INVITE_LINK_REGEX);
|
|
13
|
+
if (m) {
|
|
14
|
+
res = await client.call({
|
|
15
|
+
_: "messages.importChatInvite",
|
|
16
|
+
hash: m[1]
|
|
17
|
+
});
|
|
18
|
+
}
|
|
19
|
+
}
|
|
20
|
+
if (!res) {
|
|
21
|
+
res = await client.call({
|
|
22
|
+
_: "channels.joinChannel",
|
|
23
|
+
channel: await resolveChannel(client, chatId)
|
|
12
24
|
});
|
|
13
|
-
|
|
14
|
-
|
|
15
|
-
|
|
25
|
+
}
|
|
26
|
+
} catch (e) {
|
|
27
|
+
if (RpcError.is(e, "INVITE_REQUEST_SENT")) {
|
|
28
|
+
return { status: "request_sent" };
|
|
29
|
+
} else {
|
|
30
|
+
throw e;
|
|
31
|
+
}
|
|
32
|
+
}
|
|
33
|
+
switch (res._) {
|
|
34
|
+
case "messages.chatInviteJoinResultOk":
|
|
35
|
+
assertIsUpdatesGroup("joinChat", res.updates);
|
|
36
|
+
client.handleClientUpdate(res.updates);
|
|
37
|
+
return { status: "ok", chat: new Chat$2(res.updates.chats[0]) };
|
|
38
|
+
case "messages.chatInviteJoinResultWebView": {
|
|
39
|
+
const peers = PeersIndex.from(res);
|
|
40
|
+
return {
|
|
41
|
+
status: "webview",
|
|
42
|
+
bot: new User$2(peers.user(res.botId)),
|
|
43
|
+
webview: res.webview
|
|
44
|
+
};
|
|
16
45
|
}
|
|
17
46
|
}
|
|
18
|
-
const res = await client.call({
|
|
19
|
-
_: "channels.joinChannel",
|
|
20
|
-
channel: await resolveChannel(client, chatId)
|
|
21
|
-
});
|
|
22
|
-
assertIsUpdatesGroup("channels.joinChannel", res);
|
|
23
|
-
client.handleClientUpdate(res);
|
|
24
|
-
return new Chat$2(res.chats[0]);
|
|
25
47
|
}
|
|
26
48
|
export {
|
|
27
49
|
joinChat
|
|
@@ -1,10 +1,13 @@
|
|
|
1
1
|
import { tl } from '../../../tl/index.js';
|
|
2
2
|
import { ITelegramClient } from '../../client.types.js';
|
|
3
3
|
import { InputPeerLike } from '../../types/index.js';
|
|
4
|
+
export type DraftMessageInput = Omit<tl.RawDraftMessage, '_' | 'date' | 'richMessage'> & {
|
|
5
|
+
richMessage?: tl.TypeInputRichMessage;
|
|
6
|
+
};
|
|
4
7
|
/**
|
|
5
8
|
* Save or delete a draft message associated with some chat
|
|
6
9
|
*
|
|
7
10
|
* @param chatId ID of the chat, its username, phone or `"me"` or `"self"`
|
|
8
11
|
* @param draft Draft message, or `null` to delete.
|
|
9
12
|
*/
|
|
10
|
-
export declare function saveDraft(client: ITelegramClient, chatId: InputPeerLike, draft: null |
|
|
13
|
+
export declare function saveDraft(client: ITelegramClient, chatId: InputPeerLike, draft: null | DraftMessageInput): Promise<void>;
|
|
@@ -1,10 +1,13 @@
|
|
|
1
1
|
import { tl } from '../../../tl/index.js';
|
|
2
2
|
import { ITelegramClient } from '../../client.types.js';
|
|
3
3
|
import { InputPeerLike } from '../../types/index.js';
|
|
4
|
+
export type DraftMessageInput = Omit<tl.RawDraftMessage, '_' | 'date' | 'richMessage'> & {
|
|
5
|
+
richMessage?: tl.TypeInputRichMessage;
|
|
6
|
+
};
|
|
4
7
|
/**
|
|
5
8
|
* Save or delete a draft message associated with some chat
|
|
6
9
|
*
|
|
7
10
|
* @param chatId ID of the chat, its username, phone or `"me"` or `"self"`
|
|
8
11
|
* @param draft Draft message, or `null` to delete.
|
|
9
12
|
*/
|
|
10
|
-
export declare function saveDraft(client: ITelegramClient, chatId: InputPeerLike, draft: null |
|
|
13
|
+
export declare function saveDraft(client: ITelegramClient, chatId: InputPeerLike, draft: null | DraftMessageInput): Promise<void>;
|
|
@@ -28,15 +28,11 @@ async function sendCopyGroup(client, params) {
|
|
|
28
28
|
return sendMediaGroup.sendMediaGroup(
|
|
29
29
|
client,
|
|
30
30
|
toChatId,
|
|
31
|
-
msgs.map((msg) => {
|
|
32
|
-
|
|
33
|
-
|
|
34
|
-
|
|
35
|
-
|
|
36
|
-
caption: raw.message,
|
|
37
|
-
entities: raw.entities
|
|
38
|
-
};
|
|
39
|
-
}),
|
|
31
|
+
msgs.map((msg) => ({
|
|
32
|
+
type: "auto",
|
|
33
|
+
file: msg.media.inputMedia,
|
|
34
|
+
caption: msg.textWithEntities
|
|
35
|
+
})),
|
|
40
36
|
rest
|
|
41
37
|
);
|
|
42
38
|
}
|
|
@@ -21,15 +21,11 @@ async function sendCopyGroup(client, params) {
|
|
|
21
21
|
return sendMediaGroup(
|
|
22
22
|
client,
|
|
23
23
|
toChatId,
|
|
24
|
-
msgs.map((msg) => {
|
|
25
|
-
|
|
26
|
-
|
|
27
|
-
|
|
28
|
-
|
|
29
|
-
caption: raw.message,
|
|
30
|
-
entities: raw.entities
|
|
31
|
-
};
|
|
32
|
-
}),
|
|
24
|
+
msgs.map((msg) => ({
|
|
25
|
+
type: "auto",
|
|
26
|
+
file: msg.media.inputMedia,
|
|
27
|
+
caption: msg.textWithEntities
|
|
28
|
+
})),
|
|
33
29
|
rest
|
|
34
30
|
);
|
|
35
31
|
}
|