@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.
Files changed (85) hide show
  1. package/esm/3_types.d.ts +5 -0
  2. package/esm/3_types.d.ts.map +1 -1
  3. package/esm/3_types.js +5 -0
  4. package/esm/client/0_params.d.ts +12 -3
  5. package/esm/client/0_params.d.ts.map +1 -1
  6. package/esm/client/1_client_generic.d.ts +13 -3
  7. package/esm/client/1_client_generic.d.ts.map +1 -1
  8. package/esm/client/2_context.d.ts +2 -2
  9. package/esm/client/2_context.d.ts.map +1 -1
  10. package/esm/client/3_message_manager.d.ts +5 -4
  11. package/esm/client/3_message_manager.d.ts.map +1 -1
  12. package/esm/client/3_message_manager.js +73 -27
  13. package/esm/client/4_chat_manager.d.ts +6 -6
  14. package/esm/client/4_chat_manager.d.ts.map +1 -1
  15. package/esm/client/4_chat_manager.js +84 -84
  16. package/esm/client/5_client.d.ts +13 -3
  17. package/esm/client/5_client.d.ts.map +1 -1
  18. package/esm/client/5_client.js +12 -0
  19. package/esm/client/5_client_dispatcher.d.ts +13 -3
  20. package/esm/client/5_client_dispatcher.d.ts.map +1 -1
  21. package/esm/client/5_client_dispatcher.js +12 -0
  22. package/esm/types/0_checklist_changed.d.ts +29 -0
  23. package/esm/types/0_checklist_changed.d.ts.map +1 -0
  24. package/esm/types/0_checklist_changed.js +25 -0
  25. package/esm/types/3_checklist_item.d.ts +65 -0
  26. package/esm/types/3_checklist_item.d.ts.map +1 -0
  27. package/esm/types/3_checklist_item.js +51 -0
  28. package/esm/types/3_input_checklist_item.d.ts +31 -0
  29. package/esm/types/3_input_checklist_item.d.ts.map +1 -0
  30. package/esm/types/3_input_checklist_item.js +20 -0
  31. package/esm/types/3_input_poll_option.d.ts +31 -0
  32. package/esm/types/3_input_poll_option.d.ts.map +1 -0
  33. package/esm/types/3_input_poll_option.js +20 -0
  34. package/esm/types/4_checklist.d.ts +38 -0
  35. package/esm/types/4_checklist.d.ts.map +1 -0
  36. package/esm/types/4_checklist.js +31 -0
  37. package/esm/types/6_message.d.ts +50 -17
  38. package/esm/types/6_message.d.ts.map +1 -1
  39. package/esm/types/6_message.js +19 -1
  40. package/esm/types/7_inline_query_result.d.ts +1 -1
  41. package/esm/types/7_inline_query_result.d.ts.map +1 -1
  42. package/esm/types/7_inline_query_result.js +2 -2
  43. package/package.json +1 -1
  44. package/script/3_types.d.ts +5 -0
  45. package/script/3_types.d.ts.map +1 -1
  46. package/script/3_types.js +5 -0
  47. package/script/client/0_params.d.ts +12 -3
  48. package/script/client/0_params.d.ts.map +1 -1
  49. package/script/client/1_client_generic.d.ts +13 -3
  50. package/script/client/1_client_generic.d.ts.map +1 -1
  51. package/script/client/2_context.d.ts +2 -2
  52. package/script/client/2_context.d.ts.map +1 -1
  53. package/script/client/3_message_manager.d.ts +5 -4
  54. package/script/client/3_message_manager.d.ts.map +1 -1
  55. package/script/client/3_message_manager.js +73 -27
  56. package/script/client/4_chat_manager.d.ts +6 -6
  57. package/script/client/4_chat_manager.d.ts.map +1 -1
  58. package/script/client/4_chat_manager.js +84 -84
  59. package/script/client/5_client.d.ts +13 -3
  60. package/script/client/5_client.d.ts.map +1 -1
  61. package/script/client/5_client.js +12 -0
  62. package/script/client/5_client_dispatcher.d.ts +13 -3
  63. package/script/client/5_client_dispatcher.d.ts.map +1 -1
  64. package/script/client/5_client_dispatcher.js +12 -0
  65. package/script/types/0_checklist_changed.d.ts +29 -0
  66. package/script/types/0_checklist_changed.d.ts.map +1 -0
  67. package/script/types/0_checklist_changed.js +28 -0
  68. package/script/types/3_checklist_item.d.ts +65 -0
  69. package/script/types/3_checklist_item.d.ts.map +1 -0
  70. package/script/types/3_checklist_item.js +54 -0
  71. package/script/types/3_input_checklist_item.d.ts +31 -0
  72. package/script/types/3_input_checklist_item.d.ts.map +1 -0
  73. package/script/types/3_input_checklist_item.js +21 -0
  74. package/script/types/3_input_poll_option.d.ts +31 -0
  75. package/script/types/3_input_poll_option.d.ts.map +1 -0
  76. package/script/types/3_input_poll_option.js +21 -0
  77. package/script/types/4_checklist.d.ts +38 -0
  78. package/script/types/4_checklist.d.ts.map +1 -0
  79. package/script/types/4_checklist.js +34 -0
  80. package/script/types/6_message.d.ts +50 -17
  81. package/script/types/6_message.d.ts.map +1 -1
  82. package/script/types/6_message.js +19 -1
  83. package/script/types/7_inline_query_result.d.ts +1 -1
  84. package/script/types/7_inline_query_result.d.ts.map +1 -1
  85. package/script/types/7_inline_query_result.js +2 -2
@@ -28,7 +28,6 @@ const _3_errors_js_1 = require("../3_errors.js");
28
28
  const _3_transport_js_1 = require("../3_transport.js");
29
29
  const _3_types_js_1 = require("../3_types.js");
30
30
  const _3_types_js_2 = require("../3_types.js");
31
- const _0_message_search_filter_js_1 = require("../types/0_message_search_filter.js");
32
31
  const _0_html_js_1 = require("./0_html.js");
33
32
  const _0_markdown_js_1 = require("./0_markdown.js");
34
33
  const _0_utilities_js_1 = require("./0_utilities.js");
@@ -160,9 +159,9 @@ class MessageManager {
160
159
  this.#c.storage.assertUser("businessConsendAtnectionId");
161
160
  }
162
161
  }
163
- async parseText(text_, params) {
162
+ parseText(text_, params) {
164
163
  const [text, entities_] = MessageManager.parseText(text_, params?.entities ?? [], params?.parseMode ?? this.#c.parseMode);
165
- const entities = entities_?.length > 0 ? await Promise.all(entities_.map((v) => (0, _3_types_js_2.messageEntityToTlObject)(v, this.#c.getPeer))) : undefined;
164
+ const entities = entities_?.length > 0 ? entities_.map((v) => (0, _3_types_js_2.messageEntityToTlObject)(v, this.#c.getPeer)) : undefined;
166
165
  return [text, entities];
167
166
  }
168
167
  async updatesToMessages(chatId, updates, businessConnectionId) {
@@ -275,7 +274,7 @@ class MessageManager {
275
274
  }
276
275
  async sendMessageDraft(chatId, draftId, text, params) {
277
276
  this.#c.storage.assertBot("sendMessageDraft");
278
- const [message, entities] = await this.parseText(text, params);
277
+ const [message, entities] = this.parseText(text, params);
279
278
  const peer = await this.#c.getInputPeer(chatId);
280
279
  await this.#c.invoke({
281
280
  _: "messages.setTyping",
@@ -286,7 +285,7 @@ class MessageManager {
286
285
  }
287
286
  async sendMessage(chatId, text, params) {
288
287
  this.#checkParams(params);
289
- const [message, entities] = await this.parseText(text, params);
288
+ const [message, entities] = this.parseText(text, params);
290
289
  const replyMarkup = await this.#constructReplyMarkup(params);
291
290
  const peer = await this.#c.getInputPeer(chatId);
292
291
  const randomId = (0, _1_utilities_js_1.getRandomId)();
@@ -297,7 +296,7 @@ class MessageManager {
297
296
  const sendAs = await this.#resolveSendAs(params);
298
297
  const effect = params?.effectId ? BigInt(params.effectId) : undefined;
299
298
  const schedule_date = params?.sendAt;
300
- const allow_paid_floodskip = params?.paidBroadcast ? true : undefined;
299
+ const allow_paid_floodskip = params?.isPaidBroadcast ? true : undefined;
301
300
  let result;
302
301
  if (!noWebpage && params?.linkPreview?.url) {
303
302
  result = await this.#c.invoke({
@@ -396,7 +395,7 @@ class MessageManager {
396
395
  message: "",
397
396
  effect: params?.effectId ? BigInt(params.effectId) : undefined,
398
397
  schedule_date: params?.sendAt,
399
- allow_paid_floodskip: params?.paidBroadcast ? true : undefined,
398
+ allow_paid_floodskip: params?.isPaidBroadcast ? true : undefined,
400
399
  }, { businessConnectionId: params?.businessConnectionId });
401
400
  const message = (await this.updatesToMessages(chatId, result, params?.businessConnectionId))[0];
402
401
  return (0, _3_types_js_2.assertMessageType)(message, "venue");
@@ -428,7 +427,7 @@ class MessageManager {
428
427
  message: "",
429
428
  effect: params?.effectId ? BigInt(params.effectId) : undefined,
430
429
  schedule_date: params?.sendAt,
431
- allow_paid_floodskip: params?.paidBroadcast ? true : undefined,
430
+ allow_paid_floodskip: params?.isPaidBroadcast ? true : undefined,
432
431
  }, { businessConnectionId: params?.businessConnectionId });
433
432
  const message = (await this.updatesToMessages(chatId, result, params?.businessConnectionId))[0];
434
433
  return (0, _3_types_js_2.assertMessageType)(message, "contact");
@@ -457,7 +456,7 @@ class MessageManager {
457
456
  message: "",
458
457
  effect: params?.effectId ? BigInt(params.effectId) : undefined,
459
458
  schedule_date: params?.sendAt,
460
- allow_paid_floodskip: params?.paidBroadcast ? true : undefined,
459
+ allow_paid_floodskip: params?.isPaidBroadcast ? true : undefined,
461
460
  }, { businessConnectionId: params?.businessConnectionId });
462
461
  const message = (await this.updatesToMessages(chatId, result, params?.businessConnectionId))[0];
463
462
  return (0, _3_types_js_2.assertMessageType)(message, "dice");
@@ -504,7 +503,7 @@ class MessageManager {
504
503
  message: "",
505
504
  effect: params?.effectId ? BigInt(params.effectId) : undefined,
506
505
  schedule_date: params?.sendAt,
507
- allow_paid_floodskip: params?.paidBroadcast ? true : undefined,
506
+ allow_paid_floodskip: params?.isPaidBroadcast ? true : undefined,
508
507
  }, { businessConnectionId: params?.businessConnectionId });
509
508
  const message = (await this.updatesToMessages(chatId, result, params?.businessConnectionId))[0];
510
509
  return (0, _3_types_js_2.assertMessageType)(message, "location");
@@ -685,7 +684,7 @@ class MessageManager {
685
684
  const sendAs = params?.sendAs ? await this.#c.getInputPeer(params.sendAs) : undefined;
686
685
  const replyMarkup = await this.#constructReplyMarkup(params);
687
686
  const caption_ = params?.caption;
688
- const parseResult = caption_ !== undefined ? await this.parseText(caption_, { parseMode: params?.parseMode, entities: params?.captionEntities }) : undefined;
687
+ const parseResult = caption_ !== undefined ? this.parseText(caption_, { parseMode: params?.parseMode, entities: params?.captionEntities }) : undefined;
689
688
  const caption = parseResult === undefined ? undefined : parseResult[0];
690
689
  const captionEntities = parseResult === undefined ? undefined : parseResult[1];
691
690
  const result = await this.#c.invoke({
@@ -702,7 +701,7 @@ class MessageManager {
702
701
  entities: captionEntities,
703
702
  effect: params?.effectId ? BigInt(params.effectId) : undefined,
704
703
  schedule_date: params?.sendAt,
705
- allow_paid_floodskip: params?.paidBroadcast ? true : undefined,
704
+ allow_paid_floodskip: params?.isPaidBroadcast ? true : undefined,
706
705
  }, { businessConnectionId: params?.businessConnectionId });
707
706
  return (await this.updatesToMessages(chatId, result, params?.businessConnectionId))[0];
708
707
  }
@@ -743,16 +742,16 @@ class MessageManager {
743
742
  const sendAs = params?.sendAs ? await this.#c.getInputPeer(params.sendAs) : undefined;
744
743
  const replyMarkup = await this.#constructReplyMarkup(params);
745
744
  const explanation = params?.explanation;
746
- const parseResult = explanation !== undefined ? await this.parseText(explanation, { parseMode: params?.explanationParseMode, entities: params?.explanationEntities }) : undefined;
745
+ const parseResult = explanation !== undefined ? this.parseText(explanation, { parseMode: params?.explanationParseMode, entities: params?.explanationEntities }) : undefined;
747
746
  const solution = parseResult === undefined ? undefined : parseResult[0];
748
747
  const solutionEntities = parseResult === undefined ? undefined : parseResult[1];
749
- const answers = await Promise.all(options.map(async (v, i) => {
750
- const text = typeof v === "string" ? v : v.text;
751
- const entities = typeof v === "string" ? [] : v.entities;
752
- const parseResult = await this.parseText(text, { parseMode: params?.optionParseMode, entities: entities });
748
+ const answers = options.map((v, i) => {
749
+ const text = v.text;
750
+ const entities = v.entities;
751
+ const parseResult = this.parseText(text, { parseMode: v.parseMode, entities });
753
752
  return ({ _: "pollAnswer", option: (0, _1_utilities_js_1.encodeText)(String(i)), text: { _: "textWithEntities", text: parseResult[0], entities: parseResult[1] ?? [] } });
754
- }));
755
- const questionParseResult = await this.parseText(question, { parseMode: params?.questionParseMode, entities: params?.questionEntities });
753
+ });
754
+ const questionParseResult = this.parseText(question, { parseMode: params?.questionParseMode, entities: params?.questionEntities });
756
755
  const poll = { _: "poll", id: (0, _1_utilities_js_1.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 };
757
756
  const media = { _: "inputMediaPoll", poll, correct_answers: params?.correctOptionIndex !== undefined ? [(0, _1_utilities_js_1.encodeText)(String(params.correctOptionIndex))] : undefined, solution, solution_entities: solutionEntities };
758
757
  const result = await this.#c.invoke({
@@ -768,11 +767,58 @@ class MessageManager {
768
767
  message: "",
769
768
  effect: params?.effectId ? BigInt(params.effectId) : undefined,
770
769
  schedule_date: params?.sendAt,
771
- allow_paid_floodskip: params?.paidBroadcast ? true : undefined,
770
+ allow_paid_floodskip: params?.isPaidBroadcast ? true : undefined,
772
771
  }, { businessConnectionId: params?.businessConnectionId });
773
772
  const message = (await this.updatesToMessages(chatId, result, params?.businessConnectionId))[0];
774
773
  return (0, _3_types_js_2.assertMessageType)(message, "poll");
775
774
  }
775
+ async sendChecklist(chatId, title, items, params) {
776
+ this.#c.storage.assertUser("sendChecklist");
777
+ this.#checkParams(params);
778
+ title = title?.trim();
779
+ if (!title) {
780
+ throw new Error("Title must not be empty.");
781
+ }
782
+ if (!Array.isArray(items) || items.length < 1) {
783
+ throw new Error("There must be at least one item.");
784
+ }
785
+ const peer = await this.#c.getInputPeer(chatId);
786
+ const randomId = (0, _1_utilities_js_1.getRandomId)();
787
+ const silent = params?.isSilent ? true : undefined;
788
+ const noforwards = params?.isContentProtected ? true : undefined;
789
+ const sendAs = params?.sendAs ? await this.#c.getInputPeer(params.sendAs) : undefined;
790
+ const list = items.map((v, i) => {
791
+ const text = v.text;
792
+ const entities = v.entities;
793
+ const parseResult = this.parseText(text, { parseMode: v.parseMode, entities });
794
+ return ({ _: "todoItem", id: i + 1, title: { _: "textWithEntities", text: parseResult[0], entities: parseResult[1] ?? [] } });
795
+ });
796
+ const titleParseResult = this.parseText(title, { parseMode: params?.titleParseMode, entities: params?.titleEntities });
797
+ const todo = {
798
+ _: "todoList",
799
+ title: { _: "textWithEntities", text: titleParseResult[0], entities: titleParseResult[1] ?? [] },
800
+ list,
801
+ others_can_append: params?.isExtendableByOthers ? true : undefined,
802
+ others_can_complete: params?.isCompletableByOthers ? true : undefined,
803
+ };
804
+ const media = { _: "inputMediaTodo", todo };
805
+ const result = await this.#c.invoke({
806
+ _: "messages.sendMedia",
807
+ peer,
808
+ random_id: randomId,
809
+ silent,
810
+ noforwards,
811
+ reply_to: await this.#constructReplyTo(params),
812
+ send_as: sendAs,
813
+ media,
814
+ message: "",
815
+ effect: params?.effectId ? BigInt(params.effectId) : undefined,
816
+ schedule_date: params?.sendAt,
817
+ allow_paid_floodskip: params?.isPaidBroadcast ? true : undefined,
818
+ }, { businessConnectionId: params?.businessConnectionId });
819
+ const message = (await this.updatesToMessages(chatId, result, params?.businessConnectionId))[0];
820
+ return (0, _3_types_js_2.assertMessageType)(message, "checklist");
821
+ }
776
822
  async editMessageReplyMarkup(chatId, messageId, params) {
777
823
  this.#checkParams(params);
778
824
  const result = await this.#c.invoke({
@@ -803,7 +849,7 @@ class MessageManager {
803
849
  throw new _0_errors_js_1.InputError("The referenced message is not a text message.");
804
850
  }
805
851
  }
806
- const [message, entities] = await this.parseText(text, params);
852
+ const [message, entities] = this.parseText(text, params);
807
853
  if (!message) {
808
854
  throw new _0_errors_js_1.InputError("Message text cannot be empty.");
809
855
  }
@@ -845,7 +891,7 @@ class MessageManager {
845
891
  if (!canHaveCaption) {
846
892
  throw new _0_errors_js_1.InputError("The referenced message cannot have a caption.");
847
893
  }
848
- const [message, entities] = await this.parseText(params?.caption ?? "", params);
894
+ const [message, entities] = this.parseText(params?.caption ?? "", params);
849
895
  const result = await this.#c.invoke({
850
896
  _: "messages.editMessage",
851
897
  id: (0, _0_utilities_js_1.checkMessageId)(messageId),
@@ -858,7 +904,7 @@ class MessageManager {
858
904
  }
859
905
  async #editInlineMessageTextInner(inlineMessageId, text, params, allowEmpty = true) {
860
906
  this.#checkParams(params);
861
- const [message, entities] = await this.parseText(text, params);
907
+ const [message, entities] = this.parseText(text, params);
862
908
  if (!allowEmpty && !message) {
863
909
  throw new _0_errors_js_1.InputError("Message text cannot be empty.");
864
910
  }
@@ -1014,7 +1060,7 @@ class MessageManager {
1014
1060
  if (!("animation" in message) && !("audio" in message) && !("document" in message) && !("photo" in message) && !("video" in message)) {
1015
1061
  throw new _0_errors_js_1.InputError("Unexpected message type.");
1016
1062
  }
1017
- const [text, entities] = media.caption !== undefined ? await this.parseText(media.caption, { entities: media.captionEntities, parseMode: media.parseMode }) : ["", []];
1063
+ const [text, entities] = media.caption !== undefined ? this.parseText(media.caption, { entities: media.captionEntities, parseMode: media.parseMode }) : ["", []];
1018
1064
  const result = await this.#c.invoke({
1019
1065
  _: "messages.editMessage",
1020
1066
  peer: await this.#c.getInputPeer(chatId),
@@ -1257,7 +1303,7 @@ class MessageManager {
1257
1303
  peer,
1258
1304
  q: query,
1259
1305
  add_offset: params?.addOffset ?? 0,
1260
- filter: (0, _0_message_search_filter_js_1.messageSearchFilterToTlObject)(params?.filter ?? "empty"),
1306
+ filter: (0, _3_types_js_1.messageSearchFilterToTlObject)(params?.filter ?? "empty"),
1261
1307
  hash: 0n,
1262
1308
  limit: (0, _0_utilities_js_1.getLimit)(params?.limit),
1263
1309
  max_date: 0,
@@ -1425,7 +1471,7 @@ class MessageManager {
1425
1471
  const multiMedia = new Array();
1426
1472
  for (const v of media) {
1427
1473
  const randomId = (0, _1_utilities_js_1.getRandomId)();
1428
- const [message, entities] = v.caption !== undefined ? await this.parseText(v.caption, { entities: v.captionEntities, parseMode: v.parseMode }) : ["", []];
1474
+ const [message, entities] = v.caption !== undefined ? this.parseText(v.caption, { entities: v.captionEntities, parseMode: v.parseMode }) : ["", []];
1429
1475
  multiMedia.push({ _: "inputSingleMedia", message, entities, random_id: randomId, media: await this.#resolveInputMedia(v) });
1430
1476
  }
1431
1477
  const peer = await this.#c.getInputPeer(chatId);
@@ -1453,7 +1499,7 @@ class MessageManager {
1453
1499
  silent,
1454
1500
  send_as: sendAs,
1455
1501
  reply_to: await this.#constructReplyTo(params),
1456
- allow_paid_floodskip: params?.paidBroadcast ? true : undefined,
1502
+ allow_paid_floodskip: params?.isPaidBroadcast ? true : undefined,
1457
1503
  });
1458
1504
  return await this.updatesToMessages(chatId, result);
1459
1505
  }
@@ -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/client/4_chat_manager.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;;;;;;;;;GAkBG;AAIH,OAAO,EAAE,GAAG,EAAE,MAAM,YAAY,CAAC;AACjC,OAAO,EAAqC,KAAK,KAAK,EAA2I,KAAK,gBAAgB,EAA6B,MAAM,eAAe,CAAC;AACzQ,OAAO,EAA8B,KAAK,UAAU,EAAE,KAAK,EAAE,EAAE,KAAK,QAAQ,EAAsB,KAAK,MAAM,EAAE,MAAM,eAAe,CAAC;AAErI,OAAO,KAAK,EAA8E,mBAAmB,EAAE,yBAAyB,EAAE,mBAAmB,EAAE,sBAAsB,EAAE,yBAAyB,EAAE,sBAAsB,EAAE,2BAA2B,EAAE,qBAAqB,EAAE,uBAAuB,EAAE,yBAAyB,EAAE,sBAAsB,EAAE,kBAAkB,EAAE,MAAM,eAAe,CAAC;AAEpZ,OAAO,KAAK,EAAE,eAAe,EAAE,MAAM,yBAAyB,CAAC;AAE/D,OAAO,KAAK,EAAE,CAAC,IAAI,EAAE,EAAE,MAAM,cAAc,CAAC;AAC5C,OAAO,KAAK,EAAE,WAAW,EAAE,MAAM,qBAAqB,CAAC;AACvD,OAAO,KAAK,EAAE,cAAc,EAAE,MAAM,wBAAwB,CAAC;AAE7D,UAAU,CAAE,SAAQ,EAAE;IACpB,WAAW,EA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AC,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"}
@@ -160,7 +160,7 @@ class ChatManager {
160
160
  (0, _0_deps_js_1.unreachable)();
161
161
  }
162
162
  }
163
- // RESTRICTING, BANNING, AND UNBANNING CHAT MEMBERS //
163
+ // CHAT MEMBERS //
164
164
  async banChatMember(chatId, memberId, params) {
165
165
  const chat = await this.#c.getInputPeer(chatId);
166
166
  if (!(_2_tl_js_1.Api.is("inputPeerChannel", chat)) && !(_2_tl_js_1.Api.is("inputPeerChat", chat))) {
@@ -211,6 +211,25 @@ class ChatManager {
211
211
  const member = await this.#c.getInputPeer(memberId);
212
212
  await this.#c.invoke({ _: "channels.editBanned", channel, participant: member, banned_rights: (0, _3_types_js_2.chatMemberRightsToTlObject)(params?.rights, params?.until) });
213
213
  }
214
+ async promoteChatMember(chatId, userId, params) {
215
+ const channel = await this.#c.getInputChannel(chatId);
216
+ const user_id = await this.#c.getInputUser(userId);
217
+ const admin_rights = (0, _3_types_js_1.chatAdministratorRightsToTlObject)(params ?? {});
218
+ const rank = params?.title ?? "";
219
+ await this.#c.invoke({
220
+ _: "channels.editAdmin",
221
+ channel,
222
+ user_id,
223
+ admin_rights,
224
+ rank,
225
+ });
226
+ }
227
+ async setChatMemberTag(chatId, userId, params) {
228
+ const peer = await this.#c.getInputPeer(chatId);
229
+ const participant = await this.#c.getInputPeer(userId);
230
+ const rank = params?.tag ?? "";
231
+ await this.#c.invoke({ _: "messages.editChatParticipantRank", peer, participant, rank });
232
+ }
214
233
  // CHAT SETTINGS //
215
234
  async setAvailableReactions(chatId, availableReactions) {
216
235
  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) => (0, _3_types_js_2.reactionToTlObject)(v)) }) : (0, _0_deps_js_1.unreachable)() });
@@ -236,70 +255,6 @@ class ChatManager {
236
255
  const channel = await this.#c.getInputChannel(chatId);
237
256
  await this.#c.invoke({ _: "channels.setStickers", channel, stickerset: { _: "inputStickerSetEmpty" } });
238
257
  }
239
- // CHAT PHOTOS //
240
- async deleteChatPhoto(chatId) {
241
- const peer = await this.#c.getInputPeer(chatId);
242
- if (!((0, _0_utilities_js_1.canBeInputChannel)(peer)) && !(_2_tl_js_1.Api.is("inputPeerChat", peer))) {
243
- (0, _0_deps_js_1.unreachable)();
244
- }
245
- if ((0, _0_utilities_js_1.canBeInputChannel)(peer)) {
246
- await this.#c.invoke({ _: "channels.editPhoto", channel: (0, _0_utilities_js_1.toInputChannel)(peer), photo: { _: "inputChatPhotoEmpty" } });
247
- }
248
- else if (_2_tl_js_1.Api.is("inputPeerChat", peer)) {
249
- await this.#c.invoke({ _: "messages.editChatPhoto", chat_id: peer.chat_id, photo: { _: "inputChatPhotoEmpty" } });
250
- }
251
- }
252
- async setChatPhoto(chatId, photo, params) {
253
- const peer = await this.#c.getInputPeer(chatId);
254
- if (!((0, _0_utilities_js_1.canBeInputChannel)(peer)) && !(_2_tl_js_1.Api.is("inputPeerChat", peer))) {
255
- (0, _0_deps_js_1.unreachable)();
256
- }
257
- const file = await this.#c.fileManager.upload(photo, params);
258
- const photo_ = { _: "inputChatUploadedPhoto", file };
259
- if ((0, _0_utilities_js_1.canBeInputChannel)(peer)) {
260
- await this.#c.invoke({ _: "channels.editPhoto", channel: (0, _0_utilities_js_1.toInputChannel)(peer), photo: photo_ });
261
- }
262
- else if (_2_tl_js_1.Api.is("inputPeerChat", peer)) {
263
- await this.#c.invoke({ _: "messages.editChatPhoto", chat_id: peer.chat_id, photo: photo_ });
264
- }
265
- }
266
- // INVITING MEMBERS //
267
- async addChatMember(chatId, userId, params) {
268
- this.#c.storage.assertUser("addChatMember");
269
- const chat = await this.#c.getInputPeer(chatId);
270
- if (_2_tl_js_1.Api.isOneOf(["inputPeerEmpty", "inputPeerSelf", "inputPeerUser", "inputPeerUserFromMessage"], chat)) {
271
- throw new _0_errors_js_1.InputError("Cannot add members to private chats");
272
- }
273
- const user = await this.#c.getInputUser(userId);
274
- if (_2_tl_js_1.Api.is("inputPeerChat", chat)) {
275
- const result = await this.#c.invoke({ _: "messages.addChatUser", chat_id: chat.chat_id, user_id: user, fwd_limit: params?.historyLimit ?? 0 });
276
- return result.missing_invitees.map(_3_types_js_1.constructFailedInvitation);
277
- }
278
- else if (_2_tl_js_1.Api.is("inputPeerChannel", chat)) {
279
- const result = await this.#c.invoke({ _: "channels.inviteToChannel", channel: { ...chat, _: "inputChannel" }, users: [user] });
280
- return result.missing_invitees.map(_3_types_js_1.constructFailedInvitation);
281
- }
282
- (0, _0_deps_js_1.unreachable)();
283
- }
284
- async addChatMembers(chatId, userIds) {
285
- this.#c.storage.assertUser("addChatMembers");
286
- const chat = await this.#c.getInputPeer(chatId);
287
- if (_2_tl_js_1.Api.isOneOf(["inputPeerEmpty", "inputPeerSelf", "inputPeerUser", "inputPeerUserFromMessage"], chat)) {
288
- throw new _0_errors_js_1.InputError("Cannot add members to private chats");
289
- }
290
- const users = new Array();
291
- for (const userId of userIds) {
292
- users.push(await this.#c.getInputUser(userId));
293
- }
294
- if (_2_tl_js_1.Api.is("inputPeerChat", chat)) {
295
- throw new _0_errors_js_1.InputError("addChatMembers cannot be used with basic groups");
296
- }
297
- else if ((0, _0_utilities_js_1.canBeInputChannel)(chat)) {
298
- const result = await this.#c.invoke({ _: "channels.inviteToChannel", channel: (0, _0_utilities_js_1.toInputChannel)(chat), users });
299
- return result.missing_invitees.map(_3_types_js_1.constructFailedInvitation);
300
- }
301
- (0, _0_deps_js_1.unreachable)();
302
- }
303
258
  async #toggleSlowMode(chatId, seconds) {
304
259
  const channel = await this.#c.getInputChannel(chatId);
305
260
  await this.#c.invoke({ _: "channels.toggleSlowMode", channel, seconds });
@@ -430,25 +385,6 @@ class ChatManager {
430
385
  const password_ = await (0, _0_password_js_1.checkPassword)(password, ap);
431
386
  await this.#c.invoke({ _: "messages.editChatCreator", peer, user_id, password: password_ });
432
387
  }
433
- async promoteChatMember(chatId, userId, params) {
434
- const channel = await this.#c.getInputChannel(chatId);
435
- const user_id = await this.#c.getInputUser(userId);
436
- const admin_rights = (0, _3_types_js_1.chatAdministratorRightsToTlObject)(params ?? {});
437
- const rank = params?.title ?? "";
438
- await this.#c.invoke({
439
- _: "channels.editAdmin",
440
- channel,
441
- user_id,
442
- admin_rights,
443
- rank,
444
- });
445
- }
446
- async setChatMemberTag(chatId, userId, params) {
447
- const peer = await this.#c.getInputPeer(chatId);
448
- const participant = await this.#c.getInputPeer(userId);
449
- const rank = params?.tag ?? "";
450
- await this.#c.invoke({ _: "messages.editChatParticipantRank", peer, participant, rank });
451
- }
452
388
  async #setIsSharingEnabled(chatId, isSharingEnabled) {
453
389
  const peer = await this.#c.getInputPeer(chatId);
454
390
  await this.#c.invoke({ _: "messages.toggleNoForwards", peer, enabled: !isSharingEnabled });
@@ -461,5 +397,69 @@ class ChatManager {
461
397
  this.#c.storage.assertUser("disableSharing");
462
398
  await this.#setIsSharingEnabled(chatId, false);
463
399
  }
400
+ // CHAT PHOTOS //
401
+ async deleteChatPhoto(chatId) {
402
+ const peer = await this.#c.getInputPeer(chatId);
403
+ if (!((0, _0_utilities_js_1.canBeInputChannel)(peer)) && !(_2_tl_js_1.Api.is("inputPeerChat", peer))) {
404
+ (0, _0_deps_js_1.unreachable)();
405
+ }
406
+ if ((0, _0_utilities_js_1.canBeInputChannel)(peer)) {
407
+ await this.#c.invoke({ _: "channels.editPhoto", channel: (0, _0_utilities_js_1.toInputChannel)(peer), photo: { _: "inputChatPhotoEmpty" } });
408
+ }
409
+ else if (_2_tl_js_1.Api.is("inputPeerChat", peer)) {
410
+ await this.#c.invoke({ _: "messages.editChatPhoto", chat_id: peer.chat_id, photo: { _: "inputChatPhotoEmpty" } });
411
+ }
412
+ }
413
+ async setChatPhoto(chatId, photo, params) {
414
+ const peer = await this.#c.getInputPeer(chatId);
415
+ if (!((0, _0_utilities_js_1.canBeInputChannel)(peer)) && !(_2_tl_js_1.Api.is("inputPeerChat", peer))) {
416
+ (0, _0_deps_js_1.unreachable)();
417
+ }
418
+ const file = await this.#c.fileManager.upload(photo, params);
419
+ const photo_ = { _: "inputChatUploadedPhoto", file };
420
+ if ((0, _0_utilities_js_1.canBeInputChannel)(peer)) {
421
+ await this.#c.invoke({ _: "channels.editPhoto", channel: (0, _0_utilities_js_1.toInputChannel)(peer), photo: photo_ });
422
+ }
423
+ else if (_2_tl_js_1.Api.is("inputPeerChat", peer)) {
424
+ await this.#c.invoke({ _: "messages.editChatPhoto", chat_id: peer.chat_id, photo: photo_ });
425
+ }
426
+ }
427
+ // INVITING MEMBERS //
428
+ async addChatMember(chatId, userId, params) {
429
+ this.#c.storage.assertUser("addChatMember");
430
+ const chat = await this.#c.getInputPeer(chatId);
431
+ if (_2_tl_js_1.Api.isOneOf(["inputPeerEmpty", "inputPeerSelf", "inputPeerUser", "inputPeerUserFromMessage"], chat)) {
432
+ throw new _0_errors_js_1.InputError("Cannot add members to private chats");
433
+ }
434
+ const user = await this.#c.getInputUser(userId);
435
+ if (_2_tl_js_1.Api.is("inputPeerChat", chat)) {
436
+ const result = await this.#c.invoke({ _: "messages.addChatUser", chat_id: chat.chat_id, user_id: user, fwd_limit: params?.historyLimit ?? 0 });
437
+ return result.missing_invitees.map(_3_types_js_1.constructFailedInvitation);
438
+ }
439
+ else if (_2_tl_js_1.Api.is("inputPeerChannel", chat)) {
440
+ const result = await this.#c.invoke({ _: "channels.inviteToChannel", channel: { ...chat, _: "inputChannel" }, users: [user] });
441
+ return result.missing_invitees.map(_3_types_js_1.constructFailedInvitation);
442
+ }
443
+ (0, _0_deps_js_1.unreachable)();
444
+ }
445
+ async addChatMembers(chatId, userIds) {
446
+ this.#c.storage.assertUser("addChatMembers");
447
+ const chat = await this.#c.getInputPeer(chatId);
448
+ if (_2_tl_js_1.Api.isOneOf(["inputPeerEmpty", "inputPeerSelf", "inputPeerUser", "inputPeerUserFromMessage"], chat)) {
449
+ throw new _0_errors_js_1.InputError("Cannot add members to private chats");
450
+ }
451
+ const users = new Array();
452
+ for (const userId of userIds) {
453
+ users.push(await this.#c.getInputUser(userId));
454
+ }
455
+ if (_2_tl_js_1.Api.is("inputPeerChat", chat)) {
456
+ throw new _0_errors_js_1.InputError("addChatMembers cannot be used with basic groups");
457
+ }
458
+ else if ((0, _0_utilities_js_1.canBeInputChannel)(chat)) {
459
+ const result = await this.#c.invoke({ _: "channels.inviteToChannel", channel: (0, _0_utilities_js_1.toInputChannel)(chat), users });
460
+ return result.missing_invitees.map(_3_types_js_1.constructFailedInvitation);
461
+ }
462
+ (0, _0_deps_js_1.unreachable)();
463
+ }
464
464
  }
465
465
  exports.ChatManager = ChatManager;
@@ -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: string[], params?: SendPollParams): Promise<MessagePoll>;
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
  *