neogram 9.3.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 (291) hide show
  1. package/LICENSE +22 -0
  2. package/README.md +1239 -0
  3. package/package.json +56 -0
  4. package/src/Bot.js +4419 -0
  5. package/src/TelegramObject.js +106 -0
  6. package/src/ai/ChatGPT.js +77 -0
  7. package/src/ai/Deef.js +170 -0
  8. package/src/ai/OnlySQ.js +126 -0
  9. package/src/index.js +290 -0
  10. package/src/types/AcceptedGiftTypes.js +10 -0
  11. package/src/types/AffiliateInfo.js +10 -0
  12. package/src/types/Animation.js +10 -0
  13. package/src/types/Audio.js +10 -0
  14. package/src/types/BackgroundFill.js +5 -0
  15. package/src/types/BackgroundFillFreeformGradient.js +10 -0
  16. package/src/types/BackgroundFillGradient.js +10 -0
  17. package/src/types/BackgroundFillSolid.js +10 -0
  18. package/src/types/BackgroundType.js +5 -0
  19. package/src/types/BackgroundTypeChatTheme.js +10 -0
  20. package/src/types/BackgroundTypeFill.js +10 -0
  21. package/src/types/BackgroundTypePattern.js +10 -0
  22. package/src/types/BackgroundTypeWallpaper.js +10 -0
  23. package/src/types/Birthdate.js +10 -0
  24. package/src/types/BotCommand.js +10 -0
  25. package/src/types/BotCommandScope.js +5 -0
  26. package/src/types/BotCommandScopeAllChatAdministrators.js +10 -0
  27. package/src/types/BotCommandScopeAllGroupChats.js +10 -0
  28. package/src/types/BotCommandScopeAllPrivateChats.js +10 -0
  29. package/src/types/BotCommandScopeChat.js +10 -0
  30. package/src/types/BotCommandScopeChatAdministrators.js +10 -0
  31. package/src/types/BotCommandScopeChatMember.js +10 -0
  32. package/src/types/BotCommandScopeDefault.js +10 -0
  33. package/src/types/BotDescription.js +10 -0
  34. package/src/types/BotName.js +10 -0
  35. package/src/types/BotShortDescription.js +10 -0
  36. package/src/types/BusinessBotRights.js +10 -0
  37. package/src/types/BusinessConnection.js +10 -0
  38. package/src/types/BusinessIntro.js +10 -0
  39. package/src/types/BusinessLocation.js +10 -0
  40. package/src/types/BusinessMessagesDeleted.js +10 -0
  41. package/src/types/BusinessOpeningHours.js +10 -0
  42. package/src/types/BusinessOpeningHoursInterval.js +10 -0
  43. package/src/types/CallbackGame.js +5 -0
  44. package/src/types/CallbackQuery.js +26 -0
  45. package/src/types/Chat.js +10 -0
  46. package/src/types/ChatAdministratorRights.js +10 -0
  47. package/src/types/ChatBackground.js +10 -0
  48. package/src/types/ChatBoost.js +10 -0
  49. package/src/types/ChatBoostAdded.js +10 -0
  50. package/src/types/ChatBoostRemoved.js +10 -0
  51. package/src/types/ChatBoostSource.js +5 -0
  52. package/src/types/ChatBoostSourceGiftCode.js +10 -0
  53. package/src/types/ChatBoostSourceGiveaway.js +10 -0
  54. package/src/types/ChatBoostSourcePremium.js +10 -0
  55. package/src/types/ChatBoostUpdated.js +10 -0
  56. package/src/types/ChatFullInfo.js +10 -0
  57. package/src/types/ChatInviteLink.js +10 -0
  58. package/src/types/ChatJoinRequest.js +10 -0
  59. package/src/types/ChatLocation.js +10 -0
  60. package/src/types/ChatMember.js +5 -0
  61. package/src/types/ChatMemberAdministrator.js +10 -0
  62. package/src/types/ChatMemberBanned.js +10 -0
  63. package/src/types/ChatMemberLeft.js +10 -0
  64. package/src/types/ChatMemberMember.js +10 -0
  65. package/src/types/ChatMemberOwner.js +10 -0
  66. package/src/types/ChatMemberRestricted.js +10 -0
  67. package/src/types/ChatMemberUpdated.js +10 -0
  68. package/src/types/ChatPermissions.js +10 -0
  69. package/src/types/ChatPhoto.js +10 -0
  70. package/src/types/ChatShared.js +10 -0
  71. package/src/types/Checklist.js +10 -0
  72. package/src/types/ChecklistTask.js +10 -0
  73. package/src/types/ChecklistTasksAdded.js +10 -0
  74. package/src/types/ChecklistTasksDone.js +10 -0
  75. package/src/types/ChosenInlineResult.js +10 -0
  76. package/src/types/Contact.js +10 -0
  77. package/src/types/CopyTextButton.js +10 -0
  78. package/src/types/Dice.js +10 -0
  79. package/src/types/DirectMessagePriceChanged.js +10 -0
  80. package/src/types/DirectMessagesTopic.js +10 -0
  81. package/src/types/Document.js +10 -0
  82. package/src/types/EncryptedCredentials.js +10 -0
  83. package/src/types/EncryptedPassportElement.js +10 -0
  84. package/src/types/ExternalReplyInfo.js +10 -0
  85. package/src/types/File.js +10 -0
  86. package/src/types/ForceReply.js +10 -0
  87. package/src/types/ForumTopic.js +10 -0
  88. package/src/types/ForumTopicClosed.js +5 -0
  89. package/src/types/ForumTopicCreated.js +10 -0
  90. package/src/types/ForumTopicEdited.js +10 -0
  91. package/src/types/ForumTopicReopened.js +5 -0
  92. package/src/types/Game.js +10 -0
  93. package/src/types/GameHighScore.js +10 -0
  94. package/src/types/GeneralForumTopicHidden.js +5 -0
  95. package/src/types/GeneralForumTopicUnhidden.js +5 -0
  96. package/src/types/Gift.js +10 -0
  97. package/src/types/GiftBackground.js +10 -0
  98. package/src/types/GiftInfo.js +10 -0
  99. package/src/types/Gifts.js +10 -0
  100. package/src/types/Giveaway.js +10 -0
  101. package/src/types/GiveawayCompleted.js +10 -0
  102. package/src/types/GiveawayCreated.js +10 -0
  103. package/src/types/GiveawayWinners.js +10 -0
  104. package/src/types/InaccessibleMessage.js +10 -0
  105. package/src/types/InlineKeyboardButton.js +10 -0
  106. package/src/types/InlineKeyboardMarkup.js +10 -0
  107. package/src/types/InlineQuery.js +24 -0
  108. package/src/types/InlineQueryResult.js +5 -0
  109. package/src/types/InlineQueryResultArticle.js +10 -0
  110. package/src/types/InlineQueryResultAudio.js +10 -0
  111. package/src/types/InlineQueryResultCachedAudio.js +10 -0
  112. package/src/types/InlineQueryResultCachedDocument.js +10 -0
  113. package/src/types/InlineQueryResultCachedGif.js +10 -0
  114. package/src/types/InlineQueryResultCachedMpeg4Gif.js +10 -0
  115. package/src/types/InlineQueryResultCachedPhoto.js +10 -0
  116. package/src/types/InlineQueryResultCachedSticker.js +10 -0
  117. package/src/types/InlineQueryResultCachedVideo.js +10 -0
  118. package/src/types/InlineQueryResultCachedVoice.js +10 -0
  119. package/src/types/InlineQueryResultContact.js +10 -0
  120. package/src/types/InlineQueryResultDocument.js +10 -0
  121. package/src/types/InlineQueryResultGame.js +10 -0
  122. package/src/types/InlineQueryResultGif.js +10 -0
  123. package/src/types/InlineQueryResultLocation.js +10 -0
  124. package/src/types/InlineQueryResultMpeg4Gif.js +10 -0
  125. package/src/types/InlineQueryResultPhoto.js +10 -0
  126. package/src/types/InlineQueryResultVenue.js +10 -0
  127. package/src/types/InlineQueryResultVideo.js +10 -0
  128. package/src/types/InlineQueryResultVoice.js +10 -0
  129. package/src/types/InlineQueryResultsButton.js +10 -0
  130. package/src/types/InputChecklist.js +10 -0
  131. package/src/types/InputChecklistTask.js +10 -0
  132. package/src/types/InputContactMessageContent.js +10 -0
  133. package/src/types/InputFile.js +5 -0
  134. package/src/types/InputInvoiceMessageContent.js +10 -0
  135. package/src/types/InputLocationMessageContent.js +10 -0
  136. package/src/types/InputMedia.js +5 -0
  137. package/src/types/InputMediaAnimation.js +14 -0
  138. package/src/types/InputMediaAudio.js +14 -0
  139. package/src/types/InputMediaDocument.js +14 -0
  140. package/src/types/InputMediaPhoto.js +14 -0
  141. package/src/types/InputMediaVideo.js +14 -0
  142. package/src/types/InputMessageContent.js +5 -0
  143. package/src/types/InputPaidMedia.js +5 -0
  144. package/src/types/InputPaidMediaPhoto.js +10 -0
  145. package/src/types/InputPaidMediaVideo.js +10 -0
  146. package/src/types/InputPollOption.js +10 -0
  147. package/src/types/InputProfilePhoto.js +5 -0
  148. package/src/types/InputProfilePhotoAnimated.js +10 -0
  149. package/src/types/InputProfilePhotoStatic.js +10 -0
  150. package/src/types/InputSticker.js +10 -0
  151. package/src/types/InputStoryContent.js +5 -0
  152. package/src/types/InputStoryContentPhoto.js +10 -0
  153. package/src/types/InputStoryContentVideo.js +10 -0
  154. package/src/types/InputTextMessageContent.js +10 -0
  155. package/src/types/InputVenueMessageContent.js +10 -0
  156. package/src/types/Invoice.js +10 -0
  157. package/src/types/KeyboardButton.js +10 -0
  158. package/src/types/KeyboardButtonPollType.js +10 -0
  159. package/src/types/KeyboardButtonRequestChat.js +10 -0
  160. package/src/types/KeyboardButtonRequestUsers.js +10 -0
  161. package/src/types/LabeledPrice.js +10 -0
  162. package/src/types/LinkPreviewOptions.js +10 -0
  163. package/src/types/Location.js +10 -0
  164. package/src/types/LocationAddress.js +10 -0
  165. package/src/types/LoginUrl.js +10 -0
  166. package/src/types/MaskPosition.js +10 -0
  167. package/src/types/MaybeInaccessibleMessage.js +5 -0
  168. package/src/types/MenuButton.js +5 -0
  169. package/src/types/MenuButtonCommands.js +10 -0
  170. package/src/types/MenuButtonDefault.js +10 -0
  171. package/src/types/MenuButtonWebApp.js +10 -0
  172. package/src/types/Message.js +10 -0
  173. package/src/types/MessageAutoDeleteTimerChanged.js +10 -0
  174. package/src/types/MessageEntity.js +10 -0
  175. package/src/types/MessageId.js +10 -0
  176. package/src/types/MessageOrigin.js +5 -0
  177. package/src/types/MessageOriginChannel.js +10 -0
  178. package/src/types/MessageOriginChat.js +10 -0
  179. package/src/types/MessageOriginHiddenUser.js +10 -0
  180. package/src/types/MessageOriginUser.js +10 -0
  181. package/src/types/MessageReactionCountUpdated.js +10 -0
  182. package/src/types/MessageReactionUpdated.js +10 -0
  183. package/src/types/OrderInfo.js +10 -0
  184. package/src/types/OwnedGift.js +5 -0
  185. package/src/types/OwnedGiftRegular.js +10 -0
  186. package/src/types/OwnedGiftUnique.js +10 -0
  187. package/src/types/OwnedGifts.js +10 -0
  188. package/src/types/PaidMedia.js +5 -0
  189. package/src/types/PaidMediaInfo.js +10 -0
  190. package/src/types/PaidMediaPhoto.js +10 -0
  191. package/src/types/PaidMediaPreview.js +10 -0
  192. package/src/types/PaidMediaPurchased.js +10 -0
  193. package/src/types/PaidMediaVideo.js +10 -0
  194. package/src/types/PaidMessagePriceChanged.js +10 -0
  195. package/src/types/PassportData.js +10 -0
  196. package/src/types/PassportElementError.js +5 -0
  197. package/src/types/PassportElementErrorDataField.js +10 -0
  198. package/src/types/PassportElementErrorFile.js +10 -0
  199. package/src/types/PassportElementErrorFiles.js +10 -0
  200. package/src/types/PassportElementErrorFrontSide.js +10 -0
  201. package/src/types/PassportElementErrorReverseSide.js +10 -0
  202. package/src/types/PassportElementErrorSelfie.js +10 -0
  203. package/src/types/PassportElementErrorTranslationFile.js +10 -0
  204. package/src/types/PassportElementErrorTranslationFiles.js +10 -0
  205. package/src/types/PassportElementErrorUnspecified.js +10 -0
  206. package/src/types/PassportFile.js +10 -0
  207. package/src/types/PhotoSize.js +10 -0
  208. package/src/types/Poll.js +10 -0
  209. package/src/types/PollAnswer.js +10 -0
  210. package/src/types/PollOption.js +10 -0
  211. package/src/types/PreCheckoutQuery.js +10 -0
  212. package/src/types/PreparedInlineMessage.js +10 -0
  213. package/src/types/ProximityAlertTriggered.js +10 -0
  214. package/src/types/ReactionCount.js +10 -0
  215. package/src/types/ReactionType.js +5 -0
  216. package/src/types/ReactionTypeCustomEmoji.js +10 -0
  217. package/src/types/ReactionTypeEmoji.js +10 -0
  218. package/src/types/ReactionTypePaid.js +10 -0
  219. package/src/types/RefundedPayment.js +10 -0
  220. package/src/types/ReplyKeyboardMarkup.js +10 -0
  221. package/src/types/ReplyKeyboardRemove.js +10 -0
  222. package/src/types/ReplyParameters.js +10 -0
  223. package/src/types/ResponseParameters.js +10 -0
  224. package/src/types/RevenueWithdrawalState.js +5 -0
  225. package/src/types/RevenueWithdrawalStateFailed.js +10 -0
  226. package/src/types/RevenueWithdrawalStatePending.js +10 -0
  227. package/src/types/RevenueWithdrawalStateSucceeded.js +10 -0
  228. package/src/types/SentWebAppMessage.js +10 -0
  229. package/src/types/SharedUser.js +10 -0
  230. package/src/types/ShippingAddress.js +10 -0
  231. package/src/types/ShippingOption.js +10 -0
  232. package/src/types/ShippingQuery.js +10 -0
  233. package/src/types/StarAmount.js +10 -0
  234. package/src/types/StarTransaction.js +10 -0
  235. package/src/types/StarTransactions.js +10 -0
  236. package/src/types/Sticker.js +10 -0
  237. package/src/types/StickerSet.js +10 -0
  238. package/src/types/Story.js +10 -0
  239. package/src/types/StoryArea.js +10 -0
  240. package/src/types/StoryAreaPosition.js +10 -0
  241. package/src/types/StoryAreaType.js +5 -0
  242. package/src/types/StoryAreaTypeLink.js +10 -0
  243. package/src/types/StoryAreaTypeLocation.js +10 -0
  244. package/src/types/StoryAreaTypeSuggestedReaction.js +10 -0
  245. package/src/types/StoryAreaTypeUniqueGift.js +10 -0
  246. package/src/types/StoryAreaTypeWeather.js +10 -0
  247. package/src/types/SuccessfulPayment.js +10 -0
  248. package/src/types/SuggestedPostApprovalFailed.js +10 -0
  249. package/src/types/SuggestedPostApproved.js +10 -0
  250. package/src/types/SuggestedPostDeclined.js +10 -0
  251. package/src/types/SuggestedPostInfo.js +10 -0
  252. package/src/types/SuggestedPostPaid.js +10 -0
  253. package/src/types/SuggestedPostParameters.js +10 -0
  254. package/src/types/SuggestedPostPrice.js +10 -0
  255. package/src/types/SuggestedPostRefunded.js +10 -0
  256. package/src/types/SwitchInlineQueryChosenChat.js +10 -0
  257. package/src/types/TextQuote.js +10 -0
  258. package/src/types/TransactionPartner.js +5 -0
  259. package/src/types/TransactionPartnerAffiliateProgram.js +10 -0
  260. package/src/types/TransactionPartnerChat.js +10 -0
  261. package/src/types/TransactionPartnerFragment.js +10 -0
  262. package/src/types/TransactionPartnerOther.js +10 -0
  263. package/src/types/TransactionPartnerTelegramAds.js +10 -0
  264. package/src/types/TransactionPartnerTelegramApi.js +10 -0
  265. package/src/types/TransactionPartnerUser.js +10 -0
  266. package/src/types/UniqueGift.js +10 -0
  267. package/src/types/UniqueGiftBackdrop.js +10 -0
  268. package/src/types/UniqueGiftBackdropColors.js +10 -0
  269. package/src/types/UniqueGiftColors.js +10 -0
  270. package/src/types/UniqueGiftInfo.js +10 -0
  271. package/src/types/UniqueGiftModel.js +10 -0
  272. package/src/types/UniqueGiftSymbol.js +10 -0
  273. package/src/types/Update.js +10 -0
  274. package/src/types/User.js +10 -0
  275. package/src/types/UserChatBoosts.js +10 -0
  276. package/src/types/UserProfilePhotos.js +10 -0
  277. package/src/types/UserRating.js +10 -0
  278. package/src/types/UsersShared.js +10 -0
  279. package/src/types/Venue.js +10 -0
  280. package/src/types/Video.js +10 -0
  281. package/src/types/VideoChatEnded.js +10 -0
  282. package/src/types/VideoChatParticipantsInvited.js +10 -0
  283. package/src/types/VideoChatScheduled.js +10 -0
  284. package/src/types/VideoChatStarted.js +5 -0
  285. package/src/types/VideoNote.js +10 -0
  286. package/src/types/Voice.js +10 -0
  287. package/src/types/WebAppData.js +10 -0
  288. package/src/types/WebAppInfo.js +10 -0
  289. package/src/types/WebhookInfo.js +10 -0
  290. package/src/types/WriteAccessAllowed.js +10 -0
  291. package/types/index.d.ts +1133 -0
package/src/Bot.js ADDED
@@ -0,0 +1,4419 @@
1
+ import axios from 'axios';
2
+ import FormData from 'form-data';
3
+ import { User } from './types/User.js';
4
+
5
+ const API_ROOT = 'https://api.telegram.org';
6
+
7
+ function serialize(obj) {
8
+ if (obj === null || obj === undefined) {
9
+ return undefined;
10
+ }
11
+ if (typeof obj === 'string' || typeof obj === 'number' || typeof obj === 'boolean') {
12
+ return obj;
13
+ }
14
+ if (Array.isArray(obj)) {
15
+ const serialized = obj.map(item => {
16
+ if (item && typeof item === 'object' && typeof item.toJSON === 'function') {
17
+ return item.toJSON();
18
+ }
19
+ return item;
20
+ });
21
+ return JSON.stringify(serialized);
22
+ }
23
+ if (typeof obj === 'object' && typeof obj.toJSON === 'function') {
24
+ try {
25
+ return JSON.stringify(obj.toJSON());
26
+ } catch (_e) {
27
+ // Fallback to regular serialization if toJSON fails
28
+ return JSON.stringify(obj);
29
+ }
30
+ }
31
+ if (typeof obj === 'object') {
32
+ return JSON.stringify(obj);
33
+ }
34
+ return obj;
35
+ }
36
+
37
+ export class Bot {
38
+ constructor(token, options = {}) {
39
+ if (!token || typeof token !== 'string') {
40
+ throw new Error('Bot token is required and must be a string');
41
+ }
42
+
43
+ const { timeout = 60_000 } = options;
44
+
45
+ this.token = token;
46
+ this.timeout = timeout;
47
+ this.http = axios.create({
48
+ baseURL: `${API_ROOT}/bot${token}/`,
49
+ timeout,
50
+ });
51
+ }
52
+
53
+ async _request(method, params = {}, files = null) {
54
+ let res;
55
+ if (files && Object.keys(files).length > 0) {
56
+ const form = new FormData();
57
+ for (const [k, v] of Object.entries(params)) {
58
+ if (v !== null && v !== undefined) {
59
+ // Better handling of different value types
60
+ if (typeof v === 'object') {
61
+ form.append(k, JSON.stringify(v));
62
+ } else {
63
+ form.append(k, String(v));
64
+ }
65
+ }
66
+ }
67
+ for (const [k, v] of Object.entries(files)) {
68
+ form.append(k, v);
69
+ }
70
+ res = await this.http.post(method, form, { headers: form.getHeaders() });
71
+ } else {
72
+ res = await this.http.post(method, params);
73
+ }
74
+ const data = res.data;
75
+ if (!data.ok) {
76
+ const err = new Error(`Error ${data.error_code || 'Unknown'}: ${data.description || 'No description'}`);
77
+ err.error_code = data.error_code;
78
+ err.description = data.description;
79
+ throw err;
80
+ }
81
+ return data.result;
82
+ }
83
+
84
+ // === Core API (порт основных методов Bot из Python-версии) ===
85
+
86
+ async getUpdates({ offset, limit, timeout, allowed_updates } = {}) {
87
+ const params = {
88
+ offset,
89
+ limit,
90
+ timeout,
91
+ allowed_updates: allowed_updates ? JSON.stringify(allowed_updates) : undefined,
92
+ };
93
+ const clean = Object.fromEntries(Object.entries(params).filter(([_, v]) => v !== undefined && v !== null));
94
+ const result = await this._request('getUpdates', clean);
95
+ return Array.isArray(result) ? result : [];
96
+ }
97
+
98
+ async setWebhook({ url, certificate, ip_address, max_connections, allowed_updates, drop_pending_updates, secret_token } = {}) {
99
+ if (!url) {
100
+ throw new Error('url required');
101
+ }
102
+ const params = {
103
+ url,
104
+ ip_address,
105
+ max_connections,
106
+ allowed_updates: serialize(allowed_updates),
107
+ drop_pending_updates,
108
+ secret_token,
109
+ };
110
+ const clean = Object.fromEntries(Object.entries(params).filter(([_, v]) => v !== undefined && v !== null));
111
+ const files = {};
112
+ if (certificate) {
113
+ files.certificate = certificate;
114
+ }
115
+ const result = await this._request('setWebhook', clean, files);
116
+ return !!result;
117
+ }
118
+
119
+ async deleteWebhook({ drop_pending_updates } = {}) {
120
+ const params = { drop_pending_updates };
121
+ const clean = Object.fromEntries(Object.entries(params).filter(([_, v]) => v !== undefined && v !== null));
122
+ const result = await this._request('deleteWebhook', clean);
123
+ return !!result;
124
+ }
125
+
126
+ async getWebhookInfo() {
127
+ const result = await this._request('getWebhookInfo', {});
128
+ return result; // можно обернуть в WebhookInfo.fromJSON позже
129
+ }
130
+
131
+ async getMe() {
132
+ const result = await this._request('getMe', {});
133
+ return User.fromJSON(result);
134
+ }
135
+
136
+ async sendMessage(options = {}) {
137
+ const {
138
+ chat_id,
139
+ text,
140
+ business_connection_id,
141
+ message_thread_id,
142
+ direct_messages_topic_id,
143
+ parse_mode,
144
+ entities,
145
+ link_preview_options,
146
+ disable_notification,
147
+ protect_content,
148
+ allow_paid_broadcast,
149
+ message_effect_id,
150
+ suggested_post_parameters,
151
+ reply_parameters,
152
+ reply_markup,
153
+ } = options;
154
+ if (chat_id === undefined || chat_id === null) {
155
+ throw new Error('chat_id required');
156
+ }
157
+ if (text === undefined || text === null) {
158
+ throw new Error('text required');
159
+ }
160
+ const params = {
161
+ chat_id: serialize(chat_id),
162
+ text,
163
+ business_connection_id,
164
+ message_thread_id,
165
+ direct_messages_topic_id,
166
+ parse_mode,
167
+ entities: serialize(entities),
168
+ link_preview_options: serialize(link_preview_options),
169
+ disable_notification,
170
+ protect_content,
171
+ allow_paid_broadcast,
172
+ message_effect_id,
173
+ suggested_post_parameters: serialize(suggested_post_parameters),
174
+ reply_parameters: serialize(reply_parameters),
175
+ reply_markup: serialize(reply_markup),
176
+ };
177
+ const clean = Object.fromEntries(Object.entries(params).filter(([_, v]) => v !== undefined && v !== null));
178
+ const result = await this._request('sendMessage', clean);
179
+ return result; // Message.fromJSON можно добавить позже
180
+ }
181
+
182
+ async deleteMessage({ chat_id, message_id } = {}) {
183
+ if (chat_id === undefined || chat_id === null) {
184
+ throw new Error('chat_id required');
185
+ }
186
+ if (message_id === undefined || message_id === null) {
187
+ throw new Error('message_id required');
188
+ }
189
+ const params = { chat_id: serialize(chat_id), message_id };
190
+ const result = await this._request('deleteMessage', params);
191
+ return !!result;
192
+ }
193
+
194
+ // Пример ещё одного метода — sendPhoto (остальные можно перенести по той же схеме)
195
+ async sendPhoto(options = {}) {
196
+ const {
197
+ chat_id,
198
+ photo,
199
+ business_connection_id,
200
+ message_thread_id,
201
+ direct_messages_topic_id,
202
+ caption,
203
+ parse_mode,
204
+ caption_entities,
205
+ show_caption_above_media,
206
+ has_spoiler,
207
+ disable_notification,
208
+ protect_content,
209
+ allow_paid_broadcast,
210
+ message_effect_id,
211
+ suggested_post_parameters,
212
+ reply_parameters,
213
+ reply_markup,
214
+ } = options;
215
+ if (chat_id === undefined || chat_id === null) {
216
+ throw new Error('chat_id required');
217
+ }
218
+ if (!photo) {
219
+ throw new Error('photo required');
220
+ }
221
+ const params = {
222
+ chat_id: serialize(chat_id),
223
+ business_connection_id,
224
+ message_thread_id,
225
+ direct_messages_topic_id,
226
+ caption,
227
+ parse_mode,
228
+ caption_entities: serialize(caption_entities),
229
+ show_caption_above_media,
230
+ has_spoiler,
231
+ disable_notification,
232
+ protect_content,
233
+ allow_paid_broadcast,
234
+ message_effect_id,
235
+ suggested_post_parameters: serialize(suggested_post_parameters),
236
+ reply_parameters: serialize(reply_parameters),
237
+ reply_markup: serialize(reply_markup),
238
+ };
239
+ const clean = Object.fromEntries(Object.entries(params).filter(([_, v]) => v !== undefined && v !== null));
240
+ const files = {};
241
+ if (photo instanceof Buffer || (photo && typeof photo.pipe === 'function')) {
242
+ files.photo = photo;
243
+ } else {
244
+ clean.photo = photo;
245
+ }
246
+ const result = await this._request('sendPhoto', clean, files);
247
+ return result;
248
+ }
249
+
250
+ async logOut() {
251
+ const result = await this._request('logOut', {});
252
+ return !!result;
253
+ }
254
+
255
+ async close() {
256
+ const result = await this._request('close', {});
257
+ return !!result;
258
+ }
259
+
260
+ async forwardMessage(options = {}) {
261
+ const {
262
+ chat_id,
263
+ from_chat_id,
264
+ message_id,
265
+ message_thread_id,
266
+ direct_messages_topic_id,
267
+ video_start_timestamp,
268
+ disable_notification,
269
+ protect_content,
270
+ message_effect_id,
271
+ suggested_post_parameters,
272
+ } = options;
273
+ if (chat_id === undefined || chat_id === null) {
274
+ throw new Error('chat_id required');
275
+ }
276
+ if (from_chat_id === undefined || from_chat_id === null) {
277
+ throw new Error('from_chat_id required');
278
+ }
279
+ if (message_id === undefined || message_id === null) {
280
+ throw new Error('message_id required');
281
+ }
282
+ const params = {
283
+ chat_id: serialize(chat_id),
284
+ from_chat_id: serialize(from_chat_id),
285
+ message_id,
286
+ message_thread_id,
287
+ direct_messages_topic_id,
288
+ video_start_timestamp,
289
+ disable_notification,
290
+ protect_content,
291
+ message_effect_id,
292
+ suggested_post_parameters: serialize(suggested_post_parameters),
293
+ };
294
+ const clean = Object.fromEntries(Object.entries(params).filter(([_, v]) => v !== undefined && v !== null));
295
+ const result = await this._request('forwardMessage', clean);
296
+ return result;
297
+ }
298
+
299
+ async forwardMessages(options = {}) {
300
+ const {
301
+ chat_id,
302
+ from_chat_id,
303
+ message_ids,
304
+ message_thread_id,
305
+ direct_messages_topic_id,
306
+ disable_notification,
307
+ protect_content,
308
+ } = options;
309
+ if (chat_id === undefined || chat_id === null) {
310
+ throw new Error('chat_id required');
311
+ }
312
+ if (from_chat_id === undefined || from_chat_id === null) {
313
+ throw new Error('from_chat_id required');
314
+ }
315
+ if (!message_ids) {
316
+ throw new Error('message_ids required');
317
+ }
318
+ const params = {
319
+ chat_id: serialize(chat_id),
320
+ from_chat_id: serialize(from_chat_id),
321
+ message_ids: serialize(message_ids),
322
+ message_thread_id,
323
+ direct_messages_topic_id,
324
+ disable_notification,
325
+ protect_content,
326
+ };
327
+ const clean = Object.fromEntries(Object.entries(params).filter(([_, v]) => v !== undefined && v !== null));
328
+ const result = await this._request('forwardMessages', clean);
329
+ return result;
330
+ }
331
+
332
+ async copyMessage(options = {}) {
333
+ const {
334
+ chat_id,
335
+ from_chat_id,
336
+ message_id,
337
+ message_thread_id,
338
+ direct_messages_topic_id,
339
+ video_start_timestamp,
340
+ caption,
341
+ parse_mode,
342
+ caption_entities,
343
+ show_caption_above_media,
344
+ disable_notification,
345
+ protect_content,
346
+ allow_paid_broadcast,
347
+ message_effect_id,
348
+ suggested_post_parameters,
349
+ reply_parameters,
350
+ reply_markup,
351
+ } = options;
352
+ if (chat_id === undefined || chat_id === null) {
353
+ throw new Error('chat_id required');
354
+ }
355
+ if (from_chat_id === undefined || from_chat_id === null) {
356
+ throw new Error('from_chat_id required');
357
+ }
358
+ if (message_id === undefined || message_id === null) {
359
+ throw new Error('message_id required');
360
+ }
361
+ const params = {
362
+ chat_id: serialize(chat_id),
363
+ from_chat_id: serialize(from_chat_id),
364
+ message_id,
365
+ message_thread_id,
366
+ direct_messages_topic_id,
367
+ video_start_timestamp,
368
+ caption,
369
+ parse_mode,
370
+ caption_entities: serialize(caption_entities),
371
+ show_caption_above_media,
372
+ disable_notification,
373
+ protect_content,
374
+ allow_paid_broadcast,
375
+ message_effect_id,
376
+ suggested_post_parameters: serialize(suggested_post_parameters),
377
+ reply_parameters: serialize(reply_parameters),
378
+ reply_markup: serialize(reply_markup),
379
+ };
380
+ const clean = Object.fromEntries(Object.entries(params).filter(([_, v]) => v !== undefined && v !== null));
381
+ const result = await this._request('copyMessage', clean);
382
+ return result;
383
+ }
384
+
385
+ async copyMessages(options = {}) {
386
+ const {
387
+ chat_id,
388
+ from_chat_id,
389
+ message_ids,
390
+ message_thread_id,
391
+ direct_messages_topic_id,
392
+ disable_notification,
393
+ protect_content,
394
+ remove_caption,
395
+ } = options;
396
+ if (chat_id === undefined || chat_id === null) {
397
+ throw new Error('chat_id required');
398
+ }
399
+ if (from_chat_id === undefined || from_chat_id === null) {
400
+ throw new Error('from_chat_id required');
401
+ }
402
+ if (!message_ids) {
403
+ throw new Error('message_ids required');
404
+ }
405
+ const params = {
406
+ chat_id: serialize(chat_id),
407
+ from_chat_id: serialize(from_chat_id),
408
+ message_ids: serialize(message_ids),
409
+ message_thread_id,
410
+ direct_messages_topic_id,
411
+ disable_notification,
412
+ protect_content,
413
+ remove_caption,
414
+ };
415
+ const clean = Object.fromEntries(Object.entries(params).filter(([_, v]) => v !== undefined && v !== null));
416
+ const result = await this._request('copyMessages', clean);
417
+ return result;
418
+ }
419
+
420
+ async sendAudio(options = {}) {
421
+ const {
422
+ chat_id,
423
+ audio,
424
+ business_connection_id,
425
+ message_thread_id,
426
+ direct_messages_topic_id,
427
+ caption,
428
+ parse_mode,
429
+ caption_entities,
430
+ duration,
431
+ performer,
432
+ title,
433
+ thumbnail,
434
+ disable_notification,
435
+ protect_content,
436
+ allow_paid_broadcast,
437
+ message_effect_id,
438
+ suggested_post_parameters,
439
+ reply_parameters,
440
+ reply_markup,
441
+ } = options;
442
+ if (chat_id === undefined || chat_id === null) {
443
+ throw new Error('chat_id required');
444
+ }
445
+ if (!audio) {
446
+ throw new Error('audio required');
447
+ }
448
+ const params = {
449
+ chat_id: serialize(chat_id),
450
+ business_connection_id,
451
+ message_thread_id,
452
+ direct_messages_topic_id,
453
+ caption,
454
+ parse_mode,
455
+ caption_entities: serialize(caption_entities),
456
+ duration,
457
+ performer,
458
+ title,
459
+ disable_notification,
460
+ protect_content,
461
+ allow_paid_broadcast,
462
+ message_effect_id,
463
+ suggested_post_parameters: serialize(suggested_post_parameters),
464
+ reply_parameters: serialize(reply_parameters),
465
+ reply_markup: serialize(reply_markup),
466
+ };
467
+ const clean = Object.fromEntries(Object.entries(params).filter(([_, v]) => v !== undefined && v !== null));
468
+ const files = {};
469
+ if (audio instanceof Buffer || (audio && typeof audio.pipe === 'function')) {
470
+ files.audio = audio;
471
+ } else {
472
+ clean.audio = audio;
473
+ }
474
+ if (thumbnail) {
475
+ if (thumbnail instanceof Buffer || (thumbnail && typeof thumbnail.pipe === 'function')) {
476
+ files.thumbnail = thumbnail;
477
+ } else {
478
+ clean.thumbnail = thumbnail;
479
+ }
480
+ }
481
+ const result = await this._request('sendAudio', clean, files);
482
+ return result;
483
+ }
484
+
485
+ async sendDocument(options = {}) {
486
+ const {
487
+ chat_id,
488
+ document,
489
+ business_connection_id,
490
+ message_thread_id,
491
+ direct_messages_topic_id,
492
+ thumbnail,
493
+ caption,
494
+ parse_mode,
495
+ caption_entities,
496
+ disable_content_type_detection,
497
+ disable_notification,
498
+ protect_content,
499
+ allow_paid_broadcast,
500
+ message_effect_id,
501
+ suggested_post_parameters,
502
+ reply_parameters,
503
+ reply_markup,
504
+ } = options;
505
+ if (chat_id === undefined || chat_id === null) {
506
+ throw new Error('chat_id required');
507
+ }
508
+ if (!document) {
509
+ throw new Error('document required');
510
+ }
511
+ const params = {
512
+ chat_id: serialize(chat_id),
513
+ business_connection_id,
514
+ message_thread_id,
515
+ direct_messages_topic_id,
516
+ caption,
517
+ parse_mode,
518
+ caption_entities: serialize(caption_entities),
519
+ disable_content_type_detection,
520
+ disable_notification,
521
+ protect_content,
522
+ allow_paid_broadcast,
523
+ message_effect_id,
524
+ suggested_post_parameters: serialize(suggested_post_parameters),
525
+ reply_parameters: serialize(reply_parameters),
526
+ reply_markup: serialize(reply_markup),
527
+ };
528
+ const clean = Object.fromEntries(Object.entries(params).filter(([_, v]) => v !== undefined && v !== null));
529
+ const files = {};
530
+ if (document instanceof Buffer || (document && typeof document.pipe === 'function')) {
531
+ files.document = document;
532
+ } else {
533
+ clean.document = document;
534
+ }
535
+ if (thumbnail) {
536
+ if (thumbnail instanceof Buffer || (thumbnail && typeof thumbnail.pipe === 'function')) {
537
+ files.thumbnail = thumbnail;
538
+ } else {
539
+ clean.thumbnail = thumbnail;
540
+ }
541
+ }
542
+ const result = await this._request('sendDocument', clean, files);
543
+ return result;
544
+ }
545
+
546
+ async sendVideo(options = {}) {
547
+ const {
548
+ chat_id,
549
+ video,
550
+ business_connection_id,
551
+ message_thread_id,
552
+ direct_messages_topic_id,
553
+ duration,
554
+ width,
555
+ height,
556
+ thumbnail,
557
+ cover,
558
+ start_timestamp,
559
+ caption,
560
+ parse_mode,
561
+ caption_entities,
562
+ show_caption_above_media,
563
+ has_spoiler,
564
+ supports_streaming,
565
+ disable_notification,
566
+ protect_content,
567
+ allow_paid_broadcast,
568
+ message_effect_id,
569
+ suggested_post_parameters,
570
+ reply_parameters,
571
+ reply_markup,
572
+ } = options;
573
+ if (chat_id === undefined || chat_id === null) {
574
+ throw new Error('chat_id required');
575
+ }
576
+ if (!video) {
577
+ throw new Error('video required');
578
+ }
579
+ const params = {
580
+ chat_id: serialize(chat_id),
581
+ business_connection_id,
582
+ message_thread_id,
583
+ direct_messages_topic_id,
584
+ duration,
585
+ width,
586
+ height,
587
+ start_timestamp,
588
+ caption,
589
+ parse_mode,
590
+ caption_entities: serialize(caption_entities),
591
+ show_caption_above_media,
592
+ has_spoiler,
593
+ supports_streaming,
594
+ disable_notification,
595
+ protect_content,
596
+ allow_paid_broadcast,
597
+ message_effect_id,
598
+ suggested_post_parameters: serialize(suggested_post_parameters),
599
+ reply_parameters: serialize(reply_parameters),
600
+ reply_markup: serialize(reply_markup),
601
+ };
602
+ const clean = Object.fromEntries(Object.entries(params).filter(([_, v]) => v !== undefined && v !== null));
603
+ const files = {};
604
+ if (video instanceof Buffer || (video && typeof video.pipe === 'function')) {
605
+ files.video = video;
606
+ } else {
607
+ clean.video = video;
608
+ }
609
+ if (thumbnail) {
610
+ if (thumbnail instanceof Buffer || (thumbnail && typeof thumbnail.pipe === 'function')) {
611
+ files.thumbnail = thumbnail;
612
+ } else {
613
+ clean.thumbnail = thumbnail;
614
+ }
615
+ }
616
+ if (cover) {
617
+ if (cover instanceof Buffer || (cover && typeof cover.pipe === 'function')) {
618
+ files.cover = cover;
619
+ } else {
620
+ clean.cover = cover;
621
+ }
622
+ }
623
+ const result = await this._request('sendVideo', clean, files);
624
+ return result;
625
+ }
626
+
627
+ async sendAnimation(options = {}) {
628
+ const {
629
+ chat_id,
630
+ animation,
631
+ business_connection_id,
632
+ message_thread_id,
633
+ direct_messages_topic_id,
634
+ duration,
635
+ width,
636
+ height,
637
+ thumbnail,
638
+ caption,
639
+ parse_mode,
640
+ caption_entities,
641
+ show_caption_above_media,
642
+ has_spoiler,
643
+ disable_notification,
644
+ protect_content,
645
+ allow_paid_broadcast,
646
+ message_effect_id,
647
+ suggested_post_parameters,
648
+ reply_parameters,
649
+ reply_markup,
650
+ } = options;
651
+ if (chat_id === undefined || chat_id === null) {
652
+ throw new Error('chat_id required');
653
+ }
654
+ if (!animation) {
655
+ throw new Error('animation required');
656
+ }
657
+ const params = {
658
+ chat_id: serialize(chat_id),
659
+ business_connection_id,
660
+ message_thread_id,
661
+ direct_messages_topic_id,
662
+ duration,
663
+ width,
664
+ height,
665
+ caption,
666
+ parse_mode,
667
+ caption_entities: serialize(caption_entities),
668
+ show_caption_above_media,
669
+ has_spoiler,
670
+ disable_notification,
671
+ protect_content,
672
+ allow_paid_broadcast,
673
+ message_effect_id,
674
+ suggested_post_parameters: serialize(suggested_post_parameters),
675
+ reply_parameters: serialize(reply_parameters),
676
+ reply_markup: serialize(reply_markup),
677
+ };
678
+ const clean = Object.fromEntries(Object.entries(params).filter(([_, v]) => v !== undefined && v !== null));
679
+ const files = {};
680
+ if (animation instanceof Buffer || (animation && typeof animation.pipe === 'function')) {
681
+ files.animation = animation;
682
+ } else {
683
+ clean.animation = animation;
684
+ }
685
+ if (thumbnail) {
686
+ if (thumbnail instanceof Buffer || (thumbnail && typeof thumbnail.pipe === 'function')) {
687
+ files.thumbnail = thumbnail;
688
+ } else {
689
+ clean.thumbnail = thumbnail;
690
+ }
691
+ }
692
+ const result = await this._request('sendAnimation', clean, files);
693
+ return result;
694
+ }
695
+
696
+ async sendVoice(options = {}) {
697
+ const {
698
+ chat_id,
699
+ voice,
700
+ business_connection_id,
701
+ message_thread_id,
702
+ direct_messages_topic_id,
703
+ caption,
704
+ parse_mode,
705
+ caption_entities,
706
+ duration,
707
+ disable_notification,
708
+ protect_content,
709
+ allow_paid_broadcast,
710
+ message_effect_id,
711
+ suggested_post_parameters,
712
+ reply_parameters,
713
+ reply_markup,
714
+ } = options;
715
+ if (chat_id === undefined || chat_id === null) {
716
+ throw new Error('chat_id required');
717
+ }
718
+ if (!voice) {
719
+ throw new Error('voice required');
720
+ }
721
+ const params = {
722
+ chat_id: serialize(chat_id),
723
+ business_connection_id,
724
+ message_thread_id,
725
+ direct_messages_topic_id,
726
+ caption,
727
+ parse_mode,
728
+ caption_entities: serialize(caption_entities),
729
+ duration,
730
+ disable_notification,
731
+ protect_content,
732
+ allow_paid_broadcast,
733
+ message_effect_id,
734
+ suggested_post_parameters: serialize(suggested_post_parameters),
735
+ reply_parameters: serialize(reply_parameters),
736
+ reply_markup: serialize(reply_markup),
737
+ };
738
+ const clean = Object.fromEntries(Object.entries(params).filter(([_, v]) => v !== undefined && v !== null));
739
+ const files = {};
740
+ if (voice instanceof Buffer || (voice && typeof voice.pipe === 'function')) {
741
+ files.voice = voice;
742
+ } else {
743
+ clean.voice = voice;
744
+ }
745
+ const result = await this._request('sendVoice', clean, files);
746
+ return result;
747
+ }
748
+
749
+ async sendVideoNote(options = {}) {
750
+ const {
751
+ chat_id,
752
+ video_note,
753
+ business_connection_id,
754
+ message_thread_id,
755
+ direct_messages_topic_id,
756
+ duration,
757
+ length,
758
+ thumbnail,
759
+ disable_notification,
760
+ protect_content,
761
+ allow_paid_broadcast,
762
+ message_effect_id,
763
+ suggested_post_parameters,
764
+ reply_parameters,
765
+ reply_markup,
766
+ } = options;
767
+ if (chat_id === undefined || chat_id === null) {
768
+ throw new Error('chat_id required');
769
+ }
770
+ if (!video_note) {
771
+ throw new Error('video_note required');
772
+ }
773
+ const params = {
774
+ chat_id: serialize(chat_id),
775
+ business_connection_id,
776
+ message_thread_id,
777
+ direct_messages_topic_id,
778
+ duration,
779
+ length,
780
+ disable_notification,
781
+ protect_content,
782
+ allow_paid_broadcast,
783
+ message_effect_id,
784
+ suggested_post_parameters: serialize(suggested_post_parameters),
785
+ reply_parameters: serialize(reply_parameters),
786
+ reply_markup: serialize(reply_markup),
787
+ };
788
+ const clean = Object.fromEntries(Object.entries(params).filter(([_, v]) => v !== undefined && v !== null));
789
+ const files = {};
790
+ if (video_note instanceof Buffer || (video_note && typeof video_note.pipe === 'function')) {
791
+ files.video_note = video_note;
792
+ } else {
793
+ clean.video_note = video_note;
794
+ }
795
+ if (thumbnail) {
796
+ if (thumbnail instanceof Buffer || (thumbnail && typeof thumbnail.pipe === 'function')) {
797
+ files.thumbnail = thumbnail;
798
+ } else {
799
+ clean.thumbnail = thumbnail;
800
+ }
801
+ }
802
+ const result = await this._request('sendVideoNote', clean, files);
803
+ return result;
804
+ }
805
+
806
+ async sendPaidMedia(options = {}) {
807
+ const {
808
+ chat_id,
809
+ star_count,
810
+ media,
811
+ business_connection_id,
812
+ message_thread_id,
813
+ direct_messages_topic_id,
814
+ payload,
815
+ caption,
816
+ parse_mode,
817
+ caption_entities,
818
+ show_caption_above_media,
819
+ disable_notification,
820
+ protect_content,
821
+ allow_paid_broadcast,
822
+ suggested_post_parameters,
823
+ reply_parameters,
824
+ reply_markup,
825
+ } = options;
826
+
827
+ if (chat_id === undefined || chat_id === null) {
828
+ throw new Error('chat_id');
829
+ }
830
+ if (star_count === undefined || star_count === null) {
831
+ throw new Error('star_count');
832
+ }
833
+ if (media === undefined || media === null) {
834
+ throw new Error('media');
835
+ }
836
+
837
+ const params = {
838
+ chat_id: serialize(chat_id),
839
+ star_count: star_count,
840
+ media: serialize(media),
841
+ business_connection_id: business_connection_id,
842
+ message_thread_id: message_thread_id,
843
+ direct_messages_topic_id: direct_messages_topic_id,
844
+ payload: payload,
845
+ caption: caption,
846
+ parse_mode: parse_mode,
847
+ caption_entities: serialize(caption_entities),
848
+ show_caption_above_media: show_caption_above_media,
849
+ disable_notification: disable_notification,
850
+ protect_content: protect_content,
851
+ allow_paid_broadcast: allow_paid_broadcast,
852
+ suggested_post_parameters: serialize(suggested_post_parameters),
853
+ reply_parameters: serialize(reply_parameters),
854
+ reply_markup: serialize(reply_markup),
855
+ };
856
+ const clean = Object.fromEntries(Object.entries(params).filter(([_, v]) => v !== undefined && v !== null));
857
+ const result = await this._request('sendPaidMedia', clean);
858
+ return result;
859
+ }
860
+
861
+ async sendMediaGroup(options = {}) {
862
+ const {
863
+ chat_id,
864
+ media,
865
+ business_connection_id,
866
+ message_thread_id,
867
+ direct_messages_topic_id,
868
+ disable_notification,
869
+ protect_content,
870
+ allow_paid_broadcast,
871
+ message_effect_id,
872
+ reply_parameters,
873
+ } = options;
874
+
875
+ if (chat_id === undefined || chat_id === null) {
876
+ throw new Error('chat_id');
877
+ }
878
+ if (media === undefined || media === null) {
879
+ throw new Error('media');
880
+ }
881
+
882
+ const params = {
883
+ chat_id: serialize(chat_id),
884
+ media: serialize(media),
885
+ business_connection_id: business_connection_id,
886
+ message_thread_id: message_thread_id,
887
+ direct_messages_topic_id: direct_messages_topic_id,
888
+ disable_notification: disable_notification,
889
+ protect_content: protect_content,
890
+ allow_paid_broadcast: allow_paid_broadcast,
891
+ message_effect_id: message_effect_id,
892
+ reply_parameters: serialize(reply_parameters),
893
+ };
894
+ const clean = Object.fromEntries(Object.entries(params).filter(([_, v]) => v !== undefined && v !== null));
895
+ const result = await this._request('sendMediaGroup', clean);
896
+ return result;
897
+ }
898
+
899
+ async sendLocation(options = {}) {
900
+ const {
901
+ chat_id,
902
+ latitude,
903
+ longitude,
904
+ business_connection_id,
905
+ message_thread_id,
906
+ direct_messages_topic_id,
907
+ horizontal_accuracy,
908
+ live_period,
909
+ heading,
910
+ proximity_alert_radius,
911
+ disable_notification,
912
+ protect_content,
913
+ allow_paid_broadcast,
914
+ message_effect_id,
915
+ suggested_post_parameters,
916
+ reply_parameters,
917
+ reply_markup,
918
+ } = options;
919
+
920
+ if (chat_id === undefined || chat_id === null) {
921
+ throw new Error('chat_id');
922
+ }
923
+ if (latitude === undefined || latitude === null) {
924
+ throw new Error('latitude');
925
+ }
926
+ if (longitude === undefined || longitude === null) {
927
+ throw new Error('longitude');
928
+ }
929
+
930
+ const params = {
931
+ chat_id: serialize(chat_id),
932
+ latitude: latitude,
933
+ longitude: longitude,
934
+ business_connection_id: business_connection_id,
935
+ message_thread_id: message_thread_id,
936
+ direct_messages_topic_id: direct_messages_topic_id,
937
+ horizontal_accuracy: horizontal_accuracy,
938
+ live_period: live_period,
939
+ heading: heading,
940
+ proximity_alert_radius: proximity_alert_radius,
941
+ disable_notification: disable_notification,
942
+ protect_content: protect_content,
943
+ allow_paid_broadcast: allow_paid_broadcast,
944
+ message_effect_id: message_effect_id,
945
+ suggested_post_parameters: serialize(suggested_post_parameters),
946
+ reply_parameters: serialize(reply_parameters),
947
+ reply_markup: serialize(reply_markup),
948
+ };
949
+ const clean = Object.fromEntries(Object.entries(params).filter(([_, v]) => v !== undefined && v !== null));
950
+ const result = await this._request('sendLocation', clean);
951
+ return result;
952
+ }
953
+
954
+ async sendVenue(options = {}) {
955
+ const {
956
+ chat_id,
957
+ latitude,
958
+ longitude,
959
+ title,
960
+ address,
961
+ business_connection_id,
962
+ message_thread_id,
963
+ direct_messages_topic_id,
964
+ foursquare_id,
965
+ foursquare_type,
966
+ google_place_id,
967
+ google_place_type,
968
+ disable_notification,
969
+ protect_content,
970
+ allow_paid_broadcast,
971
+ message_effect_id,
972
+ suggested_post_parameters,
973
+ reply_parameters,
974
+ reply_markup,
975
+ } = options;
976
+
977
+ if (chat_id === undefined || chat_id === null) {
978
+ throw new Error('chat_id');
979
+ }
980
+ if (latitude === undefined || latitude === null) {
981
+ throw new Error('latitude');
982
+ }
983
+ if (longitude === undefined || longitude === null) {
984
+ throw new Error('longitude');
985
+ }
986
+ if (title === undefined || title === null) {
987
+ throw new Error('title');
988
+ }
989
+ if (address === undefined || address === null) {
990
+ throw new Error('address');
991
+ }
992
+
993
+ const params = {
994
+ chat_id: serialize(chat_id),
995
+ latitude: latitude,
996
+ longitude: longitude,
997
+ title: title,
998
+ address: address,
999
+ business_connection_id: business_connection_id,
1000
+ message_thread_id: message_thread_id,
1001
+ direct_messages_topic_id: direct_messages_topic_id,
1002
+ foursquare_id: foursquare_id,
1003
+ foursquare_type: foursquare_type,
1004
+ google_place_id: google_place_id,
1005
+ google_place_type: google_place_type,
1006
+ disable_notification: disable_notification,
1007
+ protect_content: protect_content,
1008
+ allow_paid_broadcast: allow_paid_broadcast,
1009
+ message_effect_id: message_effect_id,
1010
+ suggested_post_parameters: serialize(suggested_post_parameters),
1011
+ reply_parameters: serialize(reply_parameters),
1012
+ reply_markup: serialize(reply_markup),
1013
+ };
1014
+ const clean = Object.fromEntries(Object.entries(params).filter(([_, v]) => v !== undefined && v !== null));
1015
+ const result = await this._request('sendVenue', clean);
1016
+ return result;
1017
+ }
1018
+
1019
+ async sendContact(options = {}) {
1020
+ const {
1021
+ chat_id,
1022
+ phone_number,
1023
+ first_name,
1024
+ business_connection_id,
1025
+ message_thread_id,
1026
+ direct_messages_topic_id,
1027
+ last_name,
1028
+ vcard,
1029
+ disable_notification,
1030
+ protect_content,
1031
+ allow_paid_broadcast,
1032
+ message_effect_id,
1033
+ suggested_post_parameters,
1034
+ reply_parameters,
1035
+ reply_markup,
1036
+ } = options;
1037
+
1038
+ if (chat_id === undefined || chat_id === null) {
1039
+ throw new Error('chat_id');
1040
+ }
1041
+ if (phone_number === undefined || phone_number === null) {
1042
+ throw new Error('phone_number');
1043
+ }
1044
+ if (first_name === undefined || first_name === null) {
1045
+ throw new Error('first_name');
1046
+ }
1047
+
1048
+ const params = {
1049
+ chat_id: serialize(chat_id),
1050
+ phone_number: phone_number,
1051
+ first_name: first_name,
1052
+ business_connection_id: business_connection_id,
1053
+ message_thread_id: message_thread_id,
1054
+ direct_messages_topic_id: direct_messages_topic_id,
1055
+ last_name: last_name,
1056
+ vcard: vcard,
1057
+ disable_notification: disable_notification,
1058
+ protect_content: protect_content,
1059
+ allow_paid_broadcast: allow_paid_broadcast,
1060
+ message_effect_id: message_effect_id,
1061
+ suggested_post_parameters: serialize(suggested_post_parameters),
1062
+ reply_parameters: serialize(reply_parameters),
1063
+ reply_markup: serialize(reply_markup),
1064
+ };
1065
+ const clean = Object.fromEntries(Object.entries(params).filter(([_, v]) => v !== undefined && v !== null));
1066
+ const result = await this._request('sendContact', clean);
1067
+ return result;
1068
+ }
1069
+
1070
+ async sendPoll(options = {}) {
1071
+ const {
1072
+ chat_id,
1073
+ question,
1074
+ options: poll_options,
1075
+ business_connection_id,
1076
+ message_thread_id,
1077
+ question_parse_mode,
1078
+ question_entities,
1079
+ is_anonymous,
1080
+ type,
1081
+ allows_multiple_answers,
1082
+ correct_option_id,
1083
+ explanation,
1084
+ explanation_parse_mode,
1085
+ explanation_entities,
1086
+ open_period,
1087
+ close_date,
1088
+ is_closed,
1089
+ disable_notification,
1090
+ protect_content,
1091
+ allow_paid_broadcast,
1092
+ message_effect_id,
1093
+ reply_parameters,
1094
+ reply_markup,
1095
+ } = options;
1096
+
1097
+ if (chat_id === undefined || chat_id === null) {
1098
+ throw new Error('chat_id');
1099
+ }
1100
+ if (question === undefined || question === null) {
1101
+ throw new Error('question');
1102
+ }
1103
+ if (options === undefined || options === null) {
1104
+ throw new Error('options');
1105
+ }
1106
+
1107
+ const params = {
1108
+ chat_id: serialize(chat_id),
1109
+ question: question,
1110
+ options: serialize(poll_options),
1111
+ business_connection_id: business_connection_id,
1112
+ message_thread_id: message_thread_id,
1113
+ question_parse_mode: question_parse_mode,
1114
+ question_entities: serialize(question_entities),
1115
+ is_anonymous: is_anonymous,
1116
+ type: type,
1117
+ allows_multiple_answers: allows_multiple_answers,
1118
+ correct_option_id: correct_option_id,
1119
+ explanation: explanation,
1120
+ explanation_parse_mode: explanation_parse_mode,
1121
+ explanation_entities: serialize(explanation_entities),
1122
+ open_period: open_period,
1123
+ close_date: close_date,
1124
+ is_closed: is_closed,
1125
+ disable_notification: disable_notification,
1126
+ protect_content: protect_content,
1127
+ allow_paid_broadcast: allow_paid_broadcast,
1128
+ message_effect_id: message_effect_id,
1129
+ reply_parameters: serialize(reply_parameters),
1130
+ reply_markup: serialize(reply_markup),
1131
+ };
1132
+ const clean = Object.fromEntries(Object.entries(params).filter(([_, v]) => v !== undefined && v !== null));
1133
+ const result = await this._request('sendPoll', clean);
1134
+ return result;
1135
+ }
1136
+
1137
+ async sendChecklist(options = {}) {
1138
+ const {
1139
+ business_connection_id,
1140
+ chat_id,
1141
+ checklist,
1142
+ disable_notification,
1143
+ protect_content,
1144
+ message_effect_id,
1145
+ reply_parameters,
1146
+ reply_markup,
1147
+ } = options;
1148
+
1149
+ if (business_connection_id === undefined || business_connection_id === null) {
1150
+ throw new Error('business_connection_id');
1151
+ }
1152
+ if (chat_id === undefined || chat_id === null) {
1153
+ throw new Error('chat_id');
1154
+ }
1155
+ if (checklist === undefined || checklist === null) {
1156
+ throw new Error('checklist');
1157
+ }
1158
+
1159
+ const params = {
1160
+ business_connection_id: business_connection_id,
1161
+ chat_id: chat_id,
1162
+ checklist: serialize(checklist),
1163
+ disable_notification: disable_notification,
1164
+ protect_content: protect_content,
1165
+ message_effect_id: message_effect_id,
1166
+ reply_parameters: serialize(reply_parameters),
1167
+ reply_markup: serialize(reply_markup),
1168
+ };
1169
+ const clean = Object.fromEntries(Object.entries(params).filter(([_, v]) => v !== undefined && v !== null));
1170
+ const result = await this._request('sendChecklist', clean);
1171
+ return result;
1172
+ }
1173
+
1174
+ async sendDice(options = {}) {
1175
+ const {
1176
+ chat_id,
1177
+ business_connection_id,
1178
+ message_thread_id,
1179
+ direct_messages_topic_id,
1180
+ emoji,
1181
+ disable_notification,
1182
+ protect_content,
1183
+ allow_paid_broadcast,
1184
+ message_effect_id,
1185
+ suggested_post_parameters,
1186
+ reply_parameters,
1187
+ reply_markup,
1188
+ } = options;
1189
+
1190
+ if (chat_id === undefined || chat_id === null) {
1191
+ throw new Error('chat_id');
1192
+ }
1193
+
1194
+ const params = {
1195
+ chat_id: serialize(chat_id),
1196
+ business_connection_id: business_connection_id,
1197
+ message_thread_id: message_thread_id,
1198
+ direct_messages_topic_id: direct_messages_topic_id,
1199
+ emoji: emoji,
1200
+ disable_notification: disable_notification,
1201
+ protect_content: protect_content,
1202
+ allow_paid_broadcast: allow_paid_broadcast,
1203
+ message_effect_id: message_effect_id,
1204
+ suggested_post_parameters: serialize(suggested_post_parameters),
1205
+ reply_parameters: serialize(reply_parameters),
1206
+ reply_markup: serialize(reply_markup),
1207
+ };
1208
+ const clean = Object.fromEntries(Object.entries(params).filter(([_, v]) => v !== undefined && v !== null));
1209
+ const result = await this._request('sendDice', clean);
1210
+ return result;
1211
+ }
1212
+
1213
+ async sendMessageDraft(options = {}) {
1214
+ const {
1215
+ chat_id,
1216
+ draft_id,
1217
+ text,
1218
+ message_thread_id,
1219
+ parse_mode,
1220
+ entities,
1221
+ } = options;
1222
+
1223
+ if (chat_id === undefined || chat_id === null) {
1224
+ throw new Error('chat_id');
1225
+ }
1226
+ if (draft_id === undefined || draft_id === null) {
1227
+ throw new Error('draft_id');
1228
+ }
1229
+ if (text === undefined || text === null) {
1230
+ throw new Error('text');
1231
+ }
1232
+
1233
+ const params = {
1234
+ chat_id: chat_id,
1235
+ draft_id: draft_id,
1236
+ text: text,
1237
+ message_thread_id: message_thread_id,
1238
+ parse_mode: parse_mode,
1239
+ entities: serialize(entities),
1240
+ };
1241
+ const clean = Object.fromEntries(Object.entries(params).filter(([_, v]) => v !== undefined && v !== null));
1242
+ const result = await this._request('sendMessageDraft', clean);
1243
+ return !!result;
1244
+ }
1245
+
1246
+ async sendChatAction(options = {}) {
1247
+ const {
1248
+ chat_id,
1249
+ action,
1250
+ business_connection_id,
1251
+ message_thread_id,
1252
+ } = options;
1253
+
1254
+ if (chat_id === undefined || chat_id === null) {
1255
+ throw new Error('chat_id');
1256
+ }
1257
+ if (action === undefined || action === null) {
1258
+ throw new Error('action');
1259
+ }
1260
+
1261
+ const params = {
1262
+ chat_id: serialize(chat_id),
1263
+ action: action,
1264
+ business_connection_id: business_connection_id,
1265
+ message_thread_id: message_thread_id,
1266
+ };
1267
+ const clean = Object.fromEntries(Object.entries(params).filter(([_, v]) => v !== undefined && v !== null));
1268
+ const result = await this._request('sendChatAction', clean);
1269
+ return !!result;
1270
+ }
1271
+
1272
+ async setMessageReaction(options = {}) {
1273
+ const {
1274
+ chat_id,
1275
+ message_id,
1276
+ reaction,
1277
+ is_big,
1278
+ } = options;
1279
+
1280
+ if (chat_id === undefined || chat_id === null) {
1281
+ throw new Error('chat_id');
1282
+ }
1283
+ if (message_id === undefined || message_id === null) {
1284
+ throw new Error('message_id');
1285
+ }
1286
+
1287
+ const params = {
1288
+ chat_id: serialize(chat_id),
1289
+ message_id: message_id,
1290
+ reaction: serialize(reaction),
1291
+ is_big: is_big,
1292
+ };
1293
+ const clean = Object.fromEntries(Object.entries(params).filter(([_, v]) => v !== undefined && v !== null));
1294
+ const result = await this._request('setMessageReaction', clean);
1295
+ return !!result;
1296
+ }
1297
+
1298
+ async getUserProfilePhotos(options = {}) {
1299
+ const {
1300
+ user_id,
1301
+ offset,
1302
+ limit,
1303
+ } = options;
1304
+
1305
+ if (user_id === undefined || user_id === null) {
1306
+ throw new Error('user_id');
1307
+ }
1308
+
1309
+ const params = {
1310
+ user_id: user_id,
1311
+ offset: offset,
1312
+ limit: limit,
1313
+ };
1314
+ const clean = Object.fromEntries(Object.entries(params).filter(([_, v]) => v !== undefined && v !== null));
1315
+ const result = await this._request('getUserProfilePhotos', clean);
1316
+ return result;
1317
+ }
1318
+
1319
+ async setUserEmojiStatus(options = {}) {
1320
+ const {
1321
+ user_id,
1322
+ emoji_status_custom_emoji_id,
1323
+ emoji_status_expiration_date,
1324
+ } = options;
1325
+
1326
+ if (user_id === undefined || user_id === null) {
1327
+ throw new Error('user_id');
1328
+ }
1329
+
1330
+ const params = {
1331
+ user_id: user_id,
1332
+ emoji_status_custom_emoji_id: emoji_status_custom_emoji_id,
1333
+ emoji_status_expiration_date: emoji_status_expiration_date,
1334
+ };
1335
+ const clean = Object.fromEntries(Object.entries(params).filter(([_, v]) => v !== undefined && v !== null));
1336
+ const result = await this._request('setUserEmojiStatus', clean);
1337
+ return !!result;
1338
+ }
1339
+
1340
+ async getFile(options = {}) {
1341
+ const {
1342
+ file_id,
1343
+ } = options;
1344
+
1345
+ if (file_id === undefined || file_id === null) {
1346
+ throw new Error('file_id');
1347
+ }
1348
+
1349
+ const params = {
1350
+ file_id: file_id,
1351
+ };
1352
+ const clean = Object.fromEntries(Object.entries(params).filter(([_, v]) => v !== undefined && v !== null));
1353
+ const result = await this._request('getFile', clean);
1354
+ return result;
1355
+ }
1356
+
1357
+ async banChatMember(options = {}) {
1358
+ const {
1359
+ chat_id,
1360
+ user_id,
1361
+ until_date,
1362
+ revoke_messages,
1363
+ } = options;
1364
+
1365
+ if (chat_id === undefined || chat_id === null) {
1366
+ throw new Error('chat_id');
1367
+ }
1368
+ if (user_id === undefined || user_id === null) {
1369
+ throw new Error('user_id');
1370
+ }
1371
+
1372
+ const params = {
1373
+ chat_id: serialize(chat_id),
1374
+ user_id: user_id,
1375
+ until_date: until_date,
1376
+ revoke_messages: revoke_messages,
1377
+ };
1378
+ const clean = Object.fromEntries(Object.entries(params).filter(([_, v]) => v !== undefined && v !== null));
1379
+ const result = await this._request('banChatMember', clean);
1380
+ return !!result;
1381
+ }
1382
+
1383
+ async unbanChatMember(options = {}) {
1384
+ const {
1385
+ chat_id,
1386
+ user_id,
1387
+ only_if_banned,
1388
+ } = options;
1389
+
1390
+ if (chat_id === undefined || chat_id === null) {
1391
+ throw new Error('chat_id');
1392
+ }
1393
+ if (user_id === undefined || user_id === null) {
1394
+ throw new Error('user_id');
1395
+ }
1396
+
1397
+ const params = {
1398
+ chat_id: serialize(chat_id),
1399
+ user_id: user_id,
1400
+ only_if_banned: only_if_banned,
1401
+ };
1402
+ const clean = Object.fromEntries(Object.entries(params).filter(([_, v]) => v !== undefined && v !== null));
1403
+ const result = await this._request('unbanChatMember', clean);
1404
+ return !!result;
1405
+ }
1406
+
1407
+ async restrictChatMember(options = {}) {
1408
+ const {
1409
+ chat_id,
1410
+ user_id,
1411
+ permissions,
1412
+ use_independent_chat_permissions,
1413
+ until_date,
1414
+ } = options;
1415
+
1416
+ if (chat_id === undefined || chat_id === null) {
1417
+ throw new Error('chat_id');
1418
+ }
1419
+ if (user_id === undefined || user_id === null) {
1420
+ throw new Error('user_id');
1421
+ }
1422
+ if (permissions === undefined || permissions === null) {
1423
+ throw new Error('permissions');
1424
+ }
1425
+
1426
+ const params = {
1427
+ chat_id: serialize(chat_id),
1428
+ user_id: user_id,
1429
+ permissions: serialize(permissions),
1430
+ use_independent_chat_permissions: use_independent_chat_permissions,
1431
+ until_date: until_date,
1432
+ };
1433
+ const clean = Object.fromEntries(Object.entries(params).filter(([_, v]) => v !== undefined && v !== null));
1434
+ const result = await this._request('restrictChatMember', clean);
1435
+ return !!result;
1436
+ }
1437
+
1438
+ async promoteChatMember(options = {}) {
1439
+ const {
1440
+ chat_id,
1441
+ user_id,
1442
+ is_anonymous,
1443
+ can_manage_chat,
1444
+ can_delete_messages,
1445
+ can_manage_video_chats,
1446
+ can_restrict_members,
1447
+ can_promote_members,
1448
+ can_change_info,
1449
+ can_invite_users,
1450
+ can_post_stories,
1451
+ can_edit_stories,
1452
+ can_delete_stories,
1453
+ can_post_messages,
1454
+ can_edit_messages,
1455
+ can_pin_messages,
1456
+ can_manage_topics,
1457
+ can_manage_direct_messages,
1458
+ } = options;
1459
+
1460
+ if (chat_id === undefined || chat_id === null) {
1461
+ throw new Error('chat_id');
1462
+ }
1463
+ if (user_id === undefined || user_id === null) {
1464
+ throw new Error('user_id');
1465
+ }
1466
+
1467
+ const params = {
1468
+ chat_id: serialize(chat_id),
1469
+ user_id: user_id,
1470
+ is_anonymous: is_anonymous,
1471
+ can_manage_chat: can_manage_chat,
1472
+ can_delete_messages: can_delete_messages,
1473
+ can_manage_video_chats: can_manage_video_chats,
1474
+ can_restrict_members: can_restrict_members,
1475
+ can_promote_members: can_promote_members,
1476
+ can_change_info: can_change_info,
1477
+ can_invite_users: can_invite_users,
1478
+ can_post_stories: can_post_stories,
1479
+ can_edit_stories: can_edit_stories,
1480
+ can_delete_stories: can_delete_stories,
1481
+ can_post_messages: can_post_messages,
1482
+ can_edit_messages: can_edit_messages,
1483
+ can_pin_messages: can_pin_messages,
1484
+ can_manage_topics: can_manage_topics,
1485
+ can_manage_direct_messages: can_manage_direct_messages,
1486
+ };
1487
+ const clean = Object.fromEntries(Object.entries(params).filter(([_, v]) => v !== undefined && v !== null));
1488
+ const result = await this._request('promoteChatMember', clean);
1489
+ return !!result;
1490
+ }
1491
+
1492
+ async setChatAdministratorCustomTitle(options = {}) {
1493
+ const {
1494
+ chat_id,
1495
+ user_id,
1496
+ custom_title,
1497
+ } = options;
1498
+
1499
+ if (chat_id === undefined || chat_id === null) {
1500
+ throw new Error('chat_id');
1501
+ }
1502
+ if (user_id === undefined || user_id === null) {
1503
+ throw new Error('user_id');
1504
+ }
1505
+ if (custom_title === undefined || custom_title === null) {
1506
+ throw new Error('custom_title');
1507
+ }
1508
+
1509
+ const params = {
1510
+ chat_id: serialize(chat_id),
1511
+ user_id: user_id,
1512
+ custom_title: custom_title,
1513
+ };
1514
+ const clean = Object.fromEntries(Object.entries(params).filter(([_, v]) => v !== undefined && v !== null));
1515
+ const result = await this._request('setChatAdministratorCustomTitle', clean);
1516
+ return !!result;
1517
+ }
1518
+
1519
+ async banChatSenderChat(options = {}) {
1520
+ const {
1521
+ chat_id,
1522
+ sender_chat_id,
1523
+ } = options;
1524
+
1525
+ if (chat_id === undefined || chat_id === null) {
1526
+ throw new Error('chat_id');
1527
+ }
1528
+ if (sender_chat_id === undefined || sender_chat_id === null) {
1529
+ throw new Error('sender_chat_id');
1530
+ }
1531
+
1532
+ const params = {
1533
+ chat_id: serialize(chat_id),
1534
+ sender_chat_id: sender_chat_id,
1535
+ };
1536
+ const clean = Object.fromEntries(Object.entries(params).filter(([_, v]) => v !== undefined && v !== null));
1537
+ const result = await this._request('banChatSenderChat', clean);
1538
+ return !!result;
1539
+ }
1540
+
1541
+ async unbanChatSenderChat(options = {}) {
1542
+ const {
1543
+ chat_id,
1544
+ sender_chat_id,
1545
+ } = options;
1546
+
1547
+ if (chat_id === undefined || chat_id === null) {
1548
+ throw new Error('chat_id');
1549
+ }
1550
+ if (sender_chat_id === undefined || sender_chat_id === null) {
1551
+ throw new Error('sender_chat_id');
1552
+ }
1553
+
1554
+ const params = {
1555
+ chat_id: serialize(chat_id),
1556
+ sender_chat_id: sender_chat_id,
1557
+ };
1558
+ const clean = Object.fromEntries(Object.entries(params).filter(([_, v]) => v !== undefined && v !== null));
1559
+ const result = await this._request('unbanChatSenderChat', clean);
1560
+ return !!result;
1561
+ }
1562
+
1563
+ async setChatPermissions(options = {}) {
1564
+ const {
1565
+ chat_id,
1566
+ permissions,
1567
+ use_independent_chat_permissions,
1568
+ } = options;
1569
+
1570
+ if (chat_id === undefined || chat_id === null) {
1571
+ throw new Error('chat_id');
1572
+ }
1573
+ if (permissions === undefined || permissions === null) {
1574
+ throw new Error('permissions');
1575
+ }
1576
+
1577
+ const params = {
1578
+ chat_id: serialize(chat_id),
1579
+ permissions: serialize(permissions),
1580
+ use_independent_chat_permissions: use_independent_chat_permissions,
1581
+ };
1582
+ const clean = Object.fromEntries(Object.entries(params).filter(([_, v]) => v !== undefined && v !== null));
1583
+ const result = await this._request('setChatPermissions', clean);
1584
+ return !!result;
1585
+ }
1586
+
1587
+ async exportChatInviteLink(options = {}) {
1588
+ const {
1589
+ chat_id,
1590
+ } = options;
1591
+
1592
+ if (chat_id === undefined || chat_id === null) {
1593
+ throw new Error('chat_id');
1594
+ }
1595
+
1596
+ const params = {
1597
+ chat_id: serialize(chat_id),
1598
+ };
1599
+ const clean = Object.fromEntries(Object.entries(params).filter(([_, v]) => v !== undefined && v !== null));
1600
+ const result = await this._request('exportChatInviteLink', clean);
1601
+ return !!result;
1602
+ }
1603
+
1604
+ async createChatInviteLink(options = {}) {
1605
+ const {
1606
+ chat_id,
1607
+ name,
1608
+ expire_date,
1609
+ member_limit,
1610
+ creates_join_request,
1611
+ } = options;
1612
+
1613
+ if (chat_id === undefined || chat_id === null) {
1614
+ throw new Error('chat_id');
1615
+ }
1616
+
1617
+ const params = {
1618
+ chat_id: serialize(chat_id),
1619
+ name: name,
1620
+ expire_date: expire_date,
1621
+ member_limit: member_limit,
1622
+ creates_join_request: creates_join_request,
1623
+ };
1624
+ const clean = Object.fromEntries(Object.entries(params).filter(([_, v]) => v !== undefined && v !== null));
1625
+ const result = await this._request('createChatInviteLink', clean);
1626
+ return result;
1627
+ }
1628
+
1629
+ async editChatInviteLink(options = {}) {
1630
+ const {
1631
+ chat_id,
1632
+ invite_link,
1633
+ name,
1634
+ expire_date,
1635
+ member_limit,
1636
+ creates_join_request,
1637
+ } = options;
1638
+
1639
+ if (chat_id === undefined || chat_id === null) {
1640
+ throw new Error('chat_id');
1641
+ }
1642
+ if (invite_link === undefined || invite_link === null) {
1643
+ throw new Error('invite_link');
1644
+ }
1645
+
1646
+ const params = {
1647
+ chat_id: serialize(chat_id),
1648
+ invite_link: invite_link,
1649
+ name: name,
1650
+ expire_date: expire_date,
1651
+ member_limit: member_limit,
1652
+ creates_join_request: creates_join_request,
1653
+ };
1654
+ const clean = Object.fromEntries(Object.entries(params).filter(([_, v]) => v !== undefined && v !== null));
1655
+ const result = await this._request('editChatInviteLink', clean);
1656
+ return result;
1657
+ }
1658
+
1659
+ async createChatSubscriptionInviteLink(options = {}) {
1660
+ const {
1661
+ chat_id,
1662
+ subscription_period,
1663
+ subscription_price,
1664
+ name,
1665
+ } = options;
1666
+
1667
+ if (chat_id === undefined || chat_id === null) {
1668
+ throw new Error('chat_id');
1669
+ }
1670
+ if (subscription_period === undefined || subscription_period === null) {
1671
+ throw new Error('subscription_period');
1672
+ }
1673
+ if (subscription_price === undefined || subscription_price === null) {
1674
+ throw new Error('subscription_price');
1675
+ }
1676
+
1677
+ const params = {
1678
+ chat_id: serialize(chat_id),
1679
+ subscription_period: subscription_period,
1680
+ subscription_price: subscription_price,
1681
+ name: name,
1682
+ };
1683
+ const clean = Object.fromEntries(Object.entries(params).filter(([_, v]) => v !== undefined && v !== null));
1684
+ const result = await this._request('createChatSubscriptionInviteLink', clean);
1685
+ return result;
1686
+ }
1687
+
1688
+ async editChatSubscriptionInviteLink(options = {}) {
1689
+ const {
1690
+ chat_id,
1691
+ invite_link,
1692
+ name,
1693
+ } = options;
1694
+
1695
+ if (chat_id === undefined || chat_id === null) {
1696
+ throw new Error('chat_id');
1697
+ }
1698
+ if (invite_link === undefined || invite_link === null) {
1699
+ throw new Error('invite_link');
1700
+ }
1701
+
1702
+ const params = {
1703
+ chat_id: serialize(chat_id),
1704
+ invite_link: invite_link,
1705
+ name: name,
1706
+ };
1707
+ const clean = Object.fromEntries(Object.entries(params).filter(([_, v]) => v !== undefined && v !== null));
1708
+ const result = await this._request('editChatSubscriptionInviteLink', clean);
1709
+ return result;
1710
+ }
1711
+
1712
+ async revokeChatInviteLink(options = {}) {
1713
+ const {
1714
+ chat_id,
1715
+ invite_link,
1716
+ } = options;
1717
+
1718
+ if (chat_id === undefined || chat_id === null) {
1719
+ throw new Error('chat_id');
1720
+ }
1721
+ if (invite_link === undefined || invite_link === null) {
1722
+ throw new Error('invite_link');
1723
+ }
1724
+
1725
+ const params = {
1726
+ chat_id: serialize(chat_id),
1727
+ invite_link: invite_link,
1728
+ };
1729
+ const clean = Object.fromEntries(Object.entries(params).filter(([_, v]) => v !== undefined && v !== null));
1730
+ const result = await this._request('revokeChatInviteLink', clean);
1731
+ return result;
1732
+ }
1733
+
1734
+ async approveChatJoinRequest(options = {}) {
1735
+ const {
1736
+ chat_id,
1737
+ user_id,
1738
+ } = options;
1739
+
1740
+ if (chat_id === undefined || chat_id === null) {
1741
+ throw new Error('chat_id');
1742
+ }
1743
+ if (user_id === undefined || user_id === null) {
1744
+ throw new Error('user_id');
1745
+ }
1746
+
1747
+ const params = {
1748
+ chat_id: serialize(chat_id),
1749
+ user_id: user_id,
1750
+ };
1751
+ const clean = Object.fromEntries(Object.entries(params).filter(([_, v]) => v !== undefined && v !== null));
1752
+ const result = await this._request('approveChatJoinRequest', clean);
1753
+ return !!result;
1754
+ }
1755
+
1756
+ async declineChatJoinRequest(options = {}) {
1757
+ const {
1758
+ chat_id,
1759
+ user_id,
1760
+ } = options;
1761
+
1762
+ if (chat_id === undefined || chat_id === null) {
1763
+ throw new Error('chat_id');
1764
+ }
1765
+ if (user_id === undefined || user_id === null) {
1766
+ throw new Error('user_id');
1767
+ }
1768
+
1769
+ const params = {
1770
+ chat_id: serialize(chat_id),
1771
+ user_id: user_id,
1772
+ };
1773
+ const clean = Object.fromEntries(Object.entries(params).filter(([_, v]) => v !== undefined && v !== null));
1774
+ const result = await this._request('declineChatJoinRequest', clean);
1775
+ return !!result;
1776
+ }
1777
+
1778
+ async deleteChatPhoto(options = {}) {
1779
+ const {
1780
+ chat_id,
1781
+ } = options;
1782
+
1783
+ if (chat_id === undefined || chat_id === null) {
1784
+ throw new Error('chat_id');
1785
+ }
1786
+
1787
+ const params = {
1788
+ chat_id: serialize(chat_id),
1789
+ };
1790
+ const clean = Object.fromEntries(Object.entries(params).filter(([_, v]) => v !== undefined && v !== null));
1791
+ const result = await this._request('deleteChatPhoto', clean);
1792
+ return !!result;
1793
+ }
1794
+
1795
+ async setChatTitle(options = {}) {
1796
+ const {
1797
+ chat_id,
1798
+ title,
1799
+ } = options;
1800
+
1801
+ if (chat_id === undefined || chat_id === null) {
1802
+ throw new Error('chat_id');
1803
+ }
1804
+ if (title === undefined || title === null) {
1805
+ throw new Error('title');
1806
+ }
1807
+
1808
+ const params = {
1809
+ chat_id: serialize(chat_id),
1810
+ title: title,
1811
+ };
1812
+ const clean = Object.fromEntries(Object.entries(params).filter(([_, v]) => v !== undefined && v !== null));
1813
+ const result = await this._request('setChatTitle', clean);
1814
+ return !!result;
1815
+ }
1816
+
1817
+ async setChatDescription(options = {}) {
1818
+ const {
1819
+ chat_id,
1820
+ description,
1821
+ } = options;
1822
+
1823
+ if (chat_id === undefined || chat_id === null) {
1824
+ throw new Error('chat_id');
1825
+ }
1826
+
1827
+ const params = {
1828
+ chat_id: serialize(chat_id),
1829
+ description: description,
1830
+ };
1831
+ const clean = Object.fromEntries(Object.entries(params).filter(([_, v]) => v !== undefined && v !== null));
1832
+ const result = await this._request('setChatDescription', clean);
1833
+ return !!result;
1834
+ }
1835
+
1836
+ async pinChatMessage(options = {}) {
1837
+ const {
1838
+ chat_id,
1839
+ message_id,
1840
+ business_connection_id,
1841
+ disable_notification,
1842
+ } = options;
1843
+
1844
+ if (chat_id === undefined || chat_id === null) {
1845
+ throw new Error('chat_id');
1846
+ }
1847
+ if (message_id === undefined || message_id === null) {
1848
+ throw new Error('message_id');
1849
+ }
1850
+
1851
+ const params = {
1852
+ chat_id: serialize(chat_id),
1853
+ message_id: message_id,
1854
+ business_connection_id: business_connection_id,
1855
+ disable_notification: disable_notification,
1856
+ };
1857
+ const clean = Object.fromEntries(Object.entries(params).filter(([_, v]) => v !== undefined && v !== null));
1858
+ const result = await this._request('pinChatMessage', clean);
1859
+ return !!result;
1860
+ }
1861
+
1862
+ async unpinChatMessage(options = {}) {
1863
+ const {
1864
+ chat_id,
1865
+ business_connection_id,
1866
+ message_id,
1867
+ } = options;
1868
+
1869
+ if (chat_id === undefined || chat_id === null) {
1870
+ throw new Error('chat_id');
1871
+ }
1872
+
1873
+ const params = {
1874
+ chat_id: serialize(chat_id),
1875
+ business_connection_id: business_connection_id,
1876
+ message_id: message_id,
1877
+ };
1878
+ const clean = Object.fromEntries(Object.entries(params).filter(([_, v]) => v !== undefined && v !== null));
1879
+ const result = await this._request('unpinChatMessage', clean);
1880
+ return !!result;
1881
+ }
1882
+
1883
+ async unpinAllChatMessages(options = {}) {
1884
+ const {
1885
+ chat_id,
1886
+ } = options;
1887
+
1888
+ if (chat_id === undefined || chat_id === null) {
1889
+ throw new Error('chat_id');
1890
+ }
1891
+
1892
+ const params = {
1893
+ chat_id: serialize(chat_id),
1894
+ };
1895
+ const clean = Object.fromEntries(Object.entries(params).filter(([_, v]) => v !== undefined && v !== null));
1896
+ const result = await this._request('unpinAllChatMessages', clean);
1897
+ return !!result;
1898
+ }
1899
+
1900
+ async leaveChat(options = {}) {
1901
+ const {
1902
+ chat_id,
1903
+ } = options;
1904
+
1905
+ if (chat_id === undefined || chat_id === null) {
1906
+ throw new Error('chat_id');
1907
+ }
1908
+
1909
+ const params = {
1910
+ chat_id: serialize(chat_id),
1911
+ };
1912
+ const clean = Object.fromEntries(Object.entries(params).filter(([_, v]) => v !== undefined && v !== null));
1913
+ const result = await this._request('leaveChat', clean);
1914
+ return !!result;
1915
+ }
1916
+
1917
+ async getChat(options = {}) {
1918
+ const {
1919
+ chat_id,
1920
+ } = options;
1921
+
1922
+ if (chat_id === undefined || chat_id === null) {
1923
+ throw new Error('chat_id');
1924
+ }
1925
+
1926
+ const params = {
1927
+ chat_id: serialize(chat_id),
1928
+ };
1929
+ const clean = Object.fromEntries(Object.entries(params).filter(([_, v]) => v !== undefined && v !== null));
1930
+ const result = await this._request('getChat', clean);
1931
+ return result;
1932
+ }
1933
+
1934
+ async getChatAdministrators(options = {}) {
1935
+ const {
1936
+ chat_id,
1937
+ } = options;
1938
+
1939
+ if (chat_id === undefined || chat_id === null) {
1940
+ throw new Error('chat_id');
1941
+ }
1942
+
1943
+ const params = {
1944
+ chat_id: serialize(chat_id),
1945
+ };
1946
+ const clean = Object.fromEntries(Object.entries(params).filter(([_, v]) => v !== undefined && v !== null));
1947
+ const result = await this._request('getChatAdministrators', clean);
1948
+ return result;
1949
+ }
1950
+
1951
+ async getChatMemberCount(options = {}) {
1952
+ const {
1953
+ chat_id,
1954
+ } = options;
1955
+
1956
+ if (chat_id === undefined || chat_id === null) {
1957
+ throw new Error('chat_id');
1958
+ }
1959
+
1960
+ const params = {
1961
+ chat_id: serialize(chat_id),
1962
+ };
1963
+ const clean = Object.fromEntries(Object.entries(params).filter(([_, v]) => v !== undefined && v !== null));
1964
+ const result = await this._request('getChatMemberCount', clean);
1965
+ return result;
1966
+ }
1967
+
1968
+ async getChatMember(options = {}) {
1969
+ const {
1970
+ chat_id,
1971
+ user_id,
1972
+ } = options;
1973
+
1974
+ if (chat_id === undefined || chat_id === null) {
1975
+ throw new Error('chat_id');
1976
+ }
1977
+ if (user_id === undefined || user_id === null) {
1978
+ throw new Error('user_id');
1979
+ }
1980
+
1981
+ const params = {
1982
+ chat_id: serialize(chat_id),
1983
+ user_id: user_id,
1984
+ };
1985
+ const clean = Object.fromEntries(Object.entries(params).filter(([_, v]) => v !== undefined && v !== null));
1986
+ const result = await this._request('getChatMember', clean);
1987
+ return result;
1988
+ }
1989
+
1990
+ async setChatStickerSet(options = {}) {
1991
+ const {
1992
+ chat_id,
1993
+ sticker_set_name,
1994
+ } = options;
1995
+
1996
+ if (chat_id === undefined || chat_id === null) {
1997
+ throw new Error('chat_id');
1998
+ }
1999
+ if (sticker_set_name === undefined || sticker_set_name === null) {
2000
+ throw new Error('sticker_set_name');
2001
+ }
2002
+
2003
+ const params = {
2004
+ chat_id: serialize(chat_id),
2005
+ sticker_set_name: sticker_set_name,
2006
+ };
2007
+ const clean = Object.fromEntries(Object.entries(params).filter(([_, v]) => v !== undefined && v !== null));
2008
+ const result = await this._request('setChatStickerSet', clean);
2009
+ return !!result;
2010
+ }
2011
+
2012
+ async deleteChatStickerSet(options = {}) {
2013
+ const {
2014
+ chat_id,
2015
+ } = options;
2016
+
2017
+ if (chat_id === undefined || chat_id === null) {
2018
+ throw new Error('chat_id');
2019
+ }
2020
+
2021
+ const params = {
2022
+ chat_id: serialize(chat_id),
2023
+ };
2024
+ const clean = Object.fromEntries(Object.entries(params).filter(([_, v]) => v !== undefined && v !== null));
2025
+ const result = await this._request('deleteChatStickerSet', clean);
2026
+ return !!result;
2027
+ }
2028
+
2029
+ async getForumTopicIconStickers(_) {
2030
+ const params = {
2031
+ };
2032
+ const clean = Object.fromEntries(Object.entries(params).filter(([_, v]) => v !== undefined && v !== null));
2033
+ const result = await this._request('getForumTopicIconStickers', clean);
2034
+ return result;
2035
+ }
2036
+
2037
+ async createForumTopic(options = {}) {
2038
+ const {
2039
+ chat_id,
2040
+ name,
2041
+ icon_color,
2042
+ icon_custom_emoji_id,
2043
+ } = options;
2044
+
2045
+ if (chat_id === undefined || chat_id === null) {
2046
+ throw new Error('chat_id');
2047
+ }
2048
+ if (name === undefined || name === null) {
2049
+ throw new Error('name');
2050
+ }
2051
+
2052
+ const params = {
2053
+ chat_id: serialize(chat_id),
2054
+ name: name,
2055
+ icon_color: icon_color,
2056
+ icon_custom_emoji_id: icon_custom_emoji_id,
2057
+ };
2058
+ const clean = Object.fromEntries(Object.entries(params).filter(([_, v]) => v !== undefined && v !== null));
2059
+ const result = await this._request('createForumTopic', clean);
2060
+ return result;
2061
+ }
2062
+
2063
+ async editForumTopic(options = {}) {
2064
+ const {
2065
+ chat_id,
2066
+ message_thread_id,
2067
+ name,
2068
+ icon_custom_emoji_id,
2069
+ } = options;
2070
+
2071
+ if (chat_id === undefined || chat_id === null) {
2072
+ throw new Error('chat_id');
2073
+ }
2074
+ if (message_thread_id === undefined || message_thread_id === null) {
2075
+ throw new Error('message_thread_id');
2076
+ }
2077
+
2078
+ const params = {
2079
+ chat_id: serialize(chat_id),
2080
+ message_thread_id: message_thread_id,
2081
+ name: name,
2082
+ icon_custom_emoji_id: icon_custom_emoji_id,
2083
+ };
2084
+ const clean = Object.fromEntries(Object.entries(params).filter(([_, v]) => v !== undefined && v !== null));
2085
+ const result = await this._request('editForumTopic', clean);
2086
+ return !!result;
2087
+ }
2088
+
2089
+ async closeForumTopic(options = {}) {
2090
+ const {
2091
+ chat_id,
2092
+ message_thread_id,
2093
+ } = options;
2094
+
2095
+ if (chat_id === undefined || chat_id === null) {
2096
+ throw new Error('chat_id');
2097
+ }
2098
+ if (message_thread_id === undefined || message_thread_id === null) {
2099
+ throw new Error('message_thread_id');
2100
+ }
2101
+
2102
+ const params = {
2103
+ chat_id: serialize(chat_id),
2104
+ message_thread_id: message_thread_id,
2105
+ };
2106
+ const clean = Object.fromEntries(Object.entries(params).filter(([_, v]) => v !== undefined && v !== null));
2107
+ const result = await this._request('closeForumTopic', clean);
2108
+ return !!result;
2109
+ }
2110
+
2111
+ async reopenForumTopic(options = {}) {
2112
+ const {
2113
+ chat_id,
2114
+ message_thread_id,
2115
+ } = options;
2116
+
2117
+ if (chat_id === undefined || chat_id === null) {
2118
+ throw new Error('chat_id');
2119
+ }
2120
+ if (message_thread_id === undefined || message_thread_id === null) {
2121
+ throw new Error('message_thread_id');
2122
+ }
2123
+
2124
+ const params = {
2125
+ chat_id: serialize(chat_id),
2126
+ message_thread_id: message_thread_id,
2127
+ };
2128
+ const clean = Object.fromEntries(Object.entries(params).filter(([_, v]) => v !== undefined && v !== null));
2129
+ const result = await this._request('reopenForumTopic', clean);
2130
+ return !!result;
2131
+ }
2132
+
2133
+ async deleteForumTopic(options = {}) {
2134
+ const {
2135
+ chat_id,
2136
+ message_thread_id,
2137
+ } = options;
2138
+
2139
+ if (chat_id === undefined || chat_id === null) {
2140
+ throw new Error('chat_id');
2141
+ }
2142
+ if (message_thread_id === undefined || message_thread_id === null) {
2143
+ throw new Error('message_thread_id');
2144
+ }
2145
+
2146
+ const params = {
2147
+ chat_id: serialize(chat_id),
2148
+ message_thread_id: message_thread_id,
2149
+ };
2150
+ const clean = Object.fromEntries(Object.entries(params).filter(([_, v]) => v !== undefined && v !== null));
2151
+ const result = await this._request('deleteForumTopic', clean);
2152
+ return !!result;
2153
+ }
2154
+
2155
+ async unpinAllForumTopicMessages(options = {}) {
2156
+ const {
2157
+ chat_id,
2158
+ message_thread_id,
2159
+ } = options;
2160
+
2161
+ if (chat_id === undefined || chat_id === null) {
2162
+ throw new Error('chat_id');
2163
+ }
2164
+ if (message_thread_id === undefined || message_thread_id === null) {
2165
+ throw new Error('message_thread_id');
2166
+ }
2167
+
2168
+ const params = {
2169
+ chat_id: serialize(chat_id),
2170
+ message_thread_id: message_thread_id,
2171
+ };
2172
+ const clean = Object.fromEntries(Object.entries(params).filter(([_, v]) => v !== undefined && v !== null));
2173
+ const result = await this._request('unpinAllForumTopicMessages', clean);
2174
+ return !!result;
2175
+ }
2176
+
2177
+ async editGeneralForumTopic(options = {}) {
2178
+ const {
2179
+ chat_id,
2180
+ name,
2181
+ } = options;
2182
+
2183
+ if (chat_id === undefined || chat_id === null) {
2184
+ throw new Error('chat_id');
2185
+ }
2186
+ if (name === undefined || name === null) {
2187
+ throw new Error('name');
2188
+ }
2189
+
2190
+ const params = {
2191
+ chat_id: serialize(chat_id),
2192
+ name: name,
2193
+ };
2194
+ const clean = Object.fromEntries(Object.entries(params).filter(([_, v]) => v !== undefined && v !== null));
2195
+ const result = await this._request('editGeneralForumTopic', clean);
2196
+ return !!result;
2197
+ }
2198
+
2199
+ async closeGeneralForumTopic(options = {}) {
2200
+ const {
2201
+ chat_id,
2202
+ } = options;
2203
+
2204
+ if (chat_id === undefined || chat_id === null) {
2205
+ throw new Error('chat_id');
2206
+ }
2207
+
2208
+ const params = {
2209
+ chat_id: serialize(chat_id),
2210
+ };
2211
+ const clean = Object.fromEntries(Object.entries(params).filter(([_, v]) => v !== undefined && v !== null));
2212
+ const result = await this._request('closeGeneralForumTopic', clean);
2213
+ return !!result;
2214
+ }
2215
+
2216
+ async reopenGeneralForumTopic(options = {}) {
2217
+ const {
2218
+ chat_id,
2219
+ } = options;
2220
+
2221
+ if (chat_id === undefined || chat_id === null) {
2222
+ throw new Error('chat_id');
2223
+ }
2224
+
2225
+ const params = {
2226
+ chat_id: serialize(chat_id),
2227
+ };
2228
+ const clean = Object.fromEntries(Object.entries(params).filter(([_, v]) => v !== undefined && v !== null));
2229
+ const result = await this._request('reopenGeneralForumTopic', clean);
2230
+ return !!result;
2231
+ }
2232
+
2233
+ async hideGeneralForumTopic(options = {}) {
2234
+ const {
2235
+ chat_id,
2236
+ } = options;
2237
+
2238
+ if (chat_id === undefined || chat_id === null) {
2239
+ throw new Error('chat_id');
2240
+ }
2241
+
2242
+ const params = {
2243
+ chat_id: serialize(chat_id),
2244
+ };
2245
+ const clean = Object.fromEntries(Object.entries(params).filter(([_, v]) => v !== undefined && v !== null));
2246
+ const result = await this._request('hideGeneralForumTopic', clean);
2247
+ return !!result;
2248
+ }
2249
+
2250
+ async unhideGeneralForumTopic(options = {}) {
2251
+ const {
2252
+ chat_id,
2253
+ } = options;
2254
+
2255
+ if (chat_id === undefined || chat_id === null) {
2256
+ throw new Error('chat_id');
2257
+ }
2258
+
2259
+ const params = {
2260
+ chat_id: serialize(chat_id),
2261
+ };
2262
+ const clean = Object.fromEntries(Object.entries(params).filter(([_, v]) => v !== undefined && v !== null));
2263
+ const result = await this._request('unhideGeneralForumTopic', clean);
2264
+ return !!result;
2265
+ }
2266
+
2267
+ async unpinAllGeneralForumTopicMessages(options = {}) {
2268
+ const {
2269
+ chat_id,
2270
+ } = options;
2271
+
2272
+ if (chat_id === undefined || chat_id === null) {
2273
+ throw new Error('chat_id');
2274
+ }
2275
+
2276
+ const params = {
2277
+ chat_id: serialize(chat_id),
2278
+ };
2279
+ const clean = Object.fromEntries(Object.entries(params).filter(([_, v]) => v !== undefined && v !== null));
2280
+ const result = await this._request('unpinAllGeneralForumTopicMessages', clean);
2281
+ return !!result;
2282
+ }
2283
+
2284
+ async answerCallbackQuery(options = {}) {
2285
+ const {
2286
+ callback_query_id,
2287
+ text,
2288
+ show_alert,
2289
+ url,
2290
+ cache_time,
2291
+ } = options;
2292
+
2293
+ if (callback_query_id === undefined || callback_query_id === null) {
2294
+ throw new Error('callback_query_id');
2295
+ }
2296
+
2297
+ const params = {
2298
+ callback_query_id: callback_query_id,
2299
+ text: text,
2300
+ show_alert: show_alert,
2301
+ url: url,
2302
+ cache_time: cache_time,
2303
+ };
2304
+ const clean = Object.fromEntries(Object.entries(params).filter(([_, v]) => v !== undefined && v !== null));
2305
+ const result = await this._request('answerCallbackQuery', clean);
2306
+ return !!result;
2307
+ }
2308
+
2309
+ async getUserChatBoosts(options = {}) {
2310
+ const {
2311
+ chat_id,
2312
+ user_id,
2313
+ } = options;
2314
+
2315
+ if (chat_id === undefined || chat_id === null) {
2316
+ throw new Error('chat_id');
2317
+ }
2318
+ if (user_id === undefined || user_id === null) {
2319
+ throw new Error('user_id');
2320
+ }
2321
+
2322
+ const params = {
2323
+ chat_id: serialize(chat_id),
2324
+ user_id: user_id,
2325
+ };
2326
+ const clean = Object.fromEntries(Object.entries(params).filter(([_, v]) => v !== undefined && v !== null));
2327
+ const result = await this._request('getUserChatBoosts', clean);
2328
+ return result;
2329
+ }
2330
+
2331
+ async getBusinessConnection(options = {}) {
2332
+ const {
2333
+ business_connection_id,
2334
+ } = options;
2335
+
2336
+ if (business_connection_id === undefined || business_connection_id === null) {
2337
+ throw new Error('business_connection_id');
2338
+ }
2339
+
2340
+ const params = {
2341
+ business_connection_id: business_connection_id,
2342
+ };
2343
+ const clean = Object.fromEntries(Object.entries(params).filter(([_, v]) => v !== undefined && v !== null));
2344
+ const result = await this._request('getBusinessConnection', clean);
2345
+ return result;
2346
+ }
2347
+
2348
+ async setMyCommands(options = {}) {
2349
+ const {
2350
+ commands,
2351
+ scope,
2352
+ language_code,
2353
+ } = options;
2354
+
2355
+ if (commands === undefined || commands === null) {
2356
+ throw new Error('commands');
2357
+ }
2358
+
2359
+ const params = {
2360
+ commands: serialize(commands),
2361
+ scope: serialize(scope),
2362
+ language_code: language_code,
2363
+ };
2364
+ const clean = Object.fromEntries(Object.entries(params).filter(([_, v]) => v !== undefined && v !== null));
2365
+ const result = await this._request('setMyCommands', clean);
2366
+ return !!result;
2367
+ }
2368
+
2369
+ async deleteMyCommands(options = {}) {
2370
+ const {
2371
+ scope,
2372
+ language_code,
2373
+ } = options;
2374
+
2375
+ const params = {
2376
+ scope: serialize(scope),
2377
+ language_code: language_code,
2378
+ };
2379
+ const clean = Object.fromEntries(Object.entries(params).filter(([_, v]) => v !== undefined && v !== null));
2380
+ const result = await this._request('deleteMyCommands', clean);
2381
+ return !!result;
2382
+ }
2383
+
2384
+ async getMyCommands(options = {}) {
2385
+ const {
2386
+ scope,
2387
+ language_code,
2388
+ } = options;
2389
+
2390
+ const params = {
2391
+ scope: serialize(scope),
2392
+ language_code: language_code,
2393
+ };
2394
+ const clean = Object.fromEntries(Object.entries(params).filter(([_, v]) => v !== undefined && v !== null));
2395
+ const result = await this._request('getMyCommands', clean);
2396
+ return result;
2397
+ }
2398
+
2399
+ async setMyName(options = {}) {
2400
+ const {
2401
+ name,
2402
+ language_code,
2403
+ } = options;
2404
+
2405
+ const params = {
2406
+ name: name,
2407
+ language_code: language_code,
2408
+ };
2409
+ const clean = Object.fromEntries(Object.entries(params).filter(([_, v]) => v !== undefined && v !== null));
2410
+ const result = await this._request('setMyName', clean);
2411
+ return !!result;
2412
+ }
2413
+
2414
+ async getMyName(options = {}) {
2415
+ const {
2416
+ language_code,
2417
+ } = options;
2418
+
2419
+ const params = {
2420
+ language_code: language_code,
2421
+ };
2422
+ const clean = Object.fromEntries(Object.entries(params).filter(([_, v]) => v !== undefined && v !== null));
2423
+ const result = await this._request('getMyName', clean);
2424
+ return result;
2425
+ }
2426
+
2427
+ async setMyDescription(options = {}) {
2428
+ const {
2429
+ description,
2430
+ language_code,
2431
+ } = options;
2432
+
2433
+ const params = {
2434
+ description: description,
2435
+ language_code: language_code,
2436
+ };
2437
+ const clean = Object.fromEntries(Object.entries(params).filter(([_, v]) => v !== undefined && v !== null));
2438
+ const result = await this._request('setMyDescription', clean);
2439
+ return !!result;
2440
+ }
2441
+
2442
+ async getMyDescription(options = {}) {
2443
+ const {
2444
+ language_code,
2445
+ } = options;
2446
+
2447
+ const params = {
2448
+ language_code: language_code,
2449
+ };
2450
+ const clean = Object.fromEntries(Object.entries(params).filter(([_, v]) => v !== undefined && v !== null));
2451
+ const result = await this._request('getMyDescription', clean);
2452
+ return result;
2453
+ }
2454
+
2455
+ async setMyShortDescription(options = {}) {
2456
+ const {
2457
+ short_description,
2458
+ language_code,
2459
+ } = options;
2460
+
2461
+ const params = {
2462
+ short_description: short_description,
2463
+ language_code: language_code,
2464
+ };
2465
+ const clean = Object.fromEntries(Object.entries(params).filter(([_, v]) => v !== undefined && v !== null));
2466
+ const result = await this._request('setMyShortDescription', clean);
2467
+ return !!result;
2468
+ }
2469
+
2470
+ async getMyShortDescription(options = {}) {
2471
+ const {
2472
+ language_code,
2473
+ } = options;
2474
+
2475
+ const params = {
2476
+ language_code: language_code,
2477
+ };
2478
+ const clean = Object.fromEntries(Object.entries(params).filter(([_, v]) => v !== undefined && v !== null));
2479
+ const result = await this._request('getMyShortDescription', clean);
2480
+ return result;
2481
+ }
2482
+
2483
+ async setChatMenuButton(options = {}) {
2484
+ const {
2485
+ chat_id,
2486
+ menu_button,
2487
+ } = options;
2488
+
2489
+ const params = {
2490
+ chat_id: chat_id,
2491
+ menu_button: serialize(menu_button),
2492
+ };
2493
+ const clean = Object.fromEntries(Object.entries(params).filter(([_, v]) => v !== undefined && v !== null));
2494
+ const result = await this._request('setChatMenuButton', clean);
2495
+ return !!result;
2496
+ }
2497
+
2498
+ async getChatMenuButton(options = {}) {
2499
+ const {
2500
+ chat_id,
2501
+ } = options;
2502
+
2503
+ const params = {
2504
+ chat_id: chat_id,
2505
+ };
2506
+ const clean = Object.fromEntries(Object.entries(params).filter(([_, v]) => v !== undefined && v !== null));
2507
+ const result = await this._request('getChatMenuButton', clean);
2508
+ return result;
2509
+ }
2510
+
2511
+ async setMyDefaultAdministratorRights(options = {}) {
2512
+ const {
2513
+ rights,
2514
+ for_channels,
2515
+ } = options;
2516
+
2517
+ const params = {
2518
+ rights: serialize(rights),
2519
+ for_channels: for_channels,
2520
+ };
2521
+ const clean = Object.fromEntries(Object.entries(params).filter(([_, v]) => v !== undefined && v !== null));
2522
+ const result = await this._request('setMyDefaultAdministratorRights', clean);
2523
+ return !!result;
2524
+ }
2525
+
2526
+ async getMyDefaultAdministratorRights(options = {}) {
2527
+ const {
2528
+ for_channels,
2529
+ } = options;
2530
+
2531
+ const params = {
2532
+ for_channels: for_channels,
2533
+ };
2534
+ const clean = Object.fromEntries(Object.entries(params).filter(([_, v]) => v !== undefined && v !== null));
2535
+ const result = await this._request('getMyDefaultAdministratorRights', clean);
2536
+ return result;
2537
+ }
2538
+
2539
+ async getAvailableGifts(_) {
2540
+ const params = {
2541
+ };
2542
+ const clean = Object.fromEntries(Object.entries(params).filter(([_, v]) => v !== undefined && v !== null));
2543
+ const result = await this._request('getAvailableGifts', clean);
2544
+ return result;
2545
+ }
2546
+
2547
+ async sendGift(options = {}) {
2548
+ const {
2549
+ gift_id,
2550
+ user_id,
2551
+ chat_id,
2552
+ pay_for_upgrade,
2553
+ text,
2554
+ text_parse_mode,
2555
+ text_entities,
2556
+ } = options;
2557
+
2558
+ if (gift_id === undefined || gift_id === null) {
2559
+ throw new Error('gift_id');
2560
+ }
2561
+
2562
+ const params = {
2563
+ gift_id: gift_id,
2564
+ user_id: user_id,
2565
+ chat_id: serialize(chat_id),
2566
+ pay_for_upgrade: pay_for_upgrade,
2567
+ text: text,
2568
+ text_parse_mode: text_parse_mode,
2569
+ text_entities: serialize(text_entities),
2570
+ };
2571
+ const clean = Object.fromEntries(Object.entries(params).filter(([_, v]) => v !== undefined && v !== null));
2572
+ const result = await this._request('sendGift', clean);
2573
+ return result;
2574
+ }
2575
+
2576
+ async giftPremiumSubscription(options = {}) {
2577
+ const {
2578
+ user_id,
2579
+ month_count,
2580
+ star_count,
2581
+ text,
2582
+ text_parse_mode,
2583
+ text_entities,
2584
+ } = options;
2585
+
2586
+ if (user_id === undefined || user_id === null) {
2587
+ throw new Error('user_id');
2588
+ }
2589
+ if (month_count === undefined || month_count === null) {
2590
+ throw new Error('month_count');
2591
+ }
2592
+ if (star_count === undefined || star_count === null) {
2593
+ throw new Error('star_count');
2594
+ }
2595
+
2596
+ const params = {
2597
+ user_id: user_id,
2598
+ month_count: month_count,
2599
+ star_count: star_count,
2600
+ text: text,
2601
+ text_parse_mode: text_parse_mode,
2602
+ text_entities: serialize(text_entities),
2603
+ };
2604
+ const clean = Object.fromEntries(Object.entries(params).filter(([_, v]) => v !== undefined && v !== null));
2605
+ const result = await this._request('giftPremiumSubscription', clean);
2606
+ return !!result;
2607
+ }
2608
+
2609
+ async verifyUser(options = {}) {
2610
+ const {
2611
+ user_id,
2612
+ custom_description,
2613
+ } = options;
2614
+
2615
+ if (user_id === undefined || user_id === null) {
2616
+ throw new Error('user_id');
2617
+ }
2618
+
2619
+ const params = {
2620
+ user_id: user_id,
2621
+ custom_description: custom_description,
2622
+ };
2623
+ const clean = Object.fromEntries(Object.entries(params).filter(([_, v]) => v !== undefined && v !== null));
2624
+ const result = await this._request('verifyUser', clean);
2625
+ return !!result;
2626
+ }
2627
+
2628
+ async verifyChat(options = {}) {
2629
+ const {
2630
+ chat_id,
2631
+ custom_description,
2632
+ } = options;
2633
+
2634
+ if (chat_id === undefined || chat_id === null) {
2635
+ throw new Error('chat_id');
2636
+ }
2637
+
2638
+ const params = {
2639
+ chat_id: serialize(chat_id),
2640
+ custom_description: custom_description,
2641
+ };
2642
+ const clean = Object.fromEntries(Object.entries(params).filter(([_, v]) => v !== undefined && v !== null));
2643
+ const result = await this._request('verifyChat', clean);
2644
+ return !!result;
2645
+ }
2646
+
2647
+ async removeUserVerification(options = {}) {
2648
+ const {
2649
+ user_id,
2650
+ } = options;
2651
+
2652
+ if (user_id === undefined || user_id === null) {
2653
+ throw new Error('user_id');
2654
+ }
2655
+
2656
+ const params = {
2657
+ user_id: user_id,
2658
+ };
2659
+ const clean = Object.fromEntries(Object.entries(params).filter(([_, v]) => v !== undefined && v !== null));
2660
+ const result = await this._request('removeUserVerification', clean);
2661
+ return !!result;
2662
+ }
2663
+
2664
+ async removeChatVerification(options = {}) {
2665
+ const {
2666
+ chat_id,
2667
+ } = options;
2668
+
2669
+ if (chat_id === undefined || chat_id === null) {
2670
+ throw new Error('chat_id');
2671
+ }
2672
+
2673
+ const params = {
2674
+ chat_id: serialize(chat_id),
2675
+ };
2676
+ const clean = Object.fromEntries(Object.entries(params).filter(([_, v]) => v !== undefined && v !== null));
2677
+ const result = await this._request('removeChatVerification', clean);
2678
+ return !!result;
2679
+ }
2680
+
2681
+ async readBusinessMessage(options = {}) {
2682
+ const {
2683
+ business_connection_id,
2684
+ chat_id,
2685
+ message_id,
2686
+ } = options;
2687
+
2688
+ if (business_connection_id === undefined || business_connection_id === null) {
2689
+ throw new Error('business_connection_id');
2690
+ }
2691
+ if (chat_id === undefined || chat_id === null) {
2692
+ throw new Error('chat_id');
2693
+ }
2694
+ if (message_id === undefined || message_id === null) {
2695
+ throw new Error('message_id');
2696
+ }
2697
+
2698
+ const params = {
2699
+ business_connection_id: business_connection_id,
2700
+ chat_id: chat_id,
2701
+ message_id: message_id,
2702
+ };
2703
+ const clean = Object.fromEntries(Object.entries(params).filter(([_, v]) => v !== undefined && v !== null));
2704
+ const result = await this._request('readBusinessMessage', clean);
2705
+ return !!result;
2706
+ }
2707
+
2708
+ async deleteBusinessMessages(options = {}) {
2709
+ const {
2710
+ business_connection_id,
2711
+ message_ids,
2712
+ } = options;
2713
+
2714
+ if (business_connection_id === undefined || business_connection_id === null) {
2715
+ throw new Error('business_connection_id');
2716
+ }
2717
+ if (message_ids === undefined || message_ids === null) {
2718
+ throw new Error('message_ids');
2719
+ }
2720
+
2721
+ const params = {
2722
+ business_connection_id: business_connection_id,
2723
+ message_ids: serialize(message_ids),
2724
+ };
2725
+ const clean = Object.fromEntries(Object.entries(params).filter(([_, v]) => v !== undefined && v !== null));
2726
+ const result = await this._request('deleteBusinessMessages', clean);
2727
+ return !!result;
2728
+ }
2729
+
2730
+ async setBusinessAccountName(options = {}) {
2731
+ const {
2732
+ business_connection_id,
2733
+ first_name,
2734
+ last_name,
2735
+ } = options;
2736
+
2737
+ if (business_connection_id === undefined || business_connection_id === null) {
2738
+ throw new Error('business_connection_id');
2739
+ }
2740
+ if (first_name === undefined || first_name === null) {
2741
+ throw new Error('first_name');
2742
+ }
2743
+
2744
+ const params = {
2745
+ business_connection_id: business_connection_id,
2746
+ first_name: first_name,
2747
+ last_name: last_name,
2748
+ };
2749
+ const clean = Object.fromEntries(Object.entries(params).filter(([_, v]) => v !== undefined && v !== null));
2750
+ const result = await this._request('setBusinessAccountName', clean);
2751
+ return !!result;
2752
+ }
2753
+
2754
+ async setBusinessAccountUsername(options = {}) {
2755
+ const {
2756
+ business_connection_id,
2757
+ username,
2758
+ } = options;
2759
+
2760
+ if (business_connection_id === undefined || business_connection_id === null) {
2761
+ throw new Error('business_connection_id');
2762
+ }
2763
+
2764
+ const params = {
2765
+ business_connection_id: business_connection_id,
2766
+ username: username,
2767
+ };
2768
+ const clean = Object.fromEntries(Object.entries(params).filter(([_, v]) => v !== undefined && v !== null));
2769
+ const result = await this._request('setBusinessAccountUsername', clean);
2770
+ return !!result;
2771
+ }
2772
+
2773
+ async setBusinessAccountBio(options = {}) {
2774
+ const {
2775
+ business_connection_id,
2776
+ bio,
2777
+ } = options;
2778
+
2779
+ if (business_connection_id === undefined || business_connection_id === null) {
2780
+ throw new Error('business_connection_id');
2781
+ }
2782
+
2783
+ const params = {
2784
+ business_connection_id: business_connection_id,
2785
+ bio: bio,
2786
+ };
2787
+ const clean = Object.fromEntries(Object.entries(params).filter(([_, v]) => v !== undefined && v !== null));
2788
+ const result = await this._request('setBusinessAccountBio', clean);
2789
+ return !!result;
2790
+ }
2791
+
2792
+ async setBusinessAccountProfilePhoto(options = {}) {
2793
+ const {
2794
+ business_connection_id,
2795
+ photo,
2796
+ is_public,
2797
+ } = options;
2798
+
2799
+ if (business_connection_id === undefined || business_connection_id === null) {
2800
+ throw new Error('business_connection_id');
2801
+ }
2802
+ if (photo === undefined || photo === null) {
2803
+ throw new Error('photo');
2804
+ }
2805
+
2806
+ const params = {
2807
+ business_connection_id: business_connection_id,
2808
+ photo: serialize(photo),
2809
+ is_public: is_public,
2810
+ };
2811
+ const clean = Object.fromEntries(Object.entries(params).filter(([_, v]) => v !== undefined && v !== null));
2812
+ const result = await this._request('setBusinessAccountProfilePhoto', clean);
2813
+ return !!result;
2814
+ }
2815
+
2816
+ async removeBusinessAccountProfilePhoto(options = {}) {
2817
+ const {
2818
+ business_connection_id,
2819
+ is_public,
2820
+ } = options;
2821
+
2822
+ if (business_connection_id === undefined || business_connection_id === null) {
2823
+ throw new Error('business_connection_id');
2824
+ }
2825
+
2826
+ const params = {
2827
+ business_connection_id: business_connection_id,
2828
+ is_public: is_public,
2829
+ };
2830
+ const clean = Object.fromEntries(Object.entries(params).filter(([_, v]) => v !== undefined && v !== null));
2831
+ const result = await this._request('removeBusinessAccountProfilePhoto', clean);
2832
+ return !!result;
2833
+ }
2834
+
2835
+ async setBusinessAccountGiftSettings(options = {}) {
2836
+ const {
2837
+ business_connection_id,
2838
+ show_gift_button,
2839
+ accepted_gift_types,
2840
+ } = options;
2841
+
2842
+ if (business_connection_id === undefined || business_connection_id === null) {
2843
+ throw new Error('business_connection_id');
2844
+ }
2845
+ if (show_gift_button === undefined || show_gift_button === null) {
2846
+ throw new Error('show_gift_button');
2847
+ }
2848
+ if (accepted_gift_types === undefined || accepted_gift_types === null) {
2849
+ throw new Error('accepted_gift_types');
2850
+ }
2851
+
2852
+ const params = {
2853
+ business_connection_id: business_connection_id,
2854
+ show_gift_button: show_gift_button,
2855
+ accepted_gift_types: serialize(accepted_gift_types),
2856
+ };
2857
+ const clean = Object.fromEntries(Object.entries(params).filter(([_, v]) => v !== undefined && v !== null));
2858
+ const result = await this._request('setBusinessAccountGiftSettings', clean);
2859
+ return !!result;
2860
+ }
2861
+
2862
+ async getBusinessAccountStarBalance(options = {}) {
2863
+ const {
2864
+ business_connection_id,
2865
+ } = options;
2866
+
2867
+ if (business_connection_id === undefined || business_connection_id === null) {
2868
+ throw new Error('business_connection_id');
2869
+ }
2870
+
2871
+ const params = {
2872
+ business_connection_id: business_connection_id,
2873
+ };
2874
+ const clean = Object.fromEntries(Object.entries(params).filter(([_, v]) => v !== undefined && v !== null));
2875
+ const result = await this._request('getBusinessAccountStarBalance', clean);
2876
+ return result;
2877
+ }
2878
+
2879
+ async transferBusinessAccountStars(options = {}) {
2880
+ const {
2881
+ business_connection_id,
2882
+ star_count,
2883
+ } = options;
2884
+
2885
+ if (business_connection_id === undefined || business_connection_id === null) {
2886
+ throw new Error('business_connection_id');
2887
+ }
2888
+ if (star_count === undefined || star_count === null) {
2889
+ throw new Error('star_count');
2890
+ }
2891
+
2892
+ const params = {
2893
+ business_connection_id: business_connection_id,
2894
+ star_count: star_count,
2895
+ };
2896
+ const clean = Object.fromEntries(Object.entries(params).filter(([_, v]) => v !== undefined && v !== null));
2897
+ const result = await this._request('transferBusinessAccountStars', clean);
2898
+ return !!result;
2899
+ }
2900
+
2901
+ async getBusinessAccountGifts(options = {}) {
2902
+ const {
2903
+ business_connection_id,
2904
+ exclude_unsaved,
2905
+ exclude_saved,
2906
+ exclude_unlimited,
2907
+ exclude_limited_upgradable,
2908
+ exclude_limited_non_upgradable,
2909
+ exclude_unique,
2910
+ exclude_from_blockchain,
2911
+ sort_by_price,
2912
+ offset,
2913
+ limit,
2914
+ } = options;
2915
+
2916
+ if (business_connection_id === undefined || business_connection_id === null) {
2917
+ throw new Error('business_connection_id');
2918
+ }
2919
+
2920
+ const params = {
2921
+ business_connection_id: business_connection_id,
2922
+ exclude_unsaved: exclude_unsaved,
2923
+ exclude_saved: exclude_saved,
2924
+ exclude_unlimited: exclude_unlimited,
2925
+ exclude_limited_upgradable: exclude_limited_upgradable,
2926
+ exclude_limited_non_upgradable: exclude_limited_non_upgradable,
2927
+ exclude_unique: exclude_unique,
2928
+ exclude_from_blockchain: exclude_from_blockchain,
2929
+ sort_by_price: sort_by_price,
2930
+ offset: offset,
2931
+ limit: limit,
2932
+ };
2933
+ const clean = Object.fromEntries(Object.entries(params).filter(([_, v]) => v !== undefined && v !== null));
2934
+ const result = await this._request('getBusinessAccountGifts', clean);
2935
+ return result;
2936
+ }
2937
+
2938
+ async getUserGifts(options = {}) {
2939
+ const {
2940
+ user_id,
2941
+ exclude_unlimited,
2942
+ exclude_limited_upgradable,
2943
+ exclude_limited_non_upgradable,
2944
+ exclude_from_blockchain,
2945
+ exclude_unique,
2946
+ sort_by_price,
2947
+ offset,
2948
+ limit,
2949
+ } = options;
2950
+
2951
+ if (user_id === undefined || user_id === null) {
2952
+ throw new Error('user_id');
2953
+ }
2954
+
2955
+ const params = {
2956
+ user_id: user_id,
2957
+ exclude_unlimited: exclude_unlimited,
2958
+ exclude_limited_upgradable: exclude_limited_upgradable,
2959
+ exclude_limited_non_upgradable: exclude_limited_non_upgradable,
2960
+ exclude_from_blockchain: exclude_from_blockchain,
2961
+ exclude_unique: exclude_unique,
2962
+ sort_by_price: sort_by_price,
2963
+ offset: offset,
2964
+ limit: limit,
2965
+ };
2966
+ const clean = Object.fromEntries(Object.entries(params).filter(([_, v]) => v !== undefined && v !== null));
2967
+ const result = await this._request('getUserGifts', clean);
2968
+ return result;
2969
+ }
2970
+
2971
+ async getChatGifts(options = {}) {
2972
+ const {
2973
+ chat_id,
2974
+ exclude_unsaved,
2975
+ exclude_saved,
2976
+ exclude_unlimited,
2977
+ exclude_limited_upgradable,
2978
+ exclude_limited_non_upgradable,
2979
+ exclude_from_blockchain,
2980
+ exclude_unique,
2981
+ sort_by_price,
2982
+ offset,
2983
+ limit,
2984
+ } = options;
2985
+
2986
+ if (chat_id === undefined || chat_id === null) {
2987
+ throw new Error('chat_id');
2988
+ }
2989
+
2990
+ const params = {
2991
+ chat_id: serialize(chat_id),
2992
+ exclude_unsaved: exclude_unsaved,
2993
+ exclude_saved: exclude_saved,
2994
+ exclude_unlimited: exclude_unlimited,
2995
+ exclude_limited_upgradable: exclude_limited_upgradable,
2996
+ exclude_limited_non_upgradable: exclude_limited_non_upgradable,
2997
+ exclude_from_blockchain: exclude_from_blockchain,
2998
+ exclude_unique: exclude_unique,
2999
+ sort_by_price: sort_by_price,
3000
+ offset: offset,
3001
+ limit: limit,
3002
+ };
3003
+ const clean = Object.fromEntries(Object.entries(params).filter(([_, v]) => v !== undefined && v !== null));
3004
+ const result = await this._request('getChatGifts', clean);
3005
+ return result;
3006
+ }
3007
+
3008
+ async convertGiftToStars(options = {}) {
3009
+ const {
3010
+ business_connection_id,
3011
+ owned_gift_id,
3012
+ } = options;
3013
+
3014
+ if (business_connection_id === undefined || business_connection_id === null) {
3015
+ throw new Error('business_connection_id');
3016
+ }
3017
+ if (owned_gift_id === undefined || owned_gift_id === null) {
3018
+ throw new Error('owned_gift_id');
3019
+ }
3020
+
3021
+ const params = {
3022
+ business_connection_id: business_connection_id,
3023
+ owned_gift_id: owned_gift_id,
3024
+ };
3025
+ const clean = Object.fromEntries(Object.entries(params).filter(([_, v]) => v !== undefined && v !== null));
3026
+ const result = await this._request('convertGiftToStars', clean);
3027
+ return !!result;
3028
+ }
3029
+
3030
+ async upgradeGift(options = {}) {
3031
+ const {
3032
+ business_connection_id,
3033
+ owned_gift_id,
3034
+ keep_original_details,
3035
+ star_count,
3036
+ } = options;
3037
+
3038
+ if (business_connection_id === undefined || business_connection_id === null) {
3039
+ throw new Error('business_connection_id');
3040
+ }
3041
+ if (owned_gift_id === undefined || owned_gift_id === null) {
3042
+ throw new Error('owned_gift_id');
3043
+ }
3044
+
3045
+ const params = {
3046
+ business_connection_id: business_connection_id,
3047
+ owned_gift_id: owned_gift_id,
3048
+ keep_original_details: keep_original_details,
3049
+ star_count: star_count,
3050
+ };
3051
+ const clean = Object.fromEntries(Object.entries(params).filter(([_, v]) => v !== undefined && v !== null));
3052
+ const result = await this._request('upgradeGift', clean);
3053
+ return !!result;
3054
+ }
3055
+
3056
+ async transferGift(options = {}) {
3057
+ const {
3058
+ business_connection_id,
3059
+ owned_gift_id,
3060
+ new_owner_chat_id,
3061
+ star_count,
3062
+ } = options;
3063
+
3064
+ if (business_connection_id === undefined || business_connection_id === null) {
3065
+ throw new Error('business_connection_id');
3066
+ }
3067
+ if (owned_gift_id === undefined || owned_gift_id === null) {
3068
+ throw new Error('owned_gift_id');
3069
+ }
3070
+ if (new_owner_chat_id === undefined || new_owner_chat_id === null) {
3071
+ throw new Error('new_owner_chat_id');
3072
+ }
3073
+
3074
+ const params = {
3075
+ business_connection_id: business_connection_id,
3076
+ owned_gift_id: owned_gift_id,
3077
+ new_owner_chat_id: new_owner_chat_id,
3078
+ star_count: star_count,
3079
+ };
3080
+ const clean = Object.fromEntries(Object.entries(params).filter(([_, v]) => v !== undefined && v !== null));
3081
+ const result = await this._request('transferGift', clean);
3082
+ return !!result;
3083
+ }
3084
+
3085
+ async postStory(options = {}) {
3086
+ const {
3087
+ business_connection_id,
3088
+ content,
3089
+ active_period,
3090
+ caption,
3091
+ parse_mode,
3092
+ caption_entities,
3093
+ areas,
3094
+ post_to_chat_page,
3095
+ protect_content,
3096
+ } = options;
3097
+
3098
+ if (business_connection_id === undefined || business_connection_id === null) {
3099
+ throw new Error('business_connection_id');
3100
+ }
3101
+ if (content === undefined || content === null) {
3102
+ throw new Error('content');
3103
+ }
3104
+ if (active_period === undefined || active_period === null) {
3105
+ throw new Error('active_period');
3106
+ }
3107
+
3108
+ const params = {
3109
+ business_connection_id: business_connection_id,
3110
+ content: serialize(content),
3111
+ active_period: active_period,
3112
+ caption: caption,
3113
+ parse_mode: parse_mode,
3114
+ caption_entities: serialize(caption_entities),
3115
+ areas: serialize(areas),
3116
+ post_to_chat_page: post_to_chat_page,
3117
+ protect_content: protect_content,
3118
+ };
3119
+ const clean = Object.fromEntries(Object.entries(params).filter(([_, v]) => v !== undefined && v !== null));
3120
+ const result = await this._request('postStory', clean);
3121
+ return result;
3122
+ }
3123
+
3124
+ async repostStory(options = {}) {
3125
+ const {
3126
+ business_connection_id,
3127
+ from_chat_id,
3128
+ from_story_id,
3129
+ active_period,
3130
+ post_to_chat_page,
3131
+ protect_content,
3132
+ } = options;
3133
+
3134
+ if (business_connection_id === undefined || business_connection_id === null) {
3135
+ throw new Error('business_connection_id');
3136
+ }
3137
+ if (from_chat_id === undefined || from_chat_id === null) {
3138
+ throw new Error('from_chat_id');
3139
+ }
3140
+ if (from_story_id === undefined || from_story_id === null) {
3141
+ throw new Error('from_story_id');
3142
+ }
3143
+ if (active_period === undefined || active_period === null) {
3144
+ throw new Error('active_period');
3145
+ }
3146
+
3147
+ const params = {
3148
+ business_connection_id: business_connection_id,
3149
+ from_chat_id: from_chat_id,
3150
+ from_story_id: from_story_id,
3151
+ active_period: active_period,
3152
+ post_to_chat_page: post_to_chat_page,
3153
+ protect_content: protect_content,
3154
+ };
3155
+ const clean = Object.fromEntries(Object.entries(params).filter(([_, v]) => v !== undefined && v !== null));
3156
+ const result = await this._request('repostStory', clean);
3157
+ return result;
3158
+ }
3159
+
3160
+ async editStory(options = {}) {
3161
+ const {
3162
+ business_connection_id,
3163
+ story_id,
3164
+ content,
3165
+ caption,
3166
+ parse_mode,
3167
+ caption_entities,
3168
+ areas,
3169
+ } = options;
3170
+
3171
+ if (business_connection_id === undefined || business_connection_id === null) {
3172
+ throw new Error('business_connection_id');
3173
+ }
3174
+ if (story_id === undefined || story_id === null) {
3175
+ throw new Error('story_id');
3176
+ }
3177
+ if (content === undefined || content === null) {
3178
+ throw new Error('content');
3179
+ }
3180
+
3181
+ const params = {
3182
+ business_connection_id: business_connection_id,
3183
+ story_id: story_id,
3184
+ content: serialize(content),
3185
+ caption: caption,
3186
+ parse_mode: parse_mode,
3187
+ caption_entities: serialize(caption_entities),
3188
+ areas: serialize(areas),
3189
+ };
3190
+ const clean = Object.fromEntries(Object.entries(params).filter(([_, v]) => v !== undefined && v !== null));
3191
+ const result = await this._request('editStory', clean);
3192
+ return result;
3193
+ }
3194
+
3195
+ async deleteStory(options = {}) {
3196
+ const {
3197
+ business_connection_id,
3198
+ story_id,
3199
+ } = options;
3200
+
3201
+ if (business_connection_id === undefined || business_connection_id === null) {
3202
+ throw new Error('business_connection_id');
3203
+ }
3204
+ if (story_id === undefined || story_id === null) {
3205
+ throw new Error('story_id');
3206
+ }
3207
+
3208
+ const params = {
3209
+ business_connection_id: business_connection_id,
3210
+ story_id: story_id,
3211
+ };
3212
+ const clean = Object.fromEntries(Object.entries(params).filter(([_, v]) => v !== undefined && v !== null));
3213
+ const result = await this._request('deleteStory', clean);
3214
+ return !!result;
3215
+ }
3216
+
3217
+ async editMessageText(options = {}) {
3218
+ const {
3219
+ text,
3220
+ business_connection_id,
3221
+ chat_id,
3222
+ message_id,
3223
+ inline_message_id,
3224
+ parse_mode,
3225
+ entities,
3226
+ link_preview_options,
3227
+ reply_markup,
3228
+ } = options;
3229
+
3230
+ if (text === undefined || text === null) {
3231
+ throw new Error('text');
3232
+ }
3233
+
3234
+ const params = {
3235
+ text: text,
3236
+ business_connection_id: business_connection_id,
3237
+ chat_id: serialize(chat_id),
3238
+ message_id: message_id,
3239
+ inline_message_id: inline_message_id,
3240
+ parse_mode: parse_mode,
3241
+ entities: serialize(entities),
3242
+ link_preview_options: serialize(link_preview_options),
3243
+ reply_markup: serialize(reply_markup),
3244
+ };
3245
+ const clean = Object.fromEntries(Object.entries(params).filter(([_, v]) => v !== undefined && v !== null));
3246
+ const result = await this._request('editMessageText', clean);
3247
+ return result;
3248
+ }
3249
+
3250
+ async editMessageCaption(options = {}) {
3251
+ const {
3252
+ business_connection_id,
3253
+ chat_id,
3254
+ message_id,
3255
+ inline_message_id,
3256
+ caption,
3257
+ parse_mode,
3258
+ caption_entities,
3259
+ show_caption_above_media,
3260
+ reply_markup,
3261
+ } = options;
3262
+
3263
+ const params = {
3264
+ business_connection_id: business_connection_id,
3265
+ chat_id: serialize(chat_id),
3266
+ message_id: message_id,
3267
+ inline_message_id: inline_message_id,
3268
+ caption: caption,
3269
+ parse_mode: parse_mode,
3270
+ caption_entities: serialize(caption_entities),
3271
+ show_caption_above_media: show_caption_above_media,
3272
+ reply_markup: serialize(reply_markup),
3273
+ };
3274
+ const clean = Object.fromEntries(Object.entries(params).filter(([_, v]) => v !== undefined && v !== null));
3275
+ const result = await this._request('editMessageCaption', clean);
3276
+ return result;
3277
+ }
3278
+
3279
+ async editMessageMedia(options = {}) {
3280
+ const {
3281
+ media,
3282
+ business_connection_id,
3283
+ chat_id,
3284
+ message_id,
3285
+ inline_message_id,
3286
+ reply_markup,
3287
+ } = options;
3288
+
3289
+ if (media === undefined || media === null) {
3290
+ throw new Error('media');
3291
+ }
3292
+
3293
+ const params = {
3294
+ media: serialize(media),
3295
+ business_connection_id: business_connection_id,
3296
+ chat_id: serialize(chat_id),
3297
+ message_id: message_id,
3298
+ inline_message_id: inline_message_id,
3299
+ reply_markup: serialize(reply_markup),
3300
+ };
3301
+ const clean = Object.fromEntries(Object.entries(params).filter(([_, v]) => v !== undefined && v !== null));
3302
+ const result = await this._request('editMessageMedia', clean);
3303
+ return result;
3304
+ }
3305
+
3306
+ async editMessageLiveLocation(options = {}) {
3307
+ const {
3308
+ latitude,
3309
+ longitude,
3310
+ business_connection_id,
3311
+ chat_id,
3312
+ message_id,
3313
+ inline_message_id,
3314
+ live_period,
3315
+ horizontal_accuracy,
3316
+ heading,
3317
+ proximity_alert_radius,
3318
+ reply_markup,
3319
+ } = options;
3320
+
3321
+ if (latitude === undefined || latitude === null) {
3322
+ throw new Error('latitude');
3323
+ }
3324
+ if (longitude === undefined || longitude === null) {
3325
+ throw new Error('longitude');
3326
+ }
3327
+
3328
+ const params = {
3329
+ latitude: latitude,
3330
+ longitude: longitude,
3331
+ business_connection_id: business_connection_id,
3332
+ chat_id: serialize(chat_id),
3333
+ message_id: message_id,
3334
+ inline_message_id: inline_message_id,
3335
+ live_period: live_period,
3336
+ horizontal_accuracy: horizontal_accuracy,
3337
+ heading: heading,
3338
+ proximity_alert_radius: proximity_alert_radius,
3339
+ reply_markup: serialize(reply_markup),
3340
+ };
3341
+ const clean = Object.fromEntries(Object.entries(params).filter(([_, v]) => v !== undefined && v !== null));
3342
+ const result = await this._request('editMessageLiveLocation', clean);
3343
+ return !!result;
3344
+ }
3345
+
3346
+ async stopMessageLiveLocation(options = {}) {
3347
+ const {
3348
+ business_connection_id,
3349
+ chat_id,
3350
+ message_id,
3351
+ inline_message_id,
3352
+ reply_markup,
3353
+ } = options;
3354
+
3355
+ const params = {
3356
+ business_connection_id: business_connection_id,
3357
+ chat_id: serialize(chat_id),
3358
+ message_id: message_id,
3359
+ inline_message_id: inline_message_id,
3360
+ reply_markup: serialize(reply_markup),
3361
+ };
3362
+ const clean = Object.fromEntries(Object.entries(params).filter(([_, v]) => v !== undefined && v !== null));
3363
+ const result = await this._request('stopMessageLiveLocation', clean);
3364
+ return result;
3365
+ }
3366
+
3367
+ async editMessageChecklist(options = {}) {
3368
+ const {
3369
+ business_connection_id,
3370
+ chat_id,
3371
+ message_id,
3372
+ checklist,
3373
+ reply_markup,
3374
+ } = options;
3375
+
3376
+ if (business_connection_id === undefined || business_connection_id === null) {
3377
+ throw new Error('business_connection_id');
3378
+ }
3379
+ if (chat_id === undefined || chat_id === null) {
3380
+ throw new Error('chat_id');
3381
+ }
3382
+ if (message_id === undefined || message_id === null) {
3383
+ throw new Error('message_id');
3384
+ }
3385
+ if (checklist === undefined || checklist === null) {
3386
+ throw new Error('checklist');
3387
+ }
3388
+
3389
+ const params = {
3390
+ business_connection_id: business_connection_id,
3391
+ chat_id: chat_id,
3392
+ message_id: message_id,
3393
+ checklist: serialize(checklist),
3394
+ reply_markup: serialize(reply_markup),
3395
+ };
3396
+ const clean = Object.fromEntries(Object.entries(params).filter(([_, v]) => v !== undefined && v !== null));
3397
+ const result = await this._request('editMessageChecklist', clean);
3398
+ return !!result;
3399
+ }
3400
+
3401
+ async editMessageReplyMarkup(options = {}) {
3402
+ const {
3403
+ business_connection_id,
3404
+ chat_id,
3405
+ message_id,
3406
+ inline_message_id,
3407
+ reply_markup,
3408
+ } = options;
3409
+
3410
+ const params = {
3411
+ business_connection_id: business_connection_id,
3412
+ chat_id: serialize(chat_id),
3413
+ message_id: message_id,
3414
+ inline_message_id: inline_message_id,
3415
+ reply_markup: serialize(reply_markup),
3416
+ };
3417
+ const clean = Object.fromEntries(Object.entries(params).filter(([_, v]) => v !== undefined && v !== null));
3418
+ const result = await this._request('editMessageReplyMarkup', clean);
3419
+ return result;
3420
+ }
3421
+
3422
+ async stopPoll(options = {}) {
3423
+ const {
3424
+ chat_id,
3425
+ message_id,
3426
+ business_connection_id,
3427
+ reply_markup,
3428
+ } = options;
3429
+
3430
+ if (chat_id === undefined || chat_id === null) {
3431
+ throw new Error('chat_id');
3432
+ }
3433
+ if (message_id === undefined || message_id === null) {
3434
+ throw new Error('message_id');
3435
+ }
3436
+
3437
+ const params = {
3438
+ chat_id: serialize(chat_id),
3439
+ message_id: message_id,
3440
+ business_connection_id: business_connection_id,
3441
+ reply_markup: serialize(reply_markup),
3442
+ };
3443
+ const clean = Object.fromEntries(Object.entries(params).filter(([_, v]) => v !== undefined && v !== null));
3444
+ const result = await this._request('stopPoll', clean);
3445
+ return result;
3446
+ }
3447
+
3448
+ async approveSuggestedPost(options = {}) {
3449
+ const {
3450
+ chat_id,
3451
+ message_id,
3452
+ send_date,
3453
+ } = options;
3454
+
3455
+ if (chat_id === undefined || chat_id === null) {
3456
+ throw new Error('chat_id');
3457
+ }
3458
+ if (message_id === undefined || message_id === null) {
3459
+ throw new Error('message_id');
3460
+ }
3461
+
3462
+ const params = {
3463
+ chat_id: chat_id,
3464
+ message_id: message_id,
3465
+ send_date: send_date,
3466
+ };
3467
+ const clean = Object.fromEntries(Object.entries(params).filter(([_, v]) => v !== undefined && v !== null));
3468
+ const result = await this._request('approveSuggestedPost', clean);
3469
+ return !!result;
3470
+ }
3471
+
3472
+ async declineSuggestedPost(options = {}) {
3473
+ const {
3474
+ chat_id,
3475
+ message_id,
3476
+ comment,
3477
+ } = options;
3478
+
3479
+ if (chat_id === undefined || chat_id === null) {
3480
+ throw new Error('chat_id');
3481
+ }
3482
+ if (message_id === undefined || message_id === null) {
3483
+ throw new Error('message_id');
3484
+ }
3485
+
3486
+ const params = {
3487
+ chat_id: chat_id,
3488
+ message_id: message_id,
3489
+ comment: comment,
3490
+ };
3491
+ const clean = Object.fromEntries(Object.entries(params).filter(([_, v]) => v !== undefined && v !== null));
3492
+ const result = await this._request('declineSuggestedPost', clean);
3493
+ return !!result;
3494
+ }
3495
+
3496
+ async deleteMessages(options = {}) {
3497
+ const {
3498
+ chat_id,
3499
+ message_ids,
3500
+ } = options;
3501
+
3502
+ if (chat_id === undefined || chat_id === null) {
3503
+ throw new Error('chat_id');
3504
+ }
3505
+ if (message_ids === undefined || message_ids === null) {
3506
+ throw new Error('message_ids');
3507
+ }
3508
+
3509
+ const params = {
3510
+ chat_id: serialize(chat_id),
3511
+ message_ids: serialize(message_ids),
3512
+ };
3513
+ const clean = Object.fromEntries(Object.entries(params).filter(([_, v]) => v !== undefined && v !== null));
3514
+ const result = await this._request('deleteMessages', clean);
3515
+ return !!result;
3516
+ }
3517
+
3518
+ async getStickerSet(options = {}) {
3519
+ const {
3520
+ name,
3521
+ } = options;
3522
+
3523
+ if (name === undefined || name === null) {
3524
+ throw new Error('name');
3525
+ }
3526
+
3527
+ const params = {
3528
+ name: name,
3529
+ };
3530
+ const clean = Object.fromEntries(Object.entries(params).filter(([_, v]) => v !== undefined && v !== null));
3531
+ const result = await this._request('getStickerSet', clean);
3532
+ return result;
3533
+ }
3534
+
3535
+ async getCustomEmojiStickers(options = {}) {
3536
+ const {
3537
+ custom_emoji_ids,
3538
+ } = options;
3539
+
3540
+ if (custom_emoji_ids === undefined || custom_emoji_ids === null) {
3541
+ throw new Error('custom_emoji_ids');
3542
+ }
3543
+
3544
+ const params = {
3545
+ custom_emoji_ids: serialize(custom_emoji_ids),
3546
+ };
3547
+ const clean = Object.fromEntries(Object.entries(params).filter(([_, v]) => v !== undefined && v !== null));
3548
+ const result = await this._request('getCustomEmojiStickers', clean);
3549
+ return result;
3550
+ }
3551
+
3552
+ async createNewStickerSet(options = {}) {
3553
+ const {
3554
+ user_id,
3555
+ name,
3556
+ title,
3557
+ stickers,
3558
+ sticker_type,
3559
+ needs_repainting,
3560
+ } = options;
3561
+
3562
+ if (user_id === undefined || user_id === null) {
3563
+ throw new Error('user_id');
3564
+ }
3565
+ if (name === undefined || name === null) {
3566
+ throw new Error('name');
3567
+ }
3568
+ if (title === undefined || title === null) {
3569
+ throw new Error('title');
3570
+ }
3571
+ if (stickers === undefined || stickers === null) {
3572
+ throw new Error('stickers');
3573
+ }
3574
+
3575
+ const params = {
3576
+ user_id: user_id,
3577
+ name: name,
3578
+ title: title,
3579
+ stickers: serialize(stickers),
3580
+ sticker_type: sticker_type,
3581
+ needs_repainting: needs_repainting,
3582
+ };
3583
+ const clean = Object.fromEntries(Object.entries(params).filter(([_, v]) => v !== undefined && v !== null));
3584
+ const result = await this._request('createNewStickerSet', clean);
3585
+ return !!result;
3586
+ }
3587
+
3588
+ async addStickerToSet(options = {}) {
3589
+ const {
3590
+ user_id,
3591
+ name,
3592
+ sticker,
3593
+ } = options;
3594
+
3595
+ if (user_id === undefined || user_id === null) {
3596
+ throw new Error('user_id');
3597
+ }
3598
+ if (name === undefined || name === null) {
3599
+ throw new Error('name');
3600
+ }
3601
+ if (sticker === undefined || sticker === null) {
3602
+ throw new Error('sticker');
3603
+ }
3604
+
3605
+ const params = {
3606
+ user_id: user_id,
3607
+ name: name,
3608
+ sticker: serialize(sticker),
3609
+ };
3610
+ const clean = Object.fromEntries(Object.entries(params).filter(([_, v]) => v !== undefined && v !== null));
3611
+ const result = await this._request('addStickerToSet', clean);
3612
+ return !!result;
3613
+ }
3614
+
3615
+ async setStickerPositionInSet(options = {}) {
3616
+ const {
3617
+ sticker,
3618
+ position,
3619
+ } = options;
3620
+
3621
+ if (sticker === undefined || sticker === null) {
3622
+ throw new Error('sticker');
3623
+ }
3624
+ if (position === undefined || position === null) {
3625
+ throw new Error('position');
3626
+ }
3627
+
3628
+ const params = {
3629
+ sticker: sticker,
3630
+ position: position,
3631
+ };
3632
+ const clean = Object.fromEntries(Object.entries(params).filter(([_, v]) => v !== undefined && v !== null));
3633
+ const result = await this._request('setStickerPositionInSet', clean);
3634
+ return !!result;
3635
+ }
3636
+
3637
+ async deleteStickerFromSet(options = {}) {
3638
+ const {
3639
+ sticker,
3640
+ } = options;
3641
+
3642
+ if (sticker === undefined || sticker === null) {
3643
+ throw new Error('sticker');
3644
+ }
3645
+
3646
+ const params = {
3647
+ sticker: sticker,
3648
+ };
3649
+ const clean = Object.fromEntries(Object.entries(params).filter(([_, v]) => v !== undefined && v !== null));
3650
+ const result = await this._request('deleteStickerFromSet', clean);
3651
+ return !!result;
3652
+ }
3653
+
3654
+ async replaceStickerInSet(options = {}) {
3655
+ const {
3656
+ user_id,
3657
+ name,
3658
+ old_sticker,
3659
+ sticker,
3660
+ } = options;
3661
+
3662
+ if (user_id === undefined || user_id === null) {
3663
+ throw new Error('user_id');
3664
+ }
3665
+ if (name === undefined || name === null) {
3666
+ throw new Error('name');
3667
+ }
3668
+ if (old_sticker === undefined || old_sticker === null) {
3669
+ throw new Error('old_sticker');
3670
+ }
3671
+ if (sticker === undefined || sticker === null) {
3672
+ throw new Error('sticker');
3673
+ }
3674
+
3675
+ const params = {
3676
+ user_id: user_id,
3677
+ name: name,
3678
+ old_sticker: old_sticker,
3679
+ sticker: serialize(sticker),
3680
+ };
3681
+ const clean = Object.fromEntries(Object.entries(params).filter(([_, v]) => v !== undefined && v !== null));
3682
+ const result = await this._request('replaceStickerInSet', clean);
3683
+ return !!result;
3684
+ }
3685
+
3686
+ async setStickerEmojiList(options = {}) {
3687
+ const {
3688
+ sticker,
3689
+ emoji_list,
3690
+ } = options;
3691
+
3692
+ if (sticker === undefined || sticker === null) {
3693
+ throw new Error('sticker');
3694
+ }
3695
+ if (emoji_list === undefined || emoji_list === null) {
3696
+ throw new Error('emoji_list');
3697
+ }
3698
+
3699
+ const params = {
3700
+ sticker: sticker,
3701
+ emoji_list: serialize(emoji_list),
3702
+ };
3703
+ const clean = Object.fromEntries(Object.entries(params).filter(([_, v]) => v !== undefined && v !== null));
3704
+ const result = await this._request('setStickerEmojiList', clean);
3705
+ return !!result;
3706
+ }
3707
+
3708
+ async setStickerKeywords(options = {}) {
3709
+ const {
3710
+ sticker,
3711
+ keywords,
3712
+ } = options;
3713
+
3714
+ if (sticker === undefined || sticker === null) {
3715
+ throw new Error('sticker');
3716
+ }
3717
+
3718
+ const params = {
3719
+ sticker: sticker,
3720
+ keywords: serialize(keywords),
3721
+ };
3722
+ const clean = Object.fromEntries(Object.entries(params).filter(([_, v]) => v !== undefined && v !== null));
3723
+ const result = await this._request('setStickerKeywords', clean);
3724
+ return !!result;
3725
+ }
3726
+
3727
+ async setStickerMaskPosition(options = {}) {
3728
+ const {
3729
+ sticker,
3730
+ mask_position,
3731
+ } = options;
3732
+
3733
+ if (sticker === undefined || sticker === null) {
3734
+ throw new Error('sticker');
3735
+ }
3736
+
3737
+ const params = {
3738
+ sticker: sticker,
3739
+ mask_position: serialize(mask_position),
3740
+ };
3741
+ const clean = Object.fromEntries(Object.entries(params).filter(([_, v]) => v !== undefined && v !== null));
3742
+ const result = await this._request('setStickerMaskPosition', clean);
3743
+ return !!result;
3744
+ }
3745
+
3746
+ async setStickerSetTitle(options = {}) {
3747
+ const {
3748
+ name,
3749
+ title,
3750
+ } = options;
3751
+
3752
+ if (name === undefined || name === null) {
3753
+ throw new Error('name');
3754
+ }
3755
+ if (title === undefined || title === null) {
3756
+ throw new Error('title');
3757
+ }
3758
+
3759
+ const params = {
3760
+ name: name,
3761
+ title: title,
3762
+ };
3763
+ const clean = Object.fromEntries(Object.entries(params).filter(([_, v]) => v !== undefined && v !== null));
3764
+ const result = await this._request('setStickerSetTitle', clean);
3765
+ return !!result;
3766
+ }
3767
+
3768
+ async setCustomEmojiStickerSetThumbnail(options = {}) {
3769
+ const {
3770
+ name,
3771
+ custom_emoji_id,
3772
+ } = options;
3773
+
3774
+ if (name === undefined || name === null) {
3775
+ throw new Error('name');
3776
+ }
3777
+
3778
+ const params = {
3779
+ name: name,
3780
+ custom_emoji_id: custom_emoji_id,
3781
+ };
3782
+ const clean = Object.fromEntries(Object.entries(params).filter(([_, v]) => v !== undefined && v !== null));
3783
+ const result = await this._request('setCustomEmojiStickerSetThumbnail', clean);
3784
+ return !!result;
3785
+ }
3786
+
3787
+ async deleteStickerSet(options = {}) {
3788
+ const {
3789
+ name,
3790
+ } = options;
3791
+
3792
+ if (name === undefined || name === null) {
3793
+ throw new Error('name');
3794
+ }
3795
+
3796
+ const params = {
3797
+ name: name,
3798
+ };
3799
+ const clean = Object.fromEntries(Object.entries(params).filter(([_, v]) => v !== undefined && v !== null));
3800
+ const result = await this._request('deleteStickerSet', clean);
3801
+ return !!result;
3802
+ }
3803
+
3804
+ async answerInlineQuery(options = {}) {
3805
+ const {
3806
+ inline_query_id,
3807
+ results,
3808
+ cache_time,
3809
+ is_personal,
3810
+ next_offset,
3811
+ button,
3812
+ } = options;
3813
+
3814
+ if (inline_query_id === undefined || inline_query_id === null) {
3815
+ throw new Error('inline_query_id');
3816
+ }
3817
+ if (results === undefined || results === null) {
3818
+ throw new Error('results');
3819
+ }
3820
+
3821
+ const params = {
3822
+ inline_query_id: inline_query_id,
3823
+ results: serialize(results),
3824
+ cache_time: cache_time,
3825
+ is_personal: is_personal,
3826
+ next_offset: next_offset,
3827
+ button: serialize(button),
3828
+ };
3829
+ const clean = Object.fromEntries(Object.entries(params).filter(([_, v]) => v !== undefined && v !== null));
3830
+ const result = await this._request('answerInlineQuery', clean);
3831
+ return !!result;
3832
+ }
3833
+
3834
+ async answerWebAppQuery(options = {}) {
3835
+ const {
3836
+ web_app_query_id,
3837
+ } = options;
3838
+
3839
+ if (web_app_query_id === undefined || web_app_query_id === null) {
3840
+ throw new Error('web_app_query_id');
3841
+ }
3842
+ if (result === undefined || result === null) {
3843
+ throw new Error('result');
3844
+ }
3845
+
3846
+ const params = {
3847
+ web_app_query_id: web_app_query_id,
3848
+ result: serialize(result),
3849
+ };
3850
+ const clean = Object.fromEntries(Object.entries(params).filter(([_, v]) => v !== undefined && v !== null));
3851
+ const result = await this._request('answerWebAppQuery', clean);
3852
+ return !!result;
3853
+ }
3854
+
3855
+ async savePreparedInlineMessage(options = {}) {
3856
+ const {
3857
+ user_id,
3858
+ allow_user_chats,
3859
+ allow_bot_chats,
3860
+ allow_group_chats,
3861
+ allow_channel_chats,
3862
+ } = options;
3863
+
3864
+ if (user_id === undefined || user_id === null) {
3865
+ throw new Error('user_id');
3866
+ }
3867
+ if (result === undefined || result === null) {
3868
+ throw new Error('result');
3869
+ }
3870
+
3871
+ const params = {
3872
+ user_id: user_id,
3873
+ result: serialize(result),
3874
+ allow_user_chats: allow_user_chats,
3875
+ allow_bot_chats: allow_bot_chats,
3876
+ allow_group_chats: allow_group_chats,
3877
+ allow_channel_chats: allow_channel_chats,
3878
+ };
3879
+ const clean = Object.fromEntries(Object.entries(params).filter(([_, v]) => v !== undefined && v !== null));
3880
+ const result = await this._request('savePreparedInlineMessage', clean);
3881
+ return result;
3882
+ }
3883
+
3884
+ async sendInvoice(options = {}) {
3885
+ const {
3886
+ chat_id,
3887
+ title,
3888
+ description,
3889
+ payload,
3890
+ currency,
3891
+ prices,
3892
+ message_thread_id,
3893
+ direct_messages_topic_id,
3894
+ provider_token,
3895
+ max_tip_amount,
3896
+ suggested_tip_amounts,
3897
+ start_parameter,
3898
+ provider_data,
3899
+ photo_url,
3900
+ photo_size,
3901
+ photo_width,
3902
+ photo_height,
3903
+ need_name,
3904
+ need_phone_number,
3905
+ need_email,
3906
+ need_shipping_address,
3907
+ send_phone_number_to_provider,
3908
+ send_email_to_provider,
3909
+ is_flexible,
3910
+ disable_notification,
3911
+ protect_content,
3912
+ allow_paid_broadcast,
3913
+ message_effect_id,
3914
+ suggested_post_parameters,
3915
+ reply_parameters,
3916
+ reply_markup,
3917
+ } = options;
3918
+
3919
+ if (chat_id === undefined || chat_id === null) {
3920
+ throw new Error('chat_id');
3921
+ }
3922
+ if (title === undefined || title === null) {
3923
+ throw new Error('title');
3924
+ }
3925
+ if (description === undefined || description === null) {
3926
+ throw new Error('description');
3927
+ }
3928
+ if (payload === undefined || payload === null) {
3929
+ throw new Error('payload');
3930
+ }
3931
+ if (currency === undefined || currency === null) {
3932
+ throw new Error('currency');
3933
+ }
3934
+ if (prices === undefined || prices === null) {
3935
+ throw new Error('prices');
3936
+ }
3937
+
3938
+ const params = {
3939
+ chat_id: serialize(chat_id),
3940
+ title: title,
3941
+ description: description,
3942
+ payload: payload,
3943
+ currency: currency,
3944
+ prices: serialize(prices),
3945
+ message_thread_id: message_thread_id,
3946
+ direct_messages_topic_id: direct_messages_topic_id,
3947
+ provider_token: provider_token,
3948
+ max_tip_amount: max_tip_amount,
3949
+ suggested_tip_amounts: serialize(suggested_tip_amounts),
3950
+ start_parameter: start_parameter,
3951
+ provider_data: provider_data,
3952
+ photo_url: photo_url,
3953
+ photo_size: photo_size,
3954
+ photo_width: photo_width,
3955
+ photo_height: photo_height,
3956
+ need_name: need_name,
3957
+ need_phone_number: need_phone_number,
3958
+ need_email: need_email,
3959
+ need_shipping_address: need_shipping_address,
3960
+ send_phone_number_to_provider: send_phone_number_to_provider,
3961
+ send_email_to_provider: send_email_to_provider,
3962
+ is_flexible: is_flexible,
3963
+ disable_notification: disable_notification,
3964
+ protect_content: protect_content,
3965
+ allow_paid_broadcast: allow_paid_broadcast,
3966
+ message_effect_id: message_effect_id,
3967
+ suggested_post_parameters: serialize(suggested_post_parameters),
3968
+ reply_parameters: serialize(reply_parameters),
3969
+ reply_markup: serialize(reply_markup),
3970
+ };
3971
+ const clean = Object.fromEntries(Object.entries(params).filter(([_, v]) => v !== undefined && v !== null));
3972
+ const result = await this._request('sendInvoice', clean);
3973
+ return result;
3974
+ }
3975
+
3976
+ async createInvoiceLink(options = {}) {
3977
+ const {
3978
+ title,
3979
+ description,
3980
+ payload,
3981
+ currency,
3982
+ prices,
3983
+ business_connection_id,
3984
+ provider_token,
3985
+ subscription_period,
3986
+ max_tip_amount,
3987
+ suggested_tip_amounts,
3988
+ provider_data,
3989
+ photo_url,
3990
+ photo_size,
3991
+ photo_width,
3992
+ photo_height,
3993
+ need_name,
3994
+ need_phone_number,
3995
+ need_email,
3996
+ need_shipping_address,
3997
+ send_phone_number_to_provider,
3998
+ send_email_to_provider,
3999
+ is_flexible,
4000
+ } = options;
4001
+
4002
+ if (title === undefined || title === null) {
4003
+ throw new Error('title');
4004
+ }
4005
+ if (description === undefined || description === null) {
4006
+ throw new Error('description');
4007
+ }
4008
+ if (payload === undefined || payload === null) {
4009
+ throw new Error('payload');
4010
+ }
4011
+ if (currency === undefined || currency === null) {
4012
+ throw new Error('currency');
4013
+ }
4014
+ if (prices === undefined || prices === null) {
4015
+ throw new Error('prices');
4016
+ }
4017
+
4018
+ const params = {
4019
+ title: title,
4020
+ description: description,
4021
+ payload: payload,
4022
+ currency: currency,
4023
+ prices: serialize(prices),
4024
+ business_connection_id: business_connection_id,
4025
+ provider_token: provider_token,
4026
+ subscription_period: subscription_period,
4027
+ max_tip_amount: max_tip_amount,
4028
+ suggested_tip_amounts: serialize(suggested_tip_amounts),
4029
+ provider_data: provider_data,
4030
+ photo_url: photo_url,
4031
+ photo_size: photo_size,
4032
+ photo_width: photo_width,
4033
+ photo_height: photo_height,
4034
+ need_name: need_name,
4035
+ need_phone_number: need_phone_number,
4036
+ need_email: need_email,
4037
+ need_shipping_address: need_shipping_address,
4038
+ send_phone_number_to_provider: send_phone_number_to_provider,
4039
+ send_email_to_provider: send_email_to_provider,
4040
+ is_flexible: is_flexible,
4041
+ };
4042
+ const clean = Object.fromEntries(Object.entries(params).filter(([_, v]) => v !== undefined && v !== null));
4043
+ const result = await this._request('createInvoiceLink', clean);
4044
+ return !!result;
4045
+ }
4046
+
4047
+ async answerShippingQuery(options = {}) {
4048
+ const {
4049
+ shipping_query_id,
4050
+ ok,
4051
+ shipping_options,
4052
+ error_message,
4053
+ } = options;
4054
+
4055
+ if (shipping_query_id === undefined || shipping_query_id === null) {
4056
+ throw new Error('shipping_query_id');
4057
+ }
4058
+ if (ok === undefined || ok === null) {
4059
+ throw new Error('ok');
4060
+ }
4061
+
4062
+ const params = {
4063
+ shipping_query_id: shipping_query_id,
4064
+ ok: ok,
4065
+ shipping_options: serialize(shipping_options),
4066
+ error_message: error_message,
4067
+ };
4068
+ const clean = Object.fromEntries(Object.entries(params).filter(([_, v]) => v !== undefined && v !== null));
4069
+ const result = await this._request('answerShippingQuery', clean);
4070
+ return !!result;
4071
+ }
4072
+
4073
+ async answerPreCheckoutQuery(options = {}) {
4074
+ const {
4075
+ pre_checkout_query_id,
4076
+ ok,
4077
+ error_message,
4078
+ } = options;
4079
+
4080
+ if (pre_checkout_query_id === undefined || pre_checkout_query_id === null) {
4081
+ throw new Error('pre_checkout_query_id');
4082
+ }
4083
+ if (ok === undefined || ok === null) {
4084
+ throw new Error('ok');
4085
+ }
4086
+
4087
+ const params = {
4088
+ pre_checkout_query_id: pre_checkout_query_id,
4089
+ ok: ok,
4090
+ error_message: error_message,
4091
+ };
4092
+ const clean = Object.fromEntries(Object.entries(params).filter(([_, v]) => v !== undefined && v !== null));
4093
+ const result = await this._request('answerPreCheckoutQuery', clean);
4094
+ return !!result;
4095
+ }
4096
+
4097
+ async getMyStarBalance(_) {
4098
+ const params = {
4099
+ };
4100
+ const clean = Object.fromEntries(Object.entries(params).filter(([_, v]) => v !== undefined && v !== null));
4101
+ const result = await this._request('getMyStarBalance', clean);
4102
+ return !!result;
4103
+ }
4104
+
4105
+ async getStarTransactions(options = {}) {
4106
+ const {
4107
+ offset,
4108
+ limit,
4109
+ } = options;
4110
+
4111
+ const params = {
4112
+ offset: offset,
4113
+ limit: limit,
4114
+ };
4115
+ const clean = Object.fromEntries(Object.entries(params).filter(([_, v]) => v !== undefined && v !== null));
4116
+ const result = await this._request('getStarTransactions', clean);
4117
+ return !!result;
4118
+ }
4119
+
4120
+ async refundStarPayment(options = {}) {
4121
+ const {
4122
+ user_id,
4123
+ telegram_payment_charge_id,
4124
+ } = options;
4125
+
4126
+ if (user_id === undefined || user_id === null) {
4127
+ throw new Error('user_id');
4128
+ }
4129
+ if (telegram_payment_charge_id === undefined || telegram_payment_charge_id === null) {
4130
+ throw new Error('telegram_payment_charge_id');
4131
+ }
4132
+
4133
+ const params = {
4134
+ user_id: user_id,
4135
+ telegram_payment_charge_id: telegram_payment_charge_id,
4136
+ };
4137
+ const clean = Object.fromEntries(Object.entries(params).filter(([_, v]) => v !== undefined && v !== null));
4138
+ const result = await this._request('refundStarPayment', clean);
4139
+ return !!result;
4140
+ }
4141
+
4142
+ async editUserStarSubscription(options = {}) {
4143
+ const {
4144
+ user_id,
4145
+ telegram_payment_charge_id,
4146
+ is_canceled,
4147
+ } = options;
4148
+
4149
+ if (user_id === undefined || user_id === null) {
4150
+ throw new Error('user_id');
4151
+ }
4152
+ if (telegram_payment_charge_id === undefined || telegram_payment_charge_id === null) {
4153
+ throw new Error('telegram_payment_charge_id');
4154
+ }
4155
+ if (is_canceled === undefined || is_canceled === null) {
4156
+ throw new Error('is_canceled');
4157
+ }
4158
+
4159
+ const params = {
4160
+ user_id: user_id,
4161
+ telegram_payment_charge_id: telegram_payment_charge_id,
4162
+ is_canceled: is_canceled,
4163
+ };
4164
+ const clean = Object.fromEntries(Object.entries(params).filter(([_, v]) => v !== undefined && v !== null));
4165
+ const result = await this._request('editUserStarSubscription', clean);
4166
+ return !!result;
4167
+ }
4168
+
4169
+ async setPassportDataErrors(options = {}) {
4170
+ const {
4171
+ user_id,
4172
+ errors,
4173
+ } = options;
4174
+
4175
+ if (user_id === undefined || user_id === null) {
4176
+ throw new Error('user_id');
4177
+ }
4178
+ if (errors === undefined || errors === null) {
4179
+ throw new Error('errors');
4180
+ }
4181
+
4182
+ const params = {
4183
+ user_id: user_id,
4184
+ errors: serialize(errors),
4185
+ };
4186
+ const clean = Object.fromEntries(Object.entries(params).filter(([_, v]) => v !== undefined && v !== null));
4187
+ const result = await this._request('setPassportDataErrors', clean);
4188
+ return !!result;
4189
+ }
4190
+
4191
+ async sendGame(options = {}) {
4192
+ const {
4193
+ chat_id,
4194
+ game_short_name,
4195
+ business_connection_id,
4196
+ message_thread_id,
4197
+ disable_notification,
4198
+ protect_content,
4199
+ allow_paid_broadcast,
4200
+ message_effect_id,
4201
+ reply_parameters,
4202
+ reply_markup,
4203
+ } = options;
4204
+
4205
+ if (chat_id === undefined || chat_id === null) {
4206
+ throw new Error('chat_id');
4207
+ }
4208
+ if (game_short_name === undefined || game_short_name === null) {
4209
+ throw new Error('game_short_name');
4210
+ }
4211
+
4212
+ const params = {
4213
+ chat_id: chat_id,
4214
+ game_short_name: game_short_name,
4215
+ business_connection_id: business_connection_id,
4216
+ message_thread_id: message_thread_id,
4217
+ disable_notification: disable_notification,
4218
+ protect_content: protect_content,
4219
+ allow_paid_broadcast: allow_paid_broadcast,
4220
+ message_effect_id: message_effect_id,
4221
+ reply_parameters: serialize(reply_parameters),
4222
+ reply_markup: serialize(reply_markup),
4223
+ };
4224
+ const clean = Object.fromEntries(Object.entries(params).filter(([_, v]) => v !== undefined && v !== null));
4225
+ const result = await this._request('sendGame', clean);
4226
+ return result;
4227
+ }
4228
+
4229
+ async setGameScore(options = {}) {
4230
+ const {
4231
+ user_id,
4232
+ score,
4233
+ force,
4234
+ disable_edit_message,
4235
+ chat_id,
4236
+ message_id,
4237
+ inline_message_id,
4238
+ } = options;
4239
+
4240
+ if (user_id === undefined || user_id === null) {
4241
+ throw new Error('user_id');
4242
+ }
4243
+ if (score === undefined || score === null) {
4244
+ throw new Error('score');
4245
+ }
4246
+
4247
+ const params = {
4248
+ user_id: user_id,
4249
+ score: score,
4250
+ force: force,
4251
+ disable_edit_message: disable_edit_message,
4252
+ chat_id: chat_id,
4253
+ message_id: message_id,
4254
+ inline_message_id: inline_message_id,
4255
+ };
4256
+ const clean = Object.fromEntries(Object.entries(params).filter(([_, v]) => v !== undefined && v !== null));
4257
+ const result = await this._request('setGameScore', clean);
4258
+ return !!result;
4259
+ }
4260
+
4261
+ async getGameHighScores(options = {}) {
4262
+ const {
4263
+ user_id,
4264
+ chat_id,
4265
+ message_id,
4266
+ inline_message_id,
4267
+ } = options;
4268
+
4269
+ if (user_id === undefined || user_id === null) {
4270
+ throw new Error('user_id');
4271
+ }
4272
+
4273
+ const params = {
4274
+ user_id: user_id,
4275
+ chat_id: chat_id,
4276
+ message_id: message_id,
4277
+ inline_message_id: inline_message_id,
4278
+ };
4279
+ const clean = Object.fromEntries(Object.entries(params).filter(([_, v]) => v !== undefined && v !== null));
4280
+ const result = await this._request('getGameHighScores', clean);
4281
+ return result;
4282
+ }
4283
+
4284
+ async sendSticker(options = {}) {
4285
+ const {
4286
+ chat_id,
4287
+ sticker,
4288
+ business_connection_id,
4289
+ message_thread_id,
4290
+ direct_messages_topic_id,
4291
+ emoji,
4292
+ disable_notification,
4293
+ protect_content,
4294
+ allow_paid_broadcast,
4295
+ message_effect_id,
4296
+ suggested_post_parameters,
4297
+ reply_parameters,
4298
+ reply_markup,
4299
+ } = options;
4300
+ if (chat_id === undefined || chat_id === null) {
4301
+ throw new Error('chat_id required');
4302
+ }
4303
+ if (!sticker) {
4304
+ throw new Error('sticker required');
4305
+ }
4306
+ const params = {
4307
+ chat_id: serialize(chat_id),
4308
+ business_connection_id,
4309
+ message_thread_id,
4310
+ direct_messages_topic_id,
4311
+ emoji,
4312
+ disable_notification,
4313
+ protect_content,
4314
+ allow_paid_broadcast,
4315
+ message_effect_id,
4316
+ suggested_post_parameters: serialize(suggested_post_parameters),
4317
+ reply_parameters: serialize(reply_parameters),
4318
+ reply_markup: serialize(reply_markup),
4319
+ };
4320
+ const clean = Object.fromEntries(Object.entries(params).filter(([_, v]) => v !== undefined && v !== null));
4321
+ const files = {};
4322
+ if (sticker instanceof Buffer || (sticker && typeof sticker.pipe === 'function')) {
4323
+ files.sticker = sticker;
4324
+ } else {
4325
+ clean.sticker = sticker;
4326
+ }
4327
+ const result = await this._request('sendSticker', clean, files);
4328
+ return result;
4329
+ }
4330
+
4331
+ async setChatPhoto(options = {}) {
4332
+ const {
4333
+ chat_id,
4334
+ photo,
4335
+ } = options;
4336
+ if (chat_id === undefined || chat_id === null) {
4337
+ throw new Error('chat_id required');
4338
+ }
4339
+ if (!photo) {
4340
+ throw new Error('photo required');
4341
+ }
4342
+ const params = {
4343
+ chat_id: serialize(chat_id),
4344
+ };
4345
+ const clean = Object.fromEntries(Object.entries(params).filter(([_, v]) => v !== undefined && v !== null));
4346
+ const files = {};
4347
+ if (photo instanceof Buffer || (photo && typeof photo.pipe === 'function')) {
4348
+ files.photo = photo;
4349
+ } else {
4350
+ clean.photo = photo;
4351
+ }
4352
+ const result = await this._request('setChatPhoto', clean, files);
4353
+ return !!result;
4354
+ }
4355
+
4356
+ async uploadStickerFile(options = {}) {
4357
+ const {
4358
+ user_id,
4359
+ sticker,
4360
+ sticker_format,
4361
+ } = options;
4362
+ if (user_id === undefined || user_id === null) {
4363
+ throw new Error('user_id required');
4364
+ }
4365
+ if (!sticker) {
4366
+ throw new Error('sticker required');
4367
+ }
4368
+ if (sticker_format === undefined || sticker_format === null) {
4369
+ throw new Error('sticker_format required');
4370
+ }
4371
+ const params = {
4372
+ user_id,
4373
+ sticker_format,
4374
+ };
4375
+ const clean = Object.fromEntries(Object.entries(params).filter(([_, v]) => v !== undefined && v !== null));
4376
+ const files = {};
4377
+ if (sticker instanceof Buffer || (sticker && typeof sticker.pipe === 'function')) {
4378
+ files.sticker = sticker;
4379
+ } else {
4380
+ clean.sticker = sticker;
4381
+ }
4382
+ const result = await this._request('uploadStickerFile', clean, files);
4383
+ return result;
4384
+ }
4385
+
4386
+ async setStickerSetThumbnail(options = {}) {
4387
+ const {
4388
+ name,
4389
+ user_id,
4390
+ format,
4391
+ thumbnail,
4392
+ } = options;
4393
+ if (name === undefined || name === null) {
4394
+ throw new Error('name required');
4395
+ }
4396
+ if (user_id === undefined || user_id === null) {
4397
+ throw new Error('user_id required');
4398
+ }
4399
+ if (format === undefined || format === null) {
4400
+ throw new Error('format required');
4401
+ }
4402
+ const params = {
4403
+ name,
4404
+ user_id,
4405
+ format,
4406
+ };
4407
+ const clean = Object.fromEntries(Object.entries(params).filter(([_, v]) => v !== undefined && v !== null));
4408
+ const files = {};
4409
+ if (thumbnail) {
4410
+ if (thumbnail instanceof Buffer || (thumbnail && typeof thumbnail.pipe === 'function')) {
4411
+ files.thumbnail = thumbnail;
4412
+ } else {
4413
+ clean.thumbnail = thumbnail;
4414
+ }
4415
+ }
4416
+ const result = await this._request('setStickerSetThumbnail', clean, files);
4417
+ return !!result;
4418
+ }
4419
+ }