@tgify/tgify 0.1.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 (168) hide show
  1. package/LICENSE +23 -0
  2. package/README.md +356 -0
  3. package/filters.d.ts +1 -0
  4. package/filters.js +1 -0
  5. package/format.d.ts +1 -0
  6. package/format.js +1 -0
  7. package/future.d.ts +1 -0
  8. package/future.js +1 -0
  9. package/lib/button.js +100 -0
  10. package/lib/cli.mjs +105 -0
  11. package/lib/composer.js +582 -0
  12. package/lib/context.js +1219 -0
  13. package/lib/core/helpers/args.js +57 -0
  14. package/lib/core/helpers/check.js +55 -0
  15. package/lib/core/helpers/compact.js +16 -0
  16. package/lib/core/helpers/deunionize.js +12 -0
  17. package/lib/core/helpers/formatting.js +91 -0
  18. package/lib/core/helpers/util.js +50 -0
  19. package/lib/core/network/client.js +330 -0
  20. package/lib/core/network/error.js +21 -0
  21. package/lib/core/network/multipart-stream.js +71 -0
  22. package/lib/core/network/polling.js +87 -0
  23. package/lib/core/network/webhook.js +54 -0
  24. package/lib/core/types/typegram.js +27 -0
  25. package/lib/filters.js +69 -0
  26. package/lib/format.js +38 -0
  27. package/lib/future.js +149 -0
  28. package/lib/index.js +58 -0
  29. package/lib/input.js +61 -0
  30. package/lib/markup.js +121 -0
  31. package/lib/middleware.js +2 -0
  32. package/lib/reactions.js +84 -0
  33. package/lib/router.js +46 -0
  34. package/lib/scenes/base.js +39 -0
  35. package/lib/scenes/context.js +104 -0
  36. package/lib/scenes/index.js +21 -0
  37. package/lib/scenes/stage.js +49 -0
  38. package/lib/scenes/wizard/context.js +31 -0
  39. package/lib/scenes/wizard/index.js +45 -0
  40. package/lib/scenes.js +17 -0
  41. package/lib/session.js +166 -0
  42. package/lib/telegraf.js +256 -0
  43. package/lib/telegram-types.js +6 -0
  44. package/lib/telegram.js +1240 -0
  45. package/lib/types.js +2 -0
  46. package/lib/utils.js +5 -0
  47. package/markup.d.ts +1 -0
  48. package/markup.js +1 -0
  49. package/package.json +140 -0
  50. package/scenes.d.ts +1 -0
  51. package/scenes.js +1 -0
  52. package/session.d.ts +1 -0
  53. package/session.js +1 -0
  54. package/src/button.ts +182 -0
  55. package/src/composer.ts +1008 -0
  56. package/src/context.ts +1661 -0
  57. package/src/core/helpers/args.ts +63 -0
  58. package/src/core/helpers/check.ts +71 -0
  59. package/src/core/helpers/compact.ts +18 -0
  60. package/src/core/helpers/deunionize.ts +26 -0
  61. package/src/core/helpers/formatting.ts +119 -0
  62. package/src/core/helpers/util.ts +96 -0
  63. package/src/core/network/client.ts +396 -0
  64. package/src/core/network/error.ts +29 -0
  65. package/src/core/network/multipart-stream.ts +45 -0
  66. package/src/core/network/polling.ts +94 -0
  67. package/src/core/network/webhook.ts +58 -0
  68. package/src/core/types/typegram.ts +54 -0
  69. package/src/filters.ts +109 -0
  70. package/src/format.ts +110 -0
  71. package/src/future.ts +213 -0
  72. package/src/index.ts +17 -0
  73. package/src/input.ts +59 -0
  74. package/src/markup.ts +142 -0
  75. package/src/middleware.ts +24 -0
  76. package/src/reactions.ts +118 -0
  77. package/src/router.ts +55 -0
  78. package/src/scenes/base.ts +52 -0
  79. package/src/scenes/context.ts +136 -0
  80. package/src/scenes/index.ts +21 -0
  81. package/src/scenes/stage.ts +71 -0
  82. package/src/scenes/wizard/context.ts +58 -0
  83. package/src/scenes/wizard/index.ts +63 -0
  84. package/src/scenes.ts +1 -0
  85. package/src/session.ts +204 -0
  86. package/src/telegraf.ts +354 -0
  87. package/src/telegram-types.ts +219 -0
  88. package/src/telegram.ts +1635 -0
  89. package/src/types.ts +2 -0
  90. package/src/utils.ts +1 -0
  91. package/types.d.ts +1 -0
  92. package/types.js +1 -0
  93. package/typings/button.d.ts +36 -0
  94. package/typings/button.d.ts.map +1 -0
  95. package/typings/composer.d.ts +227 -0
  96. package/typings/composer.d.ts.map +1 -0
  97. package/typings/context.d.ts +655 -0
  98. package/typings/context.d.ts.map +1 -0
  99. package/typings/core/helpers/args.d.ts +11 -0
  100. package/typings/core/helpers/args.d.ts.map +1 -0
  101. package/typings/core/helpers/check.d.ts +56 -0
  102. package/typings/core/helpers/check.d.ts.map +1 -0
  103. package/typings/core/helpers/compact.d.ts +4 -0
  104. package/typings/core/helpers/compact.d.ts.map +1 -0
  105. package/typings/core/helpers/deunionize.d.ts +18 -0
  106. package/typings/core/helpers/deunionize.d.ts.map +1 -0
  107. package/typings/core/helpers/formatting.d.ts +30 -0
  108. package/typings/core/helpers/formatting.d.ts.map +1 -0
  109. package/typings/core/helpers/util.d.ts +26 -0
  110. package/typings/core/helpers/util.d.ts.map +1 -0
  111. package/typings/core/network/client.d.ts +53 -0
  112. package/typings/core/network/client.d.ts.map +1 -0
  113. package/typings/core/network/error.d.ts +16 -0
  114. package/typings/core/network/error.d.ts.map +1 -0
  115. package/typings/core/network/multipart-stream.d.ts +16 -0
  116. package/typings/core/network/multipart-stream.d.ts.map +1 -0
  117. package/typings/core/network/polling.d.ts +16 -0
  118. package/typings/core/network/polling.d.ts.map +1 -0
  119. package/typings/core/network/webhook.d.ts +6 -0
  120. package/typings/core/network/webhook.d.ts.map +1 -0
  121. package/typings/core/types/typegram.d.ts +42 -0
  122. package/typings/core/types/typegram.d.ts.map +1 -0
  123. package/typings/filters.d.ts +18 -0
  124. package/typings/filters.d.ts.map +1 -0
  125. package/typings/format.d.ts +22 -0
  126. package/typings/format.d.ts.map +1 -0
  127. package/typings/future.d.ts +12 -0
  128. package/typings/future.d.ts.map +1 -0
  129. package/typings/index.d.ts +15 -0
  130. package/typings/index.d.ts.map +1 -0
  131. package/typings/input.d.ts +50 -0
  132. package/typings/input.d.ts.map +1 -0
  133. package/typings/markup.d.ts +27 -0
  134. package/typings/markup.d.ts.map +1 -0
  135. package/typings/middleware.d.ts +8 -0
  136. package/typings/middleware.d.ts.map +1 -0
  137. package/typings/reactions.d.ts +32 -0
  138. package/typings/reactions.d.ts.map +1 -0
  139. package/typings/router.d.ts +21 -0
  140. package/typings/router.d.ts.map +1 -0
  141. package/typings/scenes/base.d.ts +22 -0
  142. package/typings/scenes/base.d.ts.map +1 -0
  143. package/typings/scenes/context.d.ts +36 -0
  144. package/typings/scenes/context.d.ts.map +1 -0
  145. package/typings/scenes/index.d.ts +11 -0
  146. package/typings/scenes/index.d.ts.map +1 -0
  147. package/typings/scenes/stage.d.ts +24 -0
  148. package/typings/scenes/stage.d.ts.map +1 -0
  149. package/typings/scenes/wizard/context.d.ts +29 -0
  150. package/typings/scenes/wizard/context.d.ts.map +1 -0
  151. package/typings/scenes/wizard/index.d.ts +16 -0
  152. package/typings/scenes/wizard/index.d.ts.map +1 -0
  153. package/typings/scenes.d.ts +2 -0
  154. package/typings/scenes.d.ts.map +1 -0
  155. package/typings/session.d.ts +55 -0
  156. package/typings/session.d.ts.map +1 -0
  157. package/typings/telegraf.d.ts +115 -0
  158. package/typings/telegraf.d.ts.map +1 -0
  159. package/typings/telegram-types.d.ts +117 -0
  160. package/typings/telegram-types.d.ts.map +1 -0
  161. package/typings/telegram.d.ts +675 -0
  162. package/typings/telegram.d.ts.map +1 -0
  163. package/typings/types.d.ts +3 -0
  164. package/typings/types.d.ts.map +1 -0
  165. package/typings/utils.d.ts +2 -0
  166. package/typings/utils.d.ts.map +1 -0
  167. package/utils.d.ts +1 -0
  168. package/utils.js +1 -0
@@ -0,0 +1,655 @@
1
+ import * as tg from './core/types/typegram';
2
+ import * as tt from './telegram-types';
3
+ import { Deunionize, PropOr, UnionKeys } from './core/helpers/deunionize';
4
+ import ApiClient from './core/network/client';
5
+ import { Guard, Guarded, Keyed, MaybeArray } from './core/helpers/util';
6
+ import Telegram from './telegram';
7
+ import { FmtString } from './format';
8
+ import { Digit, MessageReactions } from './reactions';
9
+ type Tail<T> = T extends [unknown, ...infer U] ? U : never;
10
+ type Shorthand<FName extends Exclude<keyof Telegram, keyof ApiClient>> = Tail<Parameters<Telegram[FName]>>;
11
+ /**
12
+ * Narrows down `C['update']` (and derived getters)
13
+ * to specific update type `U`.
14
+ *
15
+ * Used by [[`Composer`]],
16
+ * possibly useful for splitting a bot into multiple files.
17
+ */
18
+ export type NarrowedContext<C extends Context, U extends tg.Update> = Context<U> & Omit<C, keyof Context>;
19
+ export type FilteredContext<Ctx extends Context, Filter extends tt.UpdateType | Guard<Ctx['update']>> = Filter extends tt.UpdateType ? NarrowedContext<Ctx, Extract<tg.Update, Record<Filter, object>>> : NarrowedContext<Ctx, Guarded<Filter>>;
20
+ export declare class Context<U extends Deunionize<tg.Update> = tg.Update> {
21
+ readonly update: U;
22
+ readonly telegram: Telegram;
23
+ readonly botInfo: tg.UserFromGetMe;
24
+ readonly state: Record<string | symbol, any>;
25
+ constructor(update: U, telegram: Telegram, botInfo: tg.UserFromGetMe);
26
+ get updateType(): Extract<UnionKeys<U>, tt.UpdateType>;
27
+ get me(): string;
28
+ /**
29
+ * @deprecated Use ctx.telegram instead
30
+ */
31
+ get tg(): Telegram;
32
+ get message(): PropOr<U, "message">;
33
+ get editedMessage(): PropOr<U, "edited_message">;
34
+ get inlineQuery(): PropOr<U, "inline_query">;
35
+ get shippingQuery(): PropOr<U, "shipping_query">;
36
+ get preCheckoutQuery(): PropOr<U, "pre_checkout_query">;
37
+ get chosenInlineResult(): PropOr<U, "chosen_inline_result">;
38
+ get channelPost(): PropOr<U, "channel_post">;
39
+ get editedChannelPost(): PropOr<U, "edited_channel_post">;
40
+ get messageReaction(): PropOr<U, "message_reaction">;
41
+ get messageReactionCount(): PropOr<U, "message_reaction_count">;
42
+ get callbackQuery(): PropOr<U, "callback_query">;
43
+ get poll(): PropOr<U, "poll">;
44
+ get pollAnswer(): PropOr<U, "poll_answer">;
45
+ get myChatMember(): PropOr<U, "my_chat_member">;
46
+ get chatMember(): PropOr<U, "chat_member">;
47
+ get chatJoinRequest(): PropOr<U, "chat_join_request">;
48
+ get chatBoost(): PropOr<U, "chat_boost">;
49
+ get removedChatBoost(): PropOr<U, "removed_chat_boost">;
50
+ /** Shorthand for any `message` object present in the current update. One of
51
+ * `message`, `edited_message`, `channel_post`, `edited_channel_post` or
52
+ * `callback_query.message`
53
+ */
54
+ get msg(): GetMsg<U> & Msg;
55
+ /** Shorthand for any message_id present in the current update. */
56
+ get msgId(): GetMsgId<U>;
57
+ get chat(): Getter<U, 'chat'>;
58
+ get senderChat(): Getter<U, "sender_chat">;
59
+ get from(): GetUserFromAnySource<U>;
60
+ get inlineMessageId(): string | undefined;
61
+ get passportData(): tg.PassportData | undefined;
62
+ get webAppData(): {
63
+ data: {
64
+ json<T>(): T;
65
+ text(): string;
66
+ };
67
+ button_text: string;
68
+ } | undefined;
69
+ /**
70
+ * @deprecated use {@link Telegram.webhookReply}
71
+ */
72
+ get webhookReply(): boolean;
73
+ set webhookReply(enable: boolean);
74
+ get reactions(): MessageReactions;
75
+ has<Filter extends tt.UpdateType | Guard<Context['update']>>(filters: MaybeArray<Filter>): this is FilteredContext<Context, Filter>;
76
+ get text(): GetText<U>;
77
+ entities<EntityTypes extends tg.MessageEntity['type'][]>(...types: EntityTypes): (tg.MessageEntity & {
78
+ type: EntityTypes extends [] ? "mention" | "hashtag" | "cashtag" | "bot_command" | "url" | "email" | "phone_number" | "bold" | "blockquote" | "italic" | "underline" | "strikethrough" | "spoiler" | "code" | "custom_emoji" | "pre" | "text_link" | "text_mention" : EntityTypes[number];
79
+ fragment: string;
80
+ })[];
81
+ /**
82
+ * @see https://core.telegram.org/bots/api#answerinlinequery
83
+ */
84
+ answerInlineQuery(...args: Shorthand<'answerInlineQuery'>): Promise<true>;
85
+ /**
86
+ * @see https://core.telegram.org/bots/api#answercallbackquery
87
+ */
88
+ answerCbQuery(...args: Shorthand<'answerCbQuery'>): Promise<true>;
89
+ /**
90
+ * @see https://core.telegram.org/bots/api#answercallbackquery
91
+ */
92
+ answerGameQuery(...args: Shorthand<'answerGameQuery'>): Promise<true>;
93
+ /**
94
+ * Shorthand for {@link Telegram.getUserChatBoosts}
95
+ */
96
+ getUserChatBoosts(): Promise<tg.UserChatBoosts[]>;
97
+ /**
98
+ * @see https://core.telegram.org/bots/api#answershippingquery
99
+ */
100
+ answerShippingQuery(...args: Shorthand<'answerShippingQuery'>): Promise<true>;
101
+ /**
102
+ * @see https://core.telegram.org/bots/api#answerprecheckoutquery
103
+ */
104
+ answerPreCheckoutQuery(...args: Shorthand<'answerPreCheckoutQuery'>): Promise<true>;
105
+ /**
106
+ * @see https://core.telegram.org/bots/api#editmessagetext
107
+ */
108
+ editMessageText(text: string | FmtString, extra?: tt.ExtraEditMessageText): Promise<true | (tg.Update.Edited & tg.Message.TextMessage)>;
109
+ /**
110
+ * @see https://core.telegram.org/bots/api#editmessagecaption
111
+ */
112
+ editMessageCaption(caption: string | FmtString | undefined, extra?: tt.ExtraEditMessageCaption): Promise<true | (tg.Update.Edited & tg.Message.CaptionableMessage)>;
113
+ /**
114
+ * @see https://core.telegram.org/bots/api#editmessagemedia
115
+ */
116
+ editMessageMedia(media: tt.WrapCaption<tg.InputMedia>, extra?: tt.ExtraEditMessageMedia): Promise<true | (tg.Update.Edited & tg.Message)>;
117
+ /**
118
+ * @see https://core.telegram.org/bots/api#editmessagereplymarkup
119
+ */
120
+ editMessageReplyMarkup(markup: tg.InlineKeyboardMarkup | undefined): Promise<true | (tg.Update.Edited & tg.Message)>;
121
+ /**
122
+ * @see https://core.telegram.org/bots/api#editmessagelivelocation
123
+ */
124
+ editMessageLiveLocation(latitude: number, longitude: number, extra?: tt.ExtraEditMessageLiveLocation): Promise<true | (tg.Update.Edited & tg.Message.LocationMessage)>;
125
+ /**
126
+ * @see https://core.telegram.org/bots/api#stopmessagelivelocation
127
+ */
128
+ stopMessageLiveLocation(markup?: tg.InlineKeyboardMarkup): Promise<true | (tg.Update.Edited & tg.Message.LocationMessage)>;
129
+ /**
130
+ * @see https://core.telegram.org/bots/api#sendmessage
131
+ */
132
+ sendMessage(text: string | FmtString, extra?: tt.ExtraReplyMessage): Promise<tg.Message.TextMessage>;
133
+ /**
134
+ * @see https://core.telegram.org/bots/api#sendmessage
135
+ */
136
+ reply(...args: Shorthand<'sendMessage'>): Promise<tg.Message.TextMessage>;
137
+ /**
138
+ * @see https://core.telegram.org/bots/api#getchat
139
+ */
140
+ getChat(...args: Shorthand<'getChat'>): Promise<tg.ChatFromGetChat>;
141
+ /**
142
+ * @see https://core.telegram.org/bots/api#exportchatinvitelink
143
+ */
144
+ exportChatInviteLink(...args: Shorthand<'exportChatInviteLink'>): Promise<string>;
145
+ /**
146
+ * @see https://core.telegram.org/bots/api#createchatinvitelink
147
+ */
148
+ createChatInviteLink(...args: Shorthand<'createChatInviteLink'>): Promise<tg.ChatInviteLink>;
149
+ /**
150
+ * @see https://core.telegram.org/bots/api#editchatinvitelink
151
+ */
152
+ editChatInviteLink(...args: Shorthand<'editChatInviteLink'>): Promise<tg.ChatInviteLink>;
153
+ /**
154
+ * @see https://core.telegram.org/bots/api#revokechatinvitelink
155
+ */
156
+ revokeChatInviteLink(...args: Shorthand<'revokeChatInviteLink'>): Promise<tg.ChatInviteLink>;
157
+ /**
158
+ * @see https://core.telegram.org/bots/api#banchatmember
159
+ */
160
+ banChatMember(...args: Shorthand<'banChatMember'>): Promise<true>;
161
+ /**
162
+ * @see https://core.telegram.org/bots/api#banchatmember
163
+ * @deprecated since API 5.3. Use {@link Context.banChatMember}
164
+ */
165
+ get kickChatMember(): (userId: number, untilDate?: number | undefined, extra?: Omit<{
166
+ chat_id: number | string;
167
+ user_id: number;
168
+ until_date?: number;
169
+ revoke_messages?: boolean;
170
+ }, "chat_id" | "user_id" | "until_date"> | undefined) => Promise<true>;
171
+ /**
172
+ * @see https://core.telegram.org/bots/api#unbanchatmember
173
+ */
174
+ unbanChatMember(...args: Shorthand<'unbanChatMember'>): Promise<true>;
175
+ /**
176
+ * @see https://core.telegram.org/bots/api#restrictchatmember
177
+ */
178
+ restrictChatMember(...args: Shorthand<'restrictChatMember'>): Promise<true>;
179
+ /**
180
+ * @see https://core.telegram.org/bots/api#promotechatmember
181
+ */
182
+ promoteChatMember(...args: Shorthand<'promoteChatMember'>): Promise<true>;
183
+ /**
184
+ * @see https://core.telegram.org/bots/api#setchatadministratorcustomtitle
185
+ */
186
+ setChatAdministratorCustomTitle(...args: Shorthand<'setChatAdministratorCustomTitle'>): Promise<true>;
187
+ /**
188
+ * @see https://core.telegram.org/bots/api#setchatphoto
189
+ */
190
+ setChatPhoto(...args: Shorthand<'setChatPhoto'>): Promise<true>;
191
+ /**
192
+ * @see https://core.telegram.org/bots/api#deletechatphoto
193
+ */
194
+ deleteChatPhoto(...args: Shorthand<'deleteChatPhoto'>): Promise<true>;
195
+ /**
196
+ * @see https://core.telegram.org/bots/api#setchattitle
197
+ */
198
+ setChatTitle(...args: Shorthand<'setChatTitle'>): Promise<true>;
199
+ /**
200
+ * @see https://core.telegram.org/bots/api#setchatdescription
201
+ */
202
+ setChatDescription(...args: Shorthand<'setChatDescription'>): Promise<true>;
203
+ /**
204
+ * @see https://core.telegram.org/bots/api#pinchatmessage
205
+ */
206
+ pinChatMessage(...args: Shorthand<'pinChatMessage'>): Promise<true>;
207
+ /**
208
+ * @see https://core.telegram.org/bots/api#unpinchatmessage
209
+ */
210
+ unpinChatMessage(...args: Shorthand<'unpinChatMessage'>): Promise<true>;
211
+ /**
212
+ * @see https://core.telegram.org/bots/api#unpinallchatmessages
213
+ */
214
+ unpinAllChatMessages(...args: Shorthand<'unpinAllChatMessages'>): Promise<true>;
215
+ /**
216
+ * @see https://core.telegram.org/bots/api#leavechat
217
+ */
218
+ leaveChat(...args: Shorthand<'leaveChat'>): Promise<true>;
219
+ /**
220
+ * @see https://core.telegram.org/bots/api#setchatpermissions
221
+ */
222
+ setChatPermissions(...args: Shorthand<'setChatPermissions'>): Promise<true>;
223
+ /**
224
+ * @see https://core.telegram.org/bots/api#getchatadministrators
225
+ */
226
+ getChatAdministrators(...args: Shorthand<'getChatAdministrators'>): Promise<(tg.ChatMemberOwner | tg.ChatMemberAdministrator)[]>;
227
+ /**
228
+ * @see https://core.telegram.org/bots/api#getchatmember
229
+ */
230
+ getChatMember(...args: Shorthand<'getChatMember'>): Promise<tg.ChatMember>;
231
+ /**
232
+ * @see https://core.telegram.org/bots/api#getchatmembercount
233
+ */
234
+ getChatMembersCount(...args: Shorthand<'getChatMembersCount'>): Promise<number>;
235
+ /**
236
+ * @see https://core.telegram.org/bots/api#setpassportdataerrors
237
+ */
238
+ setPassportDataErrors(errors: readonly tg.PassportElementError[]): Promise<true>;
239
+ /**
240
+ * @see https://core.telegram.org/bots/api#sendphoto
241
+ */
242
+ sendPhoto(photo: string | tg.InputFile, extra?: tt.ExtraPhoto): Promise<tg.Message.PhotoMessage>;
243
+ /**
244
+ * @see https://core.telegram.org/bots/api#sendphoto
245
+ */
246
+ replyWithPhoto(...args: Shorthand<'sendPhoto'>): Promise<tg.Message.PhotoMessage>;
247
+ /**
248
+ * @see https://core.telegram.org/bots/api#sendmediagroup
249
+ */
250
+ sendMediaGroup(media: tt.MediaGroup, extra?: tt.ExtraMediaGroup): Promise<(tg.Message.DocumentMessage | tg.Message.AudioMessage | tg.Message.PhotoMessage | tg.Message.VideoMessage)[]>;
251
+ /**
252
+ * @see https://core.telegram.org/bots/api#sendmediagroup
253
+ */
254
+ replyWithMediaGroup(...args: Shorthand<'sendMediaGroup'>): Promise<(tg.Message.DocumentMessage | tg.Message.AudioMessage | tg.Message.PhotoMessage | tg.Message.VideoMessage)[]>;
255
+ /**
256
+ * @see https://core.telegram.org/bots/api#sendaudio
257
+ */
258
+ sendAudio(audio: string | tg.InputFile, extra?: tt.ExtraAudio): Promise<tg.Message.AudioMessage>;
259
+ /**
260
+ * @see https://core.telegram.org/bots/api#sendaudio
261
+ */
262
+ replyWithAudio(...args: Shorthand<'sendAudio'>): Promise<tg.Message.AudioMessage>;
263
+ /**
264
+ * @see https://core.telegram.org/bots/api#senddice
265
+ */
266
+ sendDice(extra?: tt.ExtraDice): Promise<tg.Message.DiceMessage>;
267
+ /**
268
+ * @see https://core.telegram.org/bots/api#senddice
269
+ */
270
+ replyWithDice(...args: Shorthand<'sendDice'>): Promise<tg.Message.DiceMessage>;
271
+ /**
272
+ * @see https://core.telegram.org/bots/api#senddocument
273
+ */
274
+ sendDocument(document: string | tg.InputFile, extra?: tt.ExtraDocument): Promise<tg.Message.DocumentMessage>;
275
+ /**
276
+ * @see https://core.telegram.org/bots/api#senddocument
277
+ */
278
+ replyWithDocument(...args: Shorthand<'sendDocument'>): Promise<tg.Message.DocumentMessage>;
279
+ /**
280
+ * @see https://core.telegram.org/bots/api#sendsticker
281
+ */
282
+ sendSticker(sticker: string | tg.InputFile, extra?: tt.ExtraSticker): Promise<tg.Message.StickerMessage>;
283
+ /**
284
+ * @see https://core.telegram.org/bots/api#sendsticker
285
+ */
286
+ replyWithSticker(...args: Shorthand<'sendSticker'>): Promise<tg.Message.StickerMessage>;
287
+ /**
288
+ * @see https://core.telegram.org/bots/api#sendvideo
289
+ */
290
+ sendVideo(video: string | tg.InputFile, extra?: tt.ExtraVideo): Promise<tg.Message.VideoMessage>;
291
+ /**
292
+ * @see https://core.telegram.org/bots/api#sendvideo
293
+ */
294
+ replyWithVideo(...args: Shorthand<'sendVideo'>): Promise<tg.Message.VideoMessage>;
295
+ /**
296
+ * @see https://core.telegram.org/bots/api#sendanimation
297
+ */
298
+ sendAnimation(animation: string | tg.InputFile, extra?: tt.ExtraAnimation): Promise<tg.Message.AnimationMessage>;
299
+ /**
300
+ * @see https://core.telegram.org/bots/api#sendanimation
301
+ */
302
+ replyWithAnimation(...args: Shorthand<'sendAnimation'>): Promise<tg.Message.AnimationMessage>;
303
+ /**
304
+ * @see https://core.telegram.org/bots/api#sendvideonote
305
+ */
306
+ sendVideoNote(videoNote: string | tg.InputFileVideoNote, extra?: tt.ExtraVideoNote): Promise<tg.Message.VideoNoteMessage>;
307
+ /**
308
+ * @see https://core.telegram.org/bots/api#sendvideonote
309
+ */
310
+ replyWithVideoNote(...args: Shorthand<'sendVideoNote'>): Promise<tg.Message.VideoNoteMessage>;
311
+ /**
312
+ * @see https://core.telegram.org/bots/api#sendinvoice
313
+ */
314
+ sendInvoice(invoice: tt.NewInvoiceParameters, extra?: tt.ExtraInvoice): Promise<tg.Message.InvoiceMessage>;
315
+ /**
316
+ * @see https://core.telegram.org/bots/api#sendinvoice
317
+ */
318
+ replyWithInvoice(...args: Shorthand<'sendInvoice'>): Promise<tg.Message.InvoiceMessage>;
319
+ /**
320
+ * @see https://core.telegram.org/bots/api#sendgame
321
+ */
322
+ sendGame(game: string, extra?: tt.ExtraGame): Promise<tg.Message.GameMessage>;
323
+ /**
324
+ * @see https://core.telegram.org/bots/api#sendgame
325
+ */
326
+ replyWithGame(...args: Shorthand<'sendGame'>): Promise<tg.Message.GameMessage>;
327
+ /**
328
+ * @see https://core.telegram.org/bots/api#sendvoice
329
+ */
330
+ sendVoice(voice: string | tg.InputFile, extra?: tt.ExtraVoice): Promise<tg.Message.VoiceMessage>;
331
+ /**
332
+ * @see https://core.telegram.org/bots/api#sendvoice
333
+ */
334
+ replyWithVoice(...args: Shorthand<'sendVoice'>): Promise<tg.Message.VoiceMessage>;
335
+ /**
336
+ * @see https://core.telegram.org/bots/api#sendpoll
337
+ */
338
+ sendPoll(poll: string, options: readonly string[], extra?: tt.ExtraPoll): Promise<tg.Message.PollMessage>;
339
+ /**
340
+ * @see https://core.telegram.org/bots/api#sendpoll
341
+ */
342
+ replyWithPoll(...args: Shorthand<'sendPoll'>): Promise<tg.Message.PollMessage>;
343
+ /**
344
+ * @see https://core.telegram.org/bots/api#sendpoll
345
+ */
346
+ sendQuiz(quiz: string, options: readonly string[], extra?: tt.ExtraPoll): Promise<tg.Message.PollMessage>;
347
+ /**
348
+ * @see https://core.telegram.org/bots/api#sendpoll
349
+ */
350
+ replyWithQuiz(...args: Shorthand<'sendQuiz'>): Promise<tg.Message.PollMessage>;
351
+ /**
352
+ * @see https://core.telegram.org/bots/api#stoppoll
353
+ */
354
+ stopPoll(...args: Shorthand<'stopPoll'>): Promise<tg.Poll>;
355
+ /**
356
+ * @see https://core.telegram.org/bots/api#sendchataction
357
+ */
358
+ sendChatAction(action: Shorthand<'sendChatAction'>[0], extra?: tt.ExtraSendChatAction): Promise<true>;
359
+ /**
360
+ * @see https://core.telegram.org/bots/api#sendchataction
361
+ *
362
+ * Sends the sendChatAction request repeatedly, with a delay between requests,
363
+ * as long as the provided callback function is being processed.
364
+ *
365
+ * The sendChatAction errors should be ignored, because the goal is the actual long process completing and performing an action.
366
+ *
367
+ * @param action - chat action type.
368
+ * @param callback - a function to run along with the chat action.
369
+ * @param extra - extra parameters for sendChatAction.
370
+ * @param {number} [extra.intervalDuration=8000] - The duration (in milliseconds) between subsequent sendChatAction requests.
371
+ */
372
+ persistentChatAction(action: Shorthand<'sendChatAction'>[0], callback: () => Promise<void>, { intervalDuration, ...extra }?: tt.ExtraSendChatAction & {
373
+ intervalDuration?: number;
374
+ }): Promise<void>;
375
+ /**
376
+ * @deprecated use {@link Context.sendChatAction} instead
377
+ * @see https://core.telegram.org/bots/api#sendchataction
378
+ */
379
+ replyWithChatAction(...args: Shorthand<'sendChatAction'>): Promise<true>;
380
+ /**
381
+ * Shorthand for {@link Telegram.setMessageReaction}
382
+ * @param reaction An emoji or custom_emoji_id to set as reaction to current message. Leave empty to remove reactions.
383
+ * @param is_big Pass True to set the reaction with a big animation
384
+ */
385
+ react(reaction?: MaybeArray<tg.TelegramEmoji | `${Digit}${string}` | tg.ReactionType>, is_big?: boolean): Promise<true>;
386
+ /**
387
+ * @see https://core.telegram.org/bots/api#sendlocation
388
+ */
389
+ sendLocation(latitude: number, longitude: number, extra?: tt.ExtraLocation): Promise<tg.Message.LocationMessage>;
390
+ /**
391
+ * @see https://core.telegram.org/bots/api#sendlocation
392
+ */
393
+ replyWithLocation(...args: Shorthand<'sendLocation'>): Promise<tg.Message.LocationMessage>;
394
+ /**
395
+ * @see https://core.telegram.org/bots/api#sendvenue
396
+ */
397
+ sendVenue(latitude: number, longitude: number, title: string, address: string, extra?: tt.ExtraVenue): Promise<tg.Message.VenueMessage>;
398
+ /**
399
+ * @see https://core.telegram.org/bots/api#sendvenue
400
+ */
401
+ replyWithVenue(...args: Shorthand<'sendVenue'>): Promise<tg.Message.VenueMessage>;
402
+ /**
403
+ * @see https://core.telegram.org/bots/api#sendcontact
404
+ */
405
+ sendContact(phoneNumber: string, firstName: string, extra?: tt.ExtraContact): Promise<tg.Message.ContactMessage>;
406
+ /**
407
+ * @see https://core.telegram.org/bots/api#sendcontact
408
+ */
409
+ replyWithContact(...args: Shorthand<'sendContact'>): Promise<tg.Message.ContactMessage>;
410
+ /**
411
+ * @deprecated use {@link Telegram.getStickerSet}
412
+ * @see https://core.telegram.org/bots/api#getstickerset
413
+ */
414
+ getStickerSet(setName: string): Promise<tg.StickerSet>;
415
+ /**
416
+ * @see https://core.telegram.org/bots/api#setchatstickerset
417
+ */
418
+ setChatStickerSet(setName: string): Promise<true>;
419
+ /**
420
+ * @see https://core.telegram.org/bots/api#deletechatstickerset
421
+ */
422
+ deleteChatStickerSet(): Promise<true>;
423
+ /**
424
+ * Use this method to create a topic in a forum supergroup chat. The bot must be an administrator in the chat for this
425
+ * to work and must have the can_manage_topics administrator rights. Returns information about the created topic as a
426
+ * ForumTopic object.
427
+ *
428
+ * @see https://core.telegram.org/bots/api#createforumtopic
429
+ */
430
+ createForumTopic(...args: Shorthand<'createForumTopic'>): Promise<tg.ForumTopic>;
431
+ /**
432
+ * Use this method to edit name and icon of a topic in a forum supergroup chat. The bot must be an administrator in
433
+ * the chat for this to work and must have can_manage_topics administrator rights, unless it is the creator of the
434
+ * topic. Returns True on success.
435
+ *
436
+ * @see https://core.telegram.org/bots/api#editforumtopic
437
+ */
438
+ editForumTopic(extra: tt.ExtraEditForumTopic): Promise<true>;
439
+ /**
440
+ * Use this method to close an open topic in a forum supergroup chat. The bot must be an administrator in the chat
441
+ * for this to work and must have the can_manage_topics administrator rights, unless it is the creator of the topic.
442
+ * Returns True on success.
443
+ *
444
+ * @see https://core.telegram.org/bots/api#closeforumtopic
445
+ */
446
+ closeForumTopic(): Promise<true>;
447
+ /**
448
+ * Use this method to reopen a closed topic in a forum supergroup chat. The bot must be an administrator in the chat
449
+ * for this to work and must have the can_manage_topics administrator rights, unless it is the creator of the topic.
450
+ * Returns True on success.
451
+ *
452
+ * @see https://core.telegram.org/bots/api#reopenforumtopic
453
+ */
454
+ reopenForumTopic(): Promise<true>;
455
+ /**
456
+ * Use this method to delete a forum topic along with all its messages in a forum supergroup chat. The bot must be an
457
+ * administrator in the chat for this to work and must have the can_delete_messages administrator rights.
458
+ * Returns True on success.
459
+ *
460
+ * @see https://core.telegram.org/bots/api#deleteforumtopic
461
+ */
462
+ deleteForumTopic(): Promise<true>;
463
+ /**
464
+ * Use this method to clear the list of pinned messages in a forum topic. The bot must be an administrator in the chat
465
+ * for this to work and must have the can_pin_messages administrator right in the supergroup. Returns True on success.
466
+ *
467
+ * @see https://core.telegram.org/bots/api#unpinallforumtopicmessages
468
+ */
469
+ unpinAllForumTopicMessages(): Promise<true>;
470
+ /**
471
+ * Use this method to edit the name of the 'General' topic in a forum supergroup chat. The bot must be an administrator
472
+ * in the chat for this to work and must have can_manage_topics administrator rights. Returns True on success.
473
+ *
474
+ * @see https://core.telegram.org/bots/api#editgeneralforumtopic
475
+ */
476
+ editGeneralForumTopic(name: string): Promise<true>;
477
+ /**
478
+ * Use this method to close an open 'General' topic in a forum supergroup chat. The bot must be an administrator in the
479
+ * chat for this to work and must have the can_manage_topics administrator rights. Returns True on success.
480
+ *
481
+ * @see https://core.telegram.org/bots/api#closegeneralforumtopic
482
+ */
483
+ closeGeneralForumTopic(): Promise<true>;
484
+ /**
485
+ * Use this method to reopen a closed 'General' topic in a forum supergroup chat. The bot must be an administrator in
486
+ * the chat for this to work and must have the can_manage_topics administrator rights. The topic will be automatically
487
+ * unhidden if it was hidden. Returns True on success.
488
+ *
489
+ * @see https://core.telegram.org/bots/api#reopengeneralforumtopic
490
+ */
491
+ reopenGeneralForumTopic(): Promise<true>;
492
+ /**
493
+ * Use this method to hide the 'General' topic in a forum supergroup chat. The bot must be an administrator in the chat
494
+ * for this to work and must have the can_manage_topics administrator rights. The topic will be automatically closed
495
+ * if it was open. Returns True on success.
496
+ *
497
+ * @see https://core.telegram.org/bots/api#hidegeneralforumtopic
498
+ */
499
+ hideGeneralForumTopic(): Promise<true>;
500
+ /**
501
+ * Use this method to unhide the 'General' topic in a forum supergroup chat. The bot must be an administrator in the
502
+ * chat for this to work and must have the can_manage_topics administrator rights. Returns True on success.
503
+ *
504
+ * @see https://core.telegram.org/bots/api#unhidegeneralforumtopic
505
+ */
506
+ unhideGeneralForumTopic(): Promise<true>;
507
+ /**
508
+ * Use this method to clear the list of pinned messages in a General forum topic.
509
+ * The bot must be an administrator in the chat for this to work and must have the can_pin_messages administrator
510
+ * right in the supergroup.
511
+ *
512
+ * @param chat_id Unique identifier for the target chat or username of the target supergroup (in the format @supergroupusername)
513
+ *
514
+ * @see https://core.telegram.org/bots/api#unpinallgeneralforumtopicmessages
515
+ */
516
+ unpinAllGeneralForumTopicMessages(): Promise<true>;
517
+ /**
518
+ * @deprecated use {@link Telegram.setStickerPositionInSet}
519
+ * @see https://core.telegram.org/bots/api#setstickerpositioninset
520
+ */
521
+ setStickerPositionInSet(sticker: string, position: number): Promise<true>;
522
+ /**
523
+ * @deprecated use {@link Telegram.setStickerSetThumbnail}
524
+ * @see https://core.telegram.org/bots/api#setstickersetthumbnail
525
+ */
526
+ setStickerSetThumb(...args: Parameters<Telegram['setStickerSetThumbnail']>): Promise<true>;
527
+ setStickerSetThumbnail(...args: Parameters<Telegram['setStickerSetThumbnail']>): Promise<true>;
528
+ setStickerMaskPosition(...args: Parameters<Telegram['setStickerMaskPosition']>): Promise<true>;
529
+ setStickerKeywords(...args: Parameters<Telegram['setStickerKeywords']>): Promise<true>;
530
+ setStickerEmojiList(...args: Parameters<Telegram['setStickerEmojiList']>): Promise<true>;
531
+ deleteStickerSet(...args: Parameters<Telegram['deleteStickerSet']>): Promise<true>;
532
+ setStickerSetTitle(...args: Parameters<Telegram['setStickerSetTitle']>): Promise<true>;
533
+ setCustomEmojiStickerSetThumbnail(...args: Parameters<Telegram['setCustomEmojiStickerSetThumbnail']>): Promise<true>;
534
+ /**
535
+ * @deprecated use {@link Telegram.deleteStickerFromSet}
536
+ * @see https://core.telegram.org/bots/api#deletestickerfromset
537
+ */
538
+ deleteStickerFromSet(sticker: string): Promise<true>;
539
+ /**
540
+ * @see https://core.telegram.org/bots/api#uploadstickerfile
541
+ */
542
+ uploadStickerFile(...args: Shorthand<'uploadStickerFile'>): Promise<tg.File>;
543
+ /**
544
+ * @see https://core.telegram.org/bots/api#createnewstickerset
545
+ */
546
+ createNewStickerSet(...args: Shorthand<'createNewStickerSet'>): Promise<true>;
547
+ /**
548
+ * @see https://core.telegram.org/bots/api#addstickertoset
549
+ */
550
+ addStickerToSet(...args: Shorthand<'addStickerToSet'>): Promise<true>;
551
+ /**
552
+ * @deprecated use {@link Telegram.getMyCommands}
553
+ * @see https://core.telegram.org/bots/api#getmycommands
554
+ */
555
+ getMyCommands(): Promise<tg.BotCommand[]>;
556
+ /**
557
+ * @deprecated use {@link Telegram.setMyCommands}
558
+ * @see https://core.telegram.org/bots/api#setmycommands
559
+ */
560
+ setMyCommands(commands: readonly tg.BotCommand[]): Promise<true>;
561
+ /**
562
+ * @deprecated use {@link Context.replyWithMarkdownV2}
563
+ * @see https://core.telegram.org/bots/api#sendmessage
564
+ */
565
+ replyWithMarkdown(markdown: string, extra?: tt.ExtraReplyMessage): Promise<tg.Message.TextMessage>;
566
+ /**
567
+ * @see https://core.telegram.org/bots/api#sendmessage
568
+ */
569
+ replyWithMarkdownV2(markdown: string, extra?: tt.ExtraReplyMessage): Promise<tg.Message.TextMessage>;
570
+ /**
571
+ * @see https://core.telegram.org/bots/api#sendmessage
572
+ */
573
+ replyWithHTML(html: string, extra?: tt.ExtraReplyMessage): Promise<tg.Message.TextMessage>;
574
+ /**
575
+ * @see https://core.telegram.org/bots/api#deletemessage
576
+ */
577
+ deleteMessage(messageId?: number): Promise<true>;
578
+ /**
579
+ * Context-aware shorthand for {@link Telegram.deleteMessages}
580
+ * @param messageIds Identifiers of 1-100 messages to delete. See deleteMessage for limitations on which messages can be deleted
581
+ */
582
+ deleteMessages(messageIds: number[]): Promise<true>;
583
+ /**
584
+ * @see https://core.telegram.org/bots/api#forwardmessage
585
+ */
586
+ forwardMessage(chatId: string | number, extra?: Shorthand<'forwardMessage'>[2]): Promise<tg.Message>;
587
+ /**
588
+ * Shorthand for {@link Telegram.forwardMessages}
589
+ * @see https://core.telegram.org/bots/api#forwardmessages
590
+ */
591
+ forwardMessages(chatId: string | number, messageIds: number[], extra?: Shorthand<'forwardMessages'>[2]): Promise<tg.MessageId[]>;
592
+ /**
593
+ * @see https://core.telegram.org/bots/api#copymessage
594
+ */
595
+ copyMessage(chatId: string | number, extra?: tt.ExtraCopyMessage): Promise<tg.MessageId>;
596
+ /**
597
+ * Context-aware shorthand for {@link Telegram.copyMessages}
598
+ * @param chatId Unique identifier for the target chat or username of the target channel (in the format @channelusername)
599
+ * @param messageIds Identifiers of 1-100 messages in the chat from_chat_id to copy. The identifiers must be specified in a strictly increasing order.
600
+ */
601
+ copyMessages(chatId: number | string, messageIds: number[], extra?: tt.ExtraCopyMessages): Promise<tg.MessageId[]>;
602
+ /**
603
+ * @see https://core.telegram.org/bots/api#approvechatjoinrequest
604
+ */
605
+ approveChatJoinRequest(userId: number): Promise<true>;
606
+ /**
607
+ * @see https://core.telegram.org/bots/api#declinechatjoinrequest
608
+ */
609
+ declineChatJoinRequest(userId: number): Promise<true>;
610
+ /**
611
+ * @see https://core.telegram.org/bots/api#banchatsenderchat
612
+ */
613
+ banChatSenderChat(senderChatId: number): Promise<true>;
614
+ /**
615
+ * @see https://core.telegram.org/bots/api#unbanchatsenderchat
616
+ */
617
+ unbanChatSenderChat(senderChatId: number): Promise<true>;
618
+ /**
619
+ * Use this method to change the bot's menu button in the current private chat. Returns true on success.
620
+ * @see https://core.telegram.org/bots/api#setchatmenubutton
621
+ */
622
+ setChatMenuButton(menuButton?: tg.MenuButton): Promise<true>;
623
+ /**
624
+ * Use this method to get the current value of the bot's menu button in the current private chat. Returns MenuButton on success.
625
+ * @see https://core.telegram.org/bots/api#getchatmenubutton
626
+ */
627
+ getChatMenuButton(): Promise<tg.MenuButton>;
628
+ /**
629
+ * @see https://core.telegram.org/bots/api#setmydefaultadministratorrights
630
+ */
631
+ setMyDefaultAdministratorRights(extra?: Parameters<Telegram['setMyDefaultAdministratorRights']>[0]): Promise<true>;
632
+ /**
633
+ * @see https://core.telegram.org/bots/api#getmydefaultadministratorrights
634
+ */
635
+ getMyDefaultAdministratorRights(extra?: Parameters<Telegram['getMyDefaultAdministratorRights']>[0]): Promise<tg.ChatAdministratorRights>;
636
+ }
637
+ export default Context;
638
+ type UpdateTypes<U extends Deunionize<tg.Update>> = Extract<UnionKeys<U>, tt.UpdateType>;
639
+ export type GetUpdateContent<U extends tg.Update> = U extends tg.Update.CallbackQueryUpdate ? U['callback_query']['message'] : U[UpdateTypes<U>];
640
+ type Getter<U extends Deunionize<tg.Update>, P extends string> = PropOr<GetUpdateContent<U>, P>;
641
+ interface Msg {
642
+ isAccessible(): this is MaybeMessage<tg.Message>;
643
+ has<Ks extends UnionKeys<tg.Message>[]>(...keys: Ks): this is MaybeMessage<Keyed<tg.Message, Ks[number]>>;
644
+ }
645
+ declare const Msg: Msg;
646
+ export type MaybeMessage<M extends tg.MaybeInaccessibleMessage = tg.MaybeInaccessibleMessage> = M & Msg;
647
+ type GetMsg<U extends tg.Update> = U extends tg.Update.MessageUpdate ? U['message'] : U extends tg.Update.ChannelPostUpdate ? U['channel_post'] : U extends tg.Update.EditedChannelPostUpdate ? U['edited_channel_post'] : U extends tg.Update.EditedMessageUpdate ? U['edited_message'] : U extends tg.Update.CallbackQueryUpdate ? U['callback_query']['message'] : undefined;
648
+ type GetUserFromAnySource<U extends tg.Update> = GetMsg<U> extends {
649
+ from: tg.User;
650
+ } ? tg.User : U extends tg.Update.CallbackQueryUpdate | tg.Update.InlineQueryUpdate | tg.Update.ShippingQueryUpdate | tg.Update.PreCheckoutQueryUpdate | tg.Update.ChosenInlineResultUpdate | tg.Update.ChatMemberUpdate | tg.Update.MyChatMemberUpdate | tg.Update.ChatJoinRequestUpdate | tg.Update.MessageReactionUpdate | tg.Update.PollAnswerUpdate | tg.Update.ChatBoostUpdate ? tg.User : undefined;
651
+ type GetMsgId<U extends tg.Update> = GetMsg<U> extends {
652
+ message_id: number;
653
+ } ? number : U extends tg.Update.MessageReactionUpdate ? number : U extends tg.Update.MessageReactionCountUpdate ? number : undefined;
654
+ type GetText<U extends tg.Update> = GetMsg<U> extends tg.Message.TextMessage ? string : GetMsg<U> extends tg.Message ? string | undefined : U extends tg.Update.PollUpdate ? string | undefined : undefined;
655
+ //# sourceMappingURL=context.d.ts.map