@mtkruto/node 0.110.0 → 0.111.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/esm/3_types.d.ts +5 -0
- package/esm/3_types.d.ts.map +1 -1
- package/esm/3_types.js +5 -0
- package/esm/client/0_params.d.ts +12 -3
- package/esm/client/0_params.d.ts.map +1 -1
- package/esm/client/1_client_generic.d.ts +13 -3
- package/esm/client/1_client_generic.d.ts.map +1 -1
- package/esm/client/2_context.d.ts +2 -2
- package/esm/client/2_context.d.ts.map +1 -1
- package/esm/client/3_message_manager.d.ts +5 -4
- package/esm/client/3_message_manager.d.ts.map +1 -1
- package/esm/client/3_message_manager.js +73 -27
- package/esm/client/4_chat_manager.d.ts +6 -6
- package/esm/client/4_chat_manager.d.ts.map +1 -1
- package/esm/client/4_chat_manager.js +84 -84
- package/esm/client/5_client.d.ts +13 -3
- package/esm/client/5_client.d.ts.map +1 -1
- package/esm/client/5_client.js +12 -0
- package/esm/client/5_client_dispatcher.d.ts +13 -3
- package/esm/client/5_client_dispatcher.d.ts.map +1 -1
- package/esm/client/5_client_dispatcher.js +12 -0
- package/esm/types/0_checklist_changed.d.ts +29 -0
- package/esm/types/0_checklist_changed.d.ts.map +1 -0
- package/esm/types/0_checklist_changed.js +25 -0
- package/esm/types/3_checklist_item.d.ts +65 -0
- package/esm/types/3_checklist_item.d.ts.map +1 -0
- package/esm/types/3_checklist_item.js +51 -0
- package/esm/types/3_input_checklist_item.d.ts +31 -0
- package/esm/types/3_input_checklist_item.d.ts.map +1 -0
- package/esm/types/3_input_checklist_item.js +20 -0
- package/esm/types/3_input_poll_option.d.ts +31 -0
- package/esm/types/3_input_poll_option.d.ts.map +1 -0
- package/esm/types/3_input_poll_option.js +20 -0
- package/esm/types/4_checklist.d.ts +38 -0
- package/esm/types/4_checklist.d.ts.map +1 -0
- package/esm/types/4_checklist.js +31 -0
- package/esm/types/6_message.d.ts +50 -17
- package/esm/types/6_message.d.ts.map +1 -1
- package/esm/types/6_message.js +19 -1
- package/esm/types/7_inline_query_result.d.ts +1 -1
- package/esm/types/7_inline_query_result.d.ts.map +1 -1
- package/esm/types/7_inline_query_result.js +2 -2
- package/package.json +1 -1
- package/script/3_types.d.ts +5 -0
- package/script/3_types.d.ts.map +1 -1
- package/script/3_types.js +5 -0
- package/script/client/0_params.d.ts +12 -3
- package/script/client/0_params.d.ts.map +1 -1
- package/script/client/1_client_generic.d.ts +13 -3
- package/script/client/1_client_generic.d.ts.map +1 -1
- package/script/client/2_context.d.ts +2 -2
- package/script/client/2_context.d.ts.map +1 -1
- package/script/client/3_message_manager.d.ts +5 -4
- package/script/client/3_message_manager.d.ts.map +1 -1
- package/script/client/3_message_manager.js +73 -27
- package/script/client/4_chat_manager.d.ts +6 -6
- package/script/client/4_chat_manager.d.ts.map +1 -1
- package/script/client/4_chat_manager.js +84 -84
- package/script/client/5_client.d.ts +13 -3
- package/script/client/5_client.d.ts.map +1 -1
- package/script/client/5_client.js +12 -0
- package/script/client/5_client_dispatcher.d.ts +13 -3
- package/script/client/5_client_dispatcher.d.ts.map +1 -1
- package/script/client/5_client_dispatcher.js +12 -0
- package/script/types/0_checklist_changed.d.ts +29 -0
- package/script/types/0_checklist_changed.d.ts.map +1 -0
- package/script/types/0_checklist_changed.js +28 -0
- package/script/types/3_checklist_item.d.ts +65 -0
- package/script/types/3_checklist_item.d.ts.map +1 -0
- package/script/types/3_checklist_item.js +54 -0
- package/script/types/3_input_checklist_item.d.ts +31 -0
- package/script/types/3_input_checklist_item.d.ts.map +1 -0
- package/script/types/3_input_checklist_item.js +21 -0
- package/script/types/3_input_poll_option.d.ts +31 -0
- package/script/types/3_input_poll_option.d.ts.map +1 -0
- package/script/types/3_input_poll_option.js +21 -0
- package/script/types/4_checklist.d.ts +38 -0
- package/script/types/4_checklist.d.ts.map +1 -0
- package/script/types/4_checklist.js +34 -0
- package/script/types/6_message.d.ts +50 -17
- package/script/types/6_message.d.ts.map +1 -1
- package/script/types/6_message.js +19 -1
- package/script/types/7_inline_query_result.d.ts +1 -1
- package/script/types/7_inline_query_result.d.ts.map +1 -1
- package/script/types/7_inline_query_result.js +2 -2
|
@@ -23,9 +23,8 @@ import { encodeText, fromUnixTimestamp, getLogger, getRandomId } from "../1_util
|
|
|
23
23
|
import { Api } from "../2_tl.js";
|
|
24
24
|
import { PackShortNameInvalid } from "../3_errors.js";
|
|
25
25
|
import { getDc } from "../3_transport.js";
|
|
26
|
-
import { constructMessageReactionList, constructMiniAppInfo, constructSavedChats, constructStickerSet, constructVoiceTranscription, deserializeFileId, isMessageType, selfDestructOptionToInt } from "../3_types.js";
|
|
26
|
+
import { constructMessageReactionList, constructMiniAppInfo, constructSavedChats, constructStickerSet, constructVoiceTranscription, deserializeFileId, isMessageType, messageSearchFilterToTlObject, selfDestructOptionToInt } from "../3_types.js";
|
|
27
27
|
import { assertMessageType, constructMessage as constructMessage_, deserializeInlineMessageId, FileType, messageEntityToTlObject, reactionEqual, reactionToTlObject, replyMarkupToTlObject } from "../3_types.js";
|
|
28
|
-
import { messageSearchFilterToTlObject } from "../types/0_message_search_filter.js";
|
|
29
28
|
import { parseHtml } from "./0_html.js";
|
|
30
29
|
import { parseMarkdown } from "./0_markdown.js";
|
|
31
30
|
import { canBeInputChannel, checkArray, checkMessageId, getLimit, getUsername, isHttpUrl, toInputChannel } from "./0_utilities.js";
|
|
@@ -157,9 +156,9 @@ export class MessageManager {
|
|
|
157
156
|
this.#c.storage.assertUser("businessConsendAtnectionId");
|
|
158
157
|
}
|
|
159
158
|
}
|
|
160
|
-
|
|
159
|
+
parseText(text_, params) {
|
|
161
160
|
const [text, entities_] = MessageManager.parseText(text_, params?.entities ?? [], params?.parseMode ?? this.#c.parseMode);
|
|
162
|
-
const entities = entities_?.length > 0 ?
|
|
161
|
+
const entities = entities_?.length > 0 ? entities_.map((v) => messageEntityToTlObject(v, this.#c.getPeer)) : undefined;
|
|
163
162
|
return [text, entities];
|
|
164
163
|
}
|
|
165
164
|
async updatesToMessages(chatId, updates, businessConnectionId) {
|
|
@@ -272,7 +271,7 @@ export class MessageManager {
|
|
|
272
271
|
}
|
|
273
272
|
async sendMessageDraft(chatId, draftId, text, params) {
|
|
274
273
|
this.#c.storage.assertBot("sendMessageDraft");
|
|
275
|
-
const [message, entities] =
|
|
274
|
+
const [message, entities] = this.parseText(text, params);
|
|
276
275
|
const peer = await this.#c.getInputPeer(chatId);
|
|
277
276
|
await this.#c.invoke({
|
|
278
277
|
_: "messages.setTyping",
|
|
@@ -283,7 +282,7 @@ export class MessageManager {
|
|
|
283
282
|
}
|
|
284
283
|
async sendMessage(chatId, text, params) {
|
|
285
284
|
this.#checkParams(params);
|
|
286
|
-
const [message, entities] =
|
|
285
|
+
const [message, entities] = this.parseText(text, params);
|
|
287
286
|
const replyMarkup = await this.#constructReplyMarkup(params);
|
|
288
287
|
const peer = await this.#c.getInputPeer(chatId);
|
|
289
288
|
const randomId = getRandomId();
|
|
@@ -294,7 +293,7 @@ export class MessageManager {
|
|
|
294
293
|
const sendAs = await this.#resolveSendAs(params);
|
|
295
294
|
const effect = params?.effectId ? BigInt(params.effectId) : undefined;
|
|
296
295
|
const schedule_date = params?.sendAt;
|
|
297
|
-
const allow_paid_floodskip = params?.
|
|
296
|
+
const allow_paid_floodskip = params?.isPaidBroadcast ? true : undefined;
|
|
298
297
|
let result;
|
|
299
298
|
if (!noWebpage && params?.linkPreview?.url) {
|
|
300
299
|
result = await this.#c.invoke({
|
|
@@ -393,7 +392,7 @@ export class MessageManager {
|
|
|
393
392
|
message: "",
|
|
394
393
|
effect: params?.effectId ? BigInt(params.effectId) : undefined,
|
|
395
394
|
schedule_date: params?.sendAt,
|
|
396
|
-
allow_paid_floodskip: params?.
|
|
395
|
+
allow_paid_floodskip: params?.isPaidBroadcast ? true : undefined,
|
|
397
396
|
}, { businessConnectionId: params?.businessConnectionId });
|
|
398
397
|
const message = (await this.updatesToMessages(chatId, result, params?.businessConnectionId))[0];
|
|
399
398
|
return assertMessageType(message, "venue");
|
|
@@ -425,7 +424,7 @@ export class MessageManager {
|
|
|
425
424
|
message: "",
|
|
426
425
|
effect: params?.effectId ? BigInt(params.effectId) : undefined,
|
|
427
426
|
schedule_date: params?.sendAt,
|
|
428
|
-
allow_paid_floodskip: params?.
|
|
427
|
+
allow_paid_floodskip: params?.isPaidBroadcast ? true : undefined,
|
|
429
428
|
}, { businessConnectionId: params?.businessConnectionId });
|
|
430
429
|
const message = (await this.updatesToMessages(chatId, result, params?.businessConnectionId))[0];
|
|
431
430
|
return assertMessageType(message, "contact");
|
|
@@ -454,7 +453,7 @@ export class MessageManager {
|
|
|
454
453
|
message: "",
|
|
455
454
|
effect: params?.effectId ? BigInt(params.effectId) : undefined,
|
|
456
455
|
schedule_date: params?.sendAt,
|
|
457
|
-
allow_paid_floodskip: params?.
|
|
456
|
+
allow_paid_floodskip: params?.isPaidBroadcast ? true : undefined,
|
|
458
457
|
}, { businessConnectionId: params?.businessConnectionId });
|
|
459
458
|
const message = (await this.updatesToMessages(chatId, result, params?.businessConnectionId))[0];
|
|
460
459
|
return assertMessageType(message, "dice");
|
|
@@ -501,7 +500,7 @@ export class MessageManager {
|
|
|
501
500
|
message: "",
|
|
502
501
|
effect: params?.effectId ? BigInt(params.effectId) : undefined,
|
|
503
502
|
schedule_date: params?.sendAt,
|
|
504
|
-
allow_paid_floodskip: params?.
|
|
503
|
+
allow_paid_floodskip: params?.isPaidBroadcast ? true : undefined,
|
|
505
504
|
}, { businessConnectionId: params?.businessConnectionId });
|
|
506
505
|
const message = (await this.updatesToMessages(chatId, result, params?.businessConnectionId))[0];
|
|
507
506
|
return assertMessageType(message, "location");
|
|
@@ -682,7 +681,7 @@ export class MessageManager {
|
|
|
682
681
|
const sendAs = params?.sendAs ? await this.#c.getInputPeer(params.sendAs) : undefined;
|
|
683
682
|
const replyMarkup = await this.#constructReplyMarkup(params);
|
|
684
683
|
const caption_ = params?.caption;
|
|
685
|
-
const parseResult = caption_ !== undefined ?
|
|
684
|
+
const parseResult = caption_ !== undefined ? this.parseText(caption_, { parseMode: params?.parseMode, entities: params?.captionEntities }) : undefined;
|
|
686
685
|
const caption = parseResult === undefined ? undefined : parseResult[0];
|
|
687
686
|
const captionEntities = parseResult === undefined ? undefined : parseResult[1];
|
|
688
687
|
const result = await this.#c.invoke({
|
|
@@ -699,7 +698,7 @@ export class MessageManager {
|
|
|
699
698
|
entities: captionEntities,
|
|
700
699
|
effect: params?.effectId ? BigInt(params.effectId) : undefined,
|
|
701
700
|
schedule_date: params?.sendAt,
|
|
702
|
-
allow_paid_floodskip: params?.
|
|
701
|
+
allow_paid_floodskip: params?.isPaidBroadcast ? true : undefined,
|
|
703
702
|
}, { businessConnectionId: params?.businessConnectionId });
|
|
704
703
|
return (await this.updatesToMessages(chatId, result, params?.businessConnectionId))[0];
|
|
705
704
|
}
|
|
@@ -740,16 +739,16 @@ export class MessageManager {
|
|
|
740
739
|
const sendAs = params?.sendAs ? await this.#c.getInputPeer(params.sendAs) : undefined;
|
|
741
740
|
const replyMarkup = await this.#constructReplyMarkup(params);
|
|
742
741
|
const explanation = params?.explanation;
|
|
743
|
-
const parseResult = explanation !== undefined ?
|
|
742
|
+
const parseResult = explanation !== undefined ? this.parseText(explanation, { parseMode: params?.explanationParseMode, entities: params?.explanationEntities }) : undefined;
|
|
744
743
|
const solution = parseResult === undefined ? undefined : parseResult[0];
|
|
745
744
|
const solutionEntities = parseResult === undefined ? undefined : parseResult[1];
|
|
746
|
-
const answers =
|
|
747
|
-
const text =
|
|
748
|
-
const entities =
|
|
749
|
-
const parseResult =
|
|
745
|
+
const answers = options.map((v, i) => {
|
|
746
|
+
const text = v.text;
|
|
747
|
+
const entities = v.entities;
|
|
748
|
+
const parseResult = this.parseText(text, { parseMode: v.parseMode, entities });
|
|
750
749
|
return ({ _: "pollAnswer", option: encodeText(String(i)), text: { _: "textWithEntities", text: parseResult[0], entities: parseResult[1] ?? [] } });
|
|
751
|
-
})
|
|
752
|
-
const questionParseResult =
|
|
750
|
+
});
|
|
751
|
+
const questionParseResult = this.parseText(question, { parseMode: params?.questionParseMode, entities: params?.questionEntities });
|
|
753
752
|
const poll = { _: "poll", id: getRandomId(), answers, question: { _: "textWithEntities", text: questionParseResult[0], entities: questionParseResult[1] ?? [] }, closed: params?.isClosed ? true : undefined, close_date: params?.closeDate, close_period: params?.openPeriod ? params.openPeriod : undefined, multiple_choice: params?.allowMultipleAnswers ? true : undefined, public_voters: params?.isAnonymous === false ? true : undefined, quiz: params?.type === "quiz" ? true : undefined };
|
|
754
753
|
const media = { _: "inputMediaPoll", poll, correct_answers: params?.correctOptionIndex !== undefined ? [encodeText(String(params.correctOptionIndex))] : undefined, solution, solution_entities: solutionEntities };
|
|
755
754
|
const result = await this.#c.invoke({
|
|
@@ -765,11 +764,58 @@ export class MessageManager {
|
|
|
765
764
|
message: "",
|
|
766
765
|
effect: params?.effectId ? BigInt(params.effectId) : undefined,
|
|
767
766
|
schedule_date: params?.sendAt,
|
|
768
|
-
allow_paid_floodskip: params?.
|
|
767
|
+
allow_paid_floodskip: params?.isPaidBroadcast ? true : undefined,
|
|
769
768
|
}, { businessConnectionId: params?.businessConnectionId });
|
|
770
769
|
const message = (await this.updatesToMessages(chatId, result, params?.businessConnectionId))[0];
|
|
771
770
|
return assertMessageType(message, "poll");
|
|
772
771
|
}
|
|
772
|
+
async sendChecklist(chatId, title, items, params) {
|
|
773
|
+
this.#c.storage.assertUser("sendChecklist");
|
|
774
|
+
this.#checkParams(params);
|
|
775
|
+
title = title?.trim();
|
|
776
|
+
if (!title) {
|
|
777
|
+
throw new Error("Title must not be empty.");
|
|
778
|
+
}
|
|
779
|
+
if (!Array.isArray(items) || items.length < 1) {
|
|
780
|
+
throw new Error("There must be at least one item.");
|
|
781
|
+
}
|
|
782
|
+
const peer = await this.#c.getInputPeer(chatId);
|
|
783
|
+
const randomId = getRandomId();
|
|
784
|
+
const silent = params?.isSilent ? true : undefined;
|
|
785
|
+
const noforwards = params?.isContentProtected ? true : undefined;
|
|
786
|
+
const sendAs = params?.sendAs ? await this.#c.getInputPeer(params.sendAs) : undefined;
|
|
787
|
+
const list = items.map((v, i) => {
|
|
788
|
+
const text = v.text;
|
|
789
|
+
const entities = v.entities;
|
|
790
|
+
const parseResult = this.parseText(text, { parseMode: v.parseMode, entities });
|
|
791
|
+
return ({ _: "todoItem", id: i + 1, title: { _: "textWithEntities", text: parseResult[0], entities: parseResult[1] ?? [] } });
|
|
792
|
+
});
|
|
793
|
+
const titleParseResult = this.parseText(title, { parseMode: params?.titleParseMode, entities: params?.titleEntities });
|
|
794
|
+
const todo = {
|
|
795
|
+
_: "todoList",
|
|
796
|
+
title: { _: "textWithEntities", text: titleParseResult[0], entities: titleParseResult[1] ?? [] },
|
|
797
|
+
list,
|
|
798
|
+
others_can_append: params?.isExtendableByOthers ? true : undefined,
|
|
799
|
+
others_can_complete: params?.isCompletableByOthers ? true : undefined,
|
|
800
|
+
};
|
|
801
|
+
const media = { _: "inputMediaTodo", todo };
|
|
802
|
+
const result = await this.#c.invoke({
|
|
803
|
+
_: "messages.sendMedia",
|
|
804
|
+
peer,
|
|
805
|
+
random_id: randomId,
|
|
806
|
+
silent,
|
|
807
|
+
noforwards,
|
|
808
|
+
reply_to: await this.#constructReplyTo(params),
|
|
809
|
+
send_as: sendAs,
|
|
810
|
+
media,
|
|
811
|
+
message: "",
|
|
812
|
+
effect: params?.effectId ? BigInt(params.effectId) : undefined,
|
|
813
|
+
schedule_date: params?.sendAt,
|
|
814
|
+
allow_paid_floodskip: params?.isPaidBroadcast ? true : undefined,
|
|
815
|
+
}, { businessConnectionId: params?.businessConnectionId });
|
|
816
|
+
const message = (await this.updatesToMessages(chatId, result, params?.businessConnectionId))[0];
|
|
817
|
+
return assertMessageType(message, "checklist");
|
|
818
|
+
}
|
|
773
819
|
async editMessageReplyMarkup(chatId, messageId, params) {
|
|
774
820
|
this.#checkParams(params);
|
|
775
821
|
const result = await this.#c.invoke({
|
|
@@ -800,7 +846,7 @@ export class MessageManager {
|
|
|
800
846
|
throw new InputError("The referenced message is not a text message.");
|
|
801
847
|
}
|
|
802
848
|
}
|
|
803
|
-
const [message, entities] =
|
|
849
|
+
const [message, entities] = this.parseText(text, params);
|
|
804
850
|
if (!message) {
|
|
805
851
|
throw new InputError("Message text cannot be empty.");
|
|
806
852
|
}
|
|
@@ -842,7 +888,7 @@ export class MessageManager {
|
|
|
842
888
|
if (!canHaveCaption) {
|
|
843
889
|
throw new InputError("The referenced message cannot have a caption.");
|
|
844
890
|
}
|
|
845
|
-
const [message, entities] =
|
|
891
|
+
const [message, entities] = this.parseText(params?.caption ?? "", params);
|
|
846
892
|
const result = await this.#c.invoke({
|
|
847
893
|
_: "messages.editMessage",
|
|
848
894
|
id: checkMessageId(messageId),
|
|
@@ -855,7 +901,7 @@ export class MessageManager {
|
|
|
855
901
|
}
|
|
856
902
|
async #editInlineMessageTextInner(inlineMessageId, text, params, allowEmpty = true) {
|
|
857
903
|
this.#checkParams(params);
|
|
858
|
-
const [message, entities] =
|
|
904
|
+
const [message, entities] = this.parseText(text, params);
|
|
859
905
|
if (!allowEmpty && !message) {
|
|
860
906
|
throw new InputError("Message text cannot be empty.");
|
|
861
907
|
}
|
|
@@ -1011,7 +1057,7 @@ export class MessageManager {
|
|
|
1011
1057
|
if (!("animation" in message) && !("audio" in message) && !("document" in message) && !("photo" in message) && !("video" in message)) {
|
|
1012
1058
|
throw new InputError("Unexpected message type.");
|
|
1013
1059
|
}
|
|
1014
|
-
const [text, entities] = media.caption !== undefined ?
|
|
1060
|
+
const [text, entities] = media.caption !== undefined ? this.parseText(media.caption, { entities: media.captionEntities, parseMode: media.parseMode }) : ["", []];
|
|
1015
1061
|
const result = await this.#c.invoke({
|
|
1016
1062
|
_: "messages.editMessage",
|
|
1017
1063
|
peer: await this.#c.getInputPeer(chatId),
|
|
@@ -1422,7 +1468,7 @@ export class MessageManager {
|
|
|
1422
1468
|
const multiMedia = new Array();
|
|
1423
1469
|
for (const v of media) {
|
|
1424
1470
|
const randomId = getRandomId();
|
|
1425
|
-
const [message, entities] = v.caption !== undefined ?
|
|
1471
|
+
const [message, entities] = v.caption !== undefined ? this.parseText(v.caption, { entities: v.captionEntities, parseMode: v.parseMode }) : ["", []];
|
|
1426
1472
|
multiMedia.push({ _: "inputSingleMedia", message, entities, random_id: randomId, media: await this.#resolveInputMedia(v) });
|
|
1427
1473
|
}
|
|
1428
1474
|
const peer = await this.#c.getInputPeer(chatId);
|
|
@@ -1450,7 +1496,7 @@ export class MessageManager {
|
|
|
1450
1496
|
silent,
|
|
1451
1497
|
send_as: sendAs,
|
|
1452
1498
|
reply_to: await this.#constructReplyTo(params),
|
|
1453
|
-
allow_paid_floodskip: params?.
|
|
1499
|
+
allow_paid_floodskip: params?.isPaidBroadcast ? true : undefined,
|
|
1454
1500
|
});
|
|
1455
1501
|
return await this.updatesToMessages(chatId, result);
|
|
1456
1502
|
}
|
|
@@ -48,16 +48,14 @@ export declare class ChatManager implements UpdateProcessor<ChatManagerUpdate, t
|
|
|
48
48
|
banChatMember(chatId: ID, memberId: ID, params?: BanChatMemberParams): Promise<void>;
|
|
49
49
|
unbanChatMember(chatId: ID, memberId: ID): Promise<void>;
|
|
50
50
|
setChatMemberRights(chatId: ID, memberId: ID, params?: SetChatMemberRightsParams): Promise<void>;
|
|
51
|
+
promoteChatMember(chatId: ID, userId: ID, params?: PromoteChatMemberParams): Promise<void>;
|
|
52
|
+
setChatMemberTag(chatId: ID, userId: ID, params?: SetChatMemberTagParams): Promise<void>;
|
|
51
53
|
setAvailableReactions(chatId: ID, availableReactions: "none" | "all" | Reaction[]): Promise<void>;
|
|
52
54
|
setBoostsRequiredToCircumventRestrictions(chatId: ID, boosts: number): Promise<void>;
|
|
53
55
|
enableJoinRequests(chatId: ID): Promise<void>;
|
|
54
56
|
disableJoinRequests(chatId: ID): Promise<void>;
|
|
55
57
|
setChatStickerSet(chatId: ID, setName: string): Promise<void>;
|
|
56
58
|
deleteChatStickerSet(chatId: ID): Promise<void>;
|
|
57
|
-
deleteChatPhoto(chatId: ID): Promise<void>;
|
|
58
|
-
setChatPhoto(chatId: ID, photo: FileSource, params?: SetChatPhotoParams): Promise<void>;
|
|
59
|
-
addChatMember(chatId: ID, userId: ID, params?: AddChatMemberParams): Promise<import("../3_types.js").FailedInvitation[]>;
|
|
60
|
-
addChatMembers(chatId: ID, userIds: ID[]): Promise<import("../3_types.js").FailedInvitation[]>;
|
|
61
59
|
disableSlowMode(chatId: ID): Promise<void>;
|
|
62
60
|
setSlowMode(chatId: ID, duration: SlowModeDuration): Promise<void>;
|
|
63
61
|
setChatTitle(chatId: ID, title: string): Promise<void>;
|
|
@@ -74,10 +72,12 @@ export declare class ChatManager implements UpdateProcessor<ChatManagerUpdate, t
|
|
|
74
72
|
getDiscussionChatSuggestions(): Promise<ChatP[]>;
|
|
75
73
|
setDiscussionChat(chatId: ID, discussionChatId: ID): Promise<void>;
|
|
76
74
|
transferChatOwnership(chatId: ID, userId: ID, password: string): Promise<void>;
|
|
77
|
-
promoteChatMember(chatId: ID, userId: ID, params?: PromoteChatMemberParams): Promise<void>;
|
|
78
|
-
setChatMemberTag(chatId: ID, userId: ID, params?: SetChatMemberTagParams): Promise<void>;
|
|
79
75
|
enableSharing(chatId: ID): Promise<void>;
|
|
80
76
|
disableSharing(chatId: ID): Promise<void>;
|
|
77
|
+
deleteChatPhoto(chatId: ID): Promise<void>;
|
|
78
|
+
setChatPhoto(chatId: ID, photo: FileSource, params?: SetChatPhotoParams): Promise<void>;
|
|
79
|
+
addChatMember(chatId: ID, userId: ID, params?: AddChatMemberParams): Promise<import("../3_types.js").FailedInvitation[]>;
|
|
80
|
+
addChatMembers(chatId: ID, userIds: ID[]): Promise<import("../3_types.js").FailedInvitation[]>;
|
|
81
81
|
}
|
|
82
82
|
export {};
|
|
83
83
|
//# sourceMappingURL=4_chat_manager.d.ts.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"4_chat_manager.d.ts","sourceRoot":"","sources":["../../src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C,MAAM,EAAE,EAAE,EAAE,WAAW,EAAE,MAAM;IAclD,cAAc,CAAC,MAAM,EAAE,EAAE;IAKzB,cAAc,CAAC,MAAM,EAAE,EAAE;IAUzB,aAAa,CAAC,MAAM,EAAE,EAAE;IAKxB,YAAY,CAAC,MAAM,EAAE,EAAE,EAAE,aAAa,EAAE,OAAO;IAU/C,cAAc,CAAC,MAAM,EAAE,EAAE;IAKzB,eAAe,CAAC,MAAM,EAAE,EAAE;IAU1B,gBAAgB,CAAC,MAAM,EAAE,EAAE,EAAE,MAAM,CAAC,EAAE,sBAAsB;IAK5D,iBAAiB,CAAC,MAAM,EAAE,EAAE;IAK5B,UAAU,CAAC,MAAM,EAAE,EAAE;IAarB,4BAA4B;IAc5B,iBAAiB,CAAC,MAAM,EAAE,EAAE,EAAE,gBAAgB,EAAE,EAAE;IAMlD,qBAAqB,CAAC,MAAM,EAAE,EAAE,EAAE,MAAM,EAAE,EAAE,EAAE,QAAQ,EAAE,MAAM;IAkB9D,aAAa,CAAC,MAAM,EAAE,EAAE;IAKxB,cAAc,CAAC,MAAM,EAAE,EAAE;IAMzB,eAAe,CAAC,MAAM,EAAE,EAAE;IAa1B,YAAY,CAAC,MAAM,EAAE,EAAE,EAAE,KAAK,EAAE,UAAU,EAAE,MAAM,CAAC,EAAE,kBAAkB,GAAG,OAAO,CAAC,IAAI,CAAC;IAiBvF,aAAa,CAAC,MAAM,EAAE,EAAE,EAAE,MAAM,EAAE,EAAE,EAAE,MAAM,CAAC,EAAE,mBAAmB;IAiBlE,cAAc,CAAC,MAAM,EAAE,EAAE,EAAE,OAAO,EAAE,EAAE,EAAE;CAkB/C"}
|
|
@@ -157,7 +157,7 @@ export class ChatManager {
|
|
|
157
157
|
unreachable();
|
|
158
158
|
}
|
|
159
159
|
}
|
|
160
|
-
//
|
|
160
|
+
// CHAT MEMBERS //
|
|
161
161
|
async banChatMember(chatId, memberId, params) {
|
|
162
162
|
const chat = await this.#c.getInputPeer(chatId);
|
|
163
163
|
if (!(Api.is("inputPeerChannel", chat)) && !(Api.is("inputPeerChat", chat))) {
|
|
@@ -208,6 +208,25 @@ export class ChatManager {
|
|
|
208
208
|
const member = await this.#c.getInputPeer(memberId);
|
|
209
209
|
await this.#c.invoke({ _: "channels.editBanned", channel, participant: member, banned_rights: chatMemberRightsToTlObject(params?.rights, params?.until) });
|
|
210
210
|
}
|
|
211
|
+
async promoteChatMember(chatId, userId, params) {
|
|
212
|
+
const channel = await this.#c.getInputChannel(chatId);
|
|
213
|
+
const user_id = await this.#c.getInputUser(userId);
|
|
214
|
+
const admin_rights = chatAdministratorRightsToTlObject(params ?? {});
|
|
215
|
+
const rank = params?.title ?? "";
|
|
216
|
+
await this.#c.invoke({
|
|
217
|
+
_: "channels.editAdmin",
|
|
218
|
+
channel,
|
|
219
|
+
user_id,
|
|
220
|
+
admin_rights,
|
|
221
|
+
rank,
|
|
222
|
+
});
|
|
223
|
+
}
|
|
224
|
+
async setChatMemberTag(chatId, userId, params) {
|
|
225
|
+
const peer = await this.#c.getInputPeer(chatId);
|
|
226
|
+
const participant = await this.#c.getInputPeer(userId);
|
|
227
|
+
const rank = params?.tag ?? "";
|
|
228
|
+
await this.#c.invoke({ _: "messages.editChatParticipantRank", peer, participant, rank });
|
|
229
|
+
}
|
|
211
230
|
// CHAT SETTINGS //
|
|
212
231
|
async setAvailableReactions(chatId, availableReactions) {
|
|
213
232
|
await this.#c.invoke({ _: "messages.setChatAvailableReactions", peer: await this.#c.getInputPeer(chatId), available_reactions: availableReactions === "none" ? { _: "chatReactionsNone" } : availableReactions === "all" ? { _: "chatReactionsAll" } : Array.isArray(availableReactions) ? ({ _: "chatReactionsSome", reactions: availableReactions.map((v) => reactionToTlObject(v)) }) : unreachable() });
|
|
@@ -233,70 +252,6 @@ export class ChatManager {
|
|
|
233
252
|
const channel = await this.#c.getInputChannel(chatId);
|
|
234
253
|
await this.#c.invoke({ _: "channels.setStickers", channel, stickerset: { _: "inputStickerSetEmpty" } });
|
|
235
254
|
}
|
|
236
|
-
// CHAT PHOTOS //
|
|
237
|
-
async deleteChatPhoto(chatId) {
|
|
238
|
-
const peer = await this.#c.getInputPeer(chatId);
|
|
239
|
-
if (!(canBeInputChannel(peer)) && !(Api.is("inputPeerChat", peer))) {
|
|
240
|
-
unreachable();
|
|
241
|
-
}
|
|
242
|
-
if (canBeInputChannel(peer)) {
|
|
243
|
-
await this.#c.invoke({ _: "channels.editPhoto", channel: toInputChannel(peer), photo: { _: "inputChatPhotoEmpty" } });
|
|
244
|
-
}
|
|
245
|
-
else if (Api.is("inputPeerChat", peer)) {
|
|
246
|
-
await this.#c.invoke({ _: "messages.editChatPhoto", chat_id: peer.chat_id, photo: { _: "inputChatPhotoEmpty" } });
|
|
247
|
-
}
|
|
248
|
-
}
|
|
249
|
-
async setChatPhoto(chatId, photo, params) {
|
|
250
|
-
const peer = await this.#c.getInputPeer(chatId);
|
|
251
|
-
if (!(canBeInputChannel(peer)) && !(Api.is("inputPeerChat", peer))) {
|
|
252
|
-
unreachable();
|
|
253
|
-
}
|
|
254
|
-
const file = await this.#c.fileManager.upload(photo, params);
|
|
255
|
-
const photo_ = { _: "inputChatUploadedPhoto", file };
|
|
256
|
-
if (canBeInputChannel(peer)) {
|
|
257
|
-
await this.#c.invoke({ _: "channels.editPhoto", channel: toInputChannel(peer), photo: photo_ });
|
|
258
|
-
}
|
|
259
|
-
else if (Api.is("inputPeerChat", peer)) {
|
|
260
|
-
await this.#c.invoke({ _: "messages.editChatPhoto", chat_id: peer.chat_id, photo: photo_ });
|
|
261
|
-
}
|
|
262
|
-
}
|
|
263
|
-
// INVITING MEMBERS //
|
|
264
|
-
async addChatMember(chatId, userId, params) {
|
|
265
|
-
this.#c.storage.assertUser("addChatMember");
|
|
266
|
-
const chat = await this.#c.getInputPeer(chatId);
|
|
267
|
-
if (Api.isOneOf(["inputPeerEmpty", "inputPeerSelf", "inputPeerUser", "inputPeerUserFromMessage"], chat)) {
|
|
268
|
-
throw new InputError("Cannot add members to private chats");
|
|
269
|
-
}
|
|
270
|
-
const user = await this.#c.getInputUser(userId);
|
|
271
|
-
if (Api.is("inputPeerChat", chat)) {
|
|
272
|
-
const result = await this.#c.invoke({ _: "messages.addChatUser", chat_id: chat.chat_id, user_id: user, fwd_limit: params?.historyLimit ?? 0 });
|
|
273
|
-
return result.missing_invitees.map(constructFailedInvitation);
|
|
274
|
-
}
|
|
275
|
-
else if (Api.is("inputPeerChannel", chat)) {
|
|
276
|
-
const result = await this.#c.invoke({ _: "channels.inviteToChannel", channel: { ...chat, _: "inputChannel" }, users: [user] });
|
|
277
|
-
return result.missing_invitees.map(constructFailedInvitation);
|
|
278
|
-
}
|
|
279
|
-
unreachable();
|
|
280
|
-
}
|
|
281
|
-
async addChatMembers(chatId, userIds) {
|
|
282
|
-
this.#c.storage.assertUser("addChatMembers");
|
|
283
|
-
const chat = await this.#c.getInputPeer(chatId);
|
|
284
|
-
if (Api.isOneOf(["inputPeerEmpty", "inputPeerSelf", "inputPeerUser", "inputPeerUserFromMessage"], chat)) {
|
|
285
|
-
throw new InputError("Cannot add members to private chats");
|
|
286
|
-
}
|
|
287
|
-
const users = new Array();
|
|
288
|
-
for (const userId of userIds) {
|
|
289
|
-
users.push(await this.#c.getInputUser(userId));
|
|
290
|
-
}
|
|
291
|
-
if (Api.is("inputPeerChat", chat)) {
|
|
292
|
-
throw new InputError("addChatMembers cannot be used with basic groups");
|
|
293
|
-
}
|
|
294
|
-
else if (canBeInputChannel(chat)) {
|
|
295
|
-
const result = await this.#c.invoke({ _: "channels.inviteToChannel", channel: toInputChannel(chat), users });
|
|
296
|
-
return result.missing_invitees.map(constructFailedInvitation);
|
|
297
|
-
}
|
|
298
|
-
unreachable();
|
|
299
|
-
}
|
|
300
255
|
async #toggleSlowMode(chatId, seconds) {
|
|
301
256
|
const channel = await this.#c.getInputChannel(chatId);
|
|
302
257
|
await this.#c.invoke({ _: "channels.toggleSlowMode", channel, seconds });
|
|
@@ -427,25 +382,6 @@ export class ChatManager {
|
|
|
427
382
|
const password_ = await checkPassword(password, ap);
|
|
428
383
|
await this.#c.invoke({ _: "messages.editChatCreator", peer, user_id, password: password_ });
|
|
429
384
|
}
|
|
430
|
-
async promoteChatMember(chatId, userId, params) {
|
|
431
|
-
const channel = await this.#c.getInputChannel(chatId);
|
|
432
|
-
const user_id = await this.#c.getInputUser(userId);
|
|
433
|
-
const admin_rights = chatAdministratorRightsToTlObject(params ?? {});
|
|
434
|
-
const rank = params?.title ?? "";
|
|
435
|
-
await this.#c.invoke({
|
|
436
|
-
_: "channels.editAdmin",
|
|
437
|
-
channel,
|
|
438
|
-
user_id,
|
|
439
|
-
admin_rights,
|
|
440
|
-
rank,
|
|
441
|
-
});
|
|
442
|
-
}
|
|
443
|
-
async setChatMemberTag(chatId, userId, params) {
|
|
444
|
-
const peer = await this.#c.getInputPeer(chatId);
|
|
445
|
-
const participant = await this.#c.getInputPeer(userId);
|
|
446
|
-
const rank = params?.tag ?? "";
|
|
447
|
-
await this.#c.invoke({ _: "messages.editChatParticipantRank", peer, participant, rank });
|
|
448
|
-
}
|
|
449
385
|
async #setIsSharingEnabled(chatId, isSharingEnabled) {
|
|
450
386
|
const peer = await this.#c.getInputPeer(chatId);
|
|
451
387
|
await this.#c.invoke({ _: "messages.toggleNoForwards", peer, enabled: !isSharingEnabled });
|
|
@@ -458,4 +394,68 @@ export class ChatManager {
|
|
|
458
394
|
this.#c.storage.assertUser("disableSharing");
|
|
459
395
|
await this.#setIsSharingEnabled(chatId, false);
|
|
460
396
|
}
|
|
397
|
+
// CHAT PHOTOS //
|
|
398
|
+
async deleteChatPhoto(chatId) {
|
|
399
|
+
const peer = await this.#c.getInputPeer(chatId);
|
|
400
|
+
if (!(canBeInputChannel(peer)) && !(Api.is("inputPeerChat", peer))) {
|
|
401
|
+
unreachable();
|
|
402
|
+
}
|
|
403
|
+
if (canBeInputChannel(peer)) {
|
|
404
|
+
await this.#c.invoke({ _: "channels.editPhoto", channel: toInputChannel(peer), photo: { _: "inputChatPhotoEmpty" } });
|
|
405
|
+
}
|
|
406
|
+
else if (Api.is("inputPeerChat", peer)) {
|
|
407
|
+
await this.#c.invoke({ _: "messages.editChatPhoto", chat_id: peer.chat_id, photo: { _: "inputChatPhotoEmpty" } });
|
|
408
|
+
}
|
|
409
|
+
}
|
|
410
|
+
async setChatPhoto(chatId, photo, params) {
|
|
411
|
+
const peer = await this.#c.getInputPeer(chatId);
|
|
412
|
+
if (!(canBeInputChannel(peer)) && !(Api.is("inputPeerChat", peer))) {
|
|
413
|
+
unreachable();
|
|
414
|
+
}
|
|
415
|
+
const file = await this.#c.fileManager.upload(photo, params);
|
|
416
|
+
const photo_ = { _: "inputChatUploadedPhoto", file };
|
|
417
|
+
if (canBeInputChannel(peer)) {
|
|
418
|
+
await this.#c.invoke({ _: "channels.editPhoto", channel: toInputChannel(peer), photo: photo_ });
|
|
419
|
+
}
|
|
420
|
+
else if (Api.is("inputPeerChat", peer)) {
|
|
421
|
+
await this.#c.invoke({ _: "messages.editChatPhoto", chat_id: peer.chat_id, photo: photo_ });
|
|
422
|
+
}
|
|
423
|
+
}
|
|
424
|
+
// INVITING MEMBERS //
|
|
425
|
+
async addChatMember(chatId, userId, params) {
|
|
426
|
+
this.#c.storage.assertUser("addChatMember");
|
|
427
|
+
const chat = await this.#c.getInputPeer(chatId);
|
|
428
|
+
if (Api.isOneOf(["inputPeerEmpty", "inputPeerSelf", "inputPeerUser", "inputPeerUserFromMessage"], chat)) {
|
|
429
|
+
throw new InputError("Cannot add members to private chats");
|
|
430
|
+
}
|
|
431
|
+
const user = await this.#c.getInputUser(userId);
|
|
432
|
+
if (Api.is("inputPeerChat", chat)) {
|
|
433
|
+
const result = await this.#c.invoke({ _: "messages.addChatUser", chat_id: chat.chat_id, user_id: user, fwd_limit: params?.historyLimit ?? 0 });
|
|
434
|
+
return result.missing_invitees.map(constructFailedInvitation);
|
|
435
|
+
}
|
|
436
|
+
else if (Api.is("inputPeerChannel", chat)) {
|
|
437
|
+
const result = await this.#c.invoke({ _: "channels.inviteToChannel", channel: { ...chat, _: "inputChannel" }, users: [user] });
|
|
438
|
+
return result.missing_invitees.map(constructFailedInvitation);
|
|
439
|
+
}
|
|
440
|
+
unreachable();
|
|
441
|
+
}
|
|
442
|
+
async addChatMembers(chatId, userIds) {
|
|
443
|
+
this.#c.storage.assertUser("addChatMembers");
|
|
444
|
+
const chat = await this.#c.getInputPeer(chatId);
|
|
445
|
+
if (Api.isOneOf(["inputPeerEmpty", "inputPeerSelf", "inputPeerUser", "inputPeerUserFromMessage"], chat)) {
|
|
446
|
+
throw new InputError("Cannot add members to private chats");
|
|
447
|
+
}
|
|
448
|
+
const users = new Array();
|
|
449
|
+
for (const userId of userIds) {
|
|
450
|
+
users.push(await this.#c.getInputUser(userId));
|
|
451
|
+
}
|
|
452
|
+
if (Api.is("inputPeerChat", chat)) {
|
|
453
|
+
throw new InputError("addChatMembers cannot be used with basic groups");
|
|
454
|
+
}
|
|
455
|
+
else if (canBeInputChannel(chat)) {
|
|
456
|
+
const result = await this.#c.invoke({ _: "channels.inviteToChannel", channel: toInputChannel(chat), users });
|
|
457
|
+
return result.missing_invitees.map(constructFailedInvitation);
|
|
458
|
+
}
|
|
459
|
+
unreachable();
|
|
460
|
+
}
|
|
461
461
|
}
|
package/esm/client/5_client.d.ts
CHANGED
|
@@ -20,10 +20,10 @@
|
|
|
20
20
|
import { type Storage } from "../2_storage.js";
|
|
21
21
|
import { Api, Mtproto } from "../2_tl.js";
|
|
22
22
|
import { type DC } from "../3_transport.js";
|
|
23
|
-
import { type BotCommand, type BotTokenCheckResult, type BusinessConnection, type CallbackQueryAnswer, type CallbackQueryQuestion, type Chat, type ChatAction, type ChatListItem, type ChatMember, type ChatP, type ChatPChannel, type ChatPGroup, type ChatPSupergroup, type ChatSettings, type ClaimedGifts, type FailedInvitation, type FileSource, type Gift, type ID, type InactiveChat, type InlineQueryAnswer, type InlineQueryResult, type InputGift, type InputMedia, type InputStoryContent, type InviteLink, type JoinRequest, type LinkPreview, type LiveStreamChannel, type Message, type MessageAnimation, type MessageAudio, type MessageContact, type MessageDice, type MessageDocument, type MessageInvoice, type MessageList, type MessageLocation, type MessagePhoto, type MessagePoll, type MessageReactionList, type MessageSticker, type MessageText, type MessageVenue, type MessageVideo, type MessageVideoNote, type MessageVoice, type MiniAppInfo, type NetworkStatistics, type ParseMode, type PasswordCheckResult, type Poll, type PriceTag, type Reaction, type SavedChats, type SlowModeDuration, type Sticker, type StickerSet, type Story, type Topic, type Translation, type User, type VideoChat, type VideoChatActive, type VideoChatScheduled, type VoiceTranscription } from "../3_types.js";
|
|
23
|
+
import { type BotCommand, type BotTokenCheckResult, type BusinessConnection, type CallbackQueryAnswer, type CallbackQueryQuestion, type Chat, type ChatAction, type ChatListItem, type ChatMember, type ChatP, type ChatPChannel, type ChatPGroup, type ChatPSupergroup, type ChatSettings, type ClaimedGifts, type FailedInvitation, type FileSource, type Gift, type ID, type InactiveChat, type InlineQueryAnswer, type InlineQueryResult, type InputChecklistItem, type InputGift, type InputMedia, type InputPollOption, type InputStoryContent, type InviteLink, type JoinRequest, type LinkPreview, type LiveStreamChannel, type Message, type MessageAnimation, type MessageAudio, type MessageChecklist, type MessageContact, type MessageDice, type MessageDocument, type MessageInvoice, type MessageList, type MessageLocation, type MessagePhoto, type MessagePoll, type MessageReactionList, type MessageSticker, type MessageText, type MessageVenue, type MessageVideo, type MessageVideoNote, type MessageVoice, type MiniAppInfo, type NetworkStatistics, type ParseMode, type PasswordCheckResult, type Poll, type PriceTag, type Reaction, type SavedChats, type SlowModeDuration, type Sticker, type StickerSet, type Story, type Topic, type Translation, type User, type VideoChat, type VideoChatActive, type VideoChatScheduled, type VoiceTranscription } from "../3_types.js";
|
|
24
24
|
import { Migrate } from "../4_errors.js";
|
|
25
25
|
import type { CodeCheckResult } from "../types/0_code_check_result.js";
|
|
26
|
-
import type { AddChatMemberParams, AddContactParams, AddReactionParams, AnswerCallbackQueryParams, AnswerInlineQueryParams, AnswerPreCheckoutQueryParams, ApproveJoinRequestsParams, BanChatMemberParams, CheckUsernameParams, CreateChannelParams, CreateGroupParams, CreateInviteLinkParams, CreateStoryParams, CreateSupergroupParams, CreateTopicParams, DeclineJoinRequestsParams, DeleteMessageParams, DeleteMessagesParams, DownloadLiveStreamSegmentParams, DownloadParams, EditInlineMessageCaptionParams, EditInlineMessageMediaParams, EditInlineMessageTextParams, EditMessageCaptionParams, EditMessageLiveLocationParams, EditMessageMediaParams, EditMessageReplyMarkupParams, EditMessageTextParams, EditTopicParams, EnableSignaturesParams, ForwardMessagesParams, GetChatMembersParams, GetChatsParams, GetClaimedGiftsParams, GetCommonChatsParams, GetCreatedInviteLinksParams, GetHistoryParams, GetJoinRequestsParams, GetLinkPreviewParams, GetMessageReactionsParams, GetMyCommandsParams, GetSavedChatsParams, GetSavedMessagesParams, GetTranslationsParams, InvokeParams, JoinVideoChatParams, OpenChatParams, OpenMiniAppParams, PinMessageParams, PromoteChatMemberParams, ScheduleVideoChatParams, SearchMessagesParams, SendAnimationParams, SendAudioParams, SendContactParams, SendDiceParams, SendDocumentParams, SendGiftParams, SendInlineQueryParams, SendInvoiceParams, SendLocationParams, SendMediaGroupParams, SendMessageDraftParams, SendMessageParams, SendPhotoParams, SendPollParams, SendStickerParams, SendVenueParams, SendVideoNoteParams, SendVideoParams, SendVoiceParams, SetBirthdayParams, SetChatMemberRightsParams, SetChatMemberTagParams, SetChatPhotoParams, SetEmojiStatusParams, SetLocationParams, SetMyCommandsParams, SetNameColorParams, SetPersonalChannelParams, SetProfileColorParams, SetReactionsParams, SetWorkingHoursParams, SignInParams, StartBotParams, StartVideoChatParams, StopPollParams, UnpinMessageParams, UpdateProfileParams } from "./0_params.js";
|
|
26
|
+
import type { AddChatMemberParams, AddContactParams, AddReactionParams, AnswerCallbackQueryParams, AnswerInlineQueryParams, AnswerPreCheckoutQueryParams, ApproveJoinRequestsParams, BanChatMemberParams, CheckUsernameParams, CreateChannelParams, CreateGroupParams, CreateInviteLinkParams, CreateStoryParams, CreateSupergroupParams, CreateTopicParams, DeclineJoinRequestsParams, DeleteMessageParams, DeleteMessagesParams, DownloadLiveStreamSegmentParams, DownloadParams, EditInlineMessageCaptionParams, EditInlineMessageMediaParams, EditInlineMessageTextParams, EditMessageCaptionParams, EditMessageLiveLocationParams, EditMessageMediaParams, EditMessageReplyMarkupParams, EditMessageTextParams, EditTopicParams, EnableSignaturesParams, ForwardMessagesParams, GetChatMembersParams, GetChatsParams, GetClaimedGiftsParams, GetCommonChatsParams, GetCreatedInviteLinksParams, GetHistoryParams, GetJoinRequestsParams, GetLinkPreviewParams, GetMessageReactionsParams, GetMyCommandsParams, GetSavedChatsParams, GetSavedMessagesParams, GetTranslationsParams, InvokeParams, JoinVideoChatParams, OpenChatParams, OpenMiniAppParams, PinMessageParams, PromoteChatMemberParams, ScheduleVideoChatParams, SearchMessagesParams, SendAnimationParams, SendAudioParams, SendChecklistParams, SendContactParams, SendDiceParams, SendDocumentParams, SendGiftParams, SendInlineQueryParams, SendInvoiceParams, SendLocationParams, SendMediaGroupParams, SendMessageDraftParams, SendMessageParams, SendPhotoParams, SendPollParams, SendStickerParams, SendVenueParams, SendVideoNoteParams, SendVideoParams, SendVoiceParams, SetBirthdayParams, SetChatMemberRightsParams, SetChatMemberTagParams, SetChatPhotoParams, SetEmojiStatusParams, SetLocationParams, SetMyCommandsParams, SetNameColorParams, SetPersonalChannelParams, SetProfileColorParams, SetReactionsParams, SetWorkingHoursParams, SignInParams, StartBotParams, StartVideoChatParams, StopPollParams, UnpinMessageParams, UpdateProfileParams } from "./0_params.js";
|
|
27
27
|
import { StorageOperations } from "./0_storage_operations.js";
|
|
28
28
|
import type { ClientGeneric } from "./1_client_generic.js";
|
|
29
29
|
import type { ClientPlainParams } from "./1_client_plain.js";
|
|
@@ -507,7 +507,17 @@ export declare class Client<C extends Context = Context> extends Composer<C> imp
|
|
|
507
507
|
* @param options The poll's options.
|
|
508
508
|
* @returns The sent poll.
|
|
509
509
|
*/
|
|
510
|
-
sendPoll(chatId: ID, question: string, options:
|
|
510
|
+
sendPoll(chatId: ID, question: string, options: InputPollOption[], params?: SendPollParams): Promise<MessagePoll>;
|
|
511
|
+
/**
|
|
512
|
+
* Send a checklist. User-only.
|
|
513
|
+
*
|
|
514
|
+
* @method ms
|
|
515
|
+
* @param chatId The identifier of a chat to send the checklist to.
|
|
516
|
+
* @param title The checklist's title.
|
|
517
|
+
* @param items The checklist's items.
|
|
518
|
+
* @returns The sent checklist.
|
|
519
|
+
*/
|
|
520
|
+
sendChecklist(chatId: ID, title: string, items: InputChecklistItem[], params?: SendChecklistParams): Promise<MessageChecklist>;
|
|
511
521
|
/**
|
|
512
522
|
* Send an invoice. Bot-only.
|
|
513
523
|
*
|