@im-more/dsh-telegram 0.0.0-stage → 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 (122) hide show
  1. package/LICENSE +21 -0
  2. package/cordis.patch.yml +10 -0
  3. package/lib/index.js +2067 -0
  4. package/lib/index.js.map +1 -0
  5. package/lib/types/bot.d.ts +70 -0
  6. package/lib/types/bot.d.ts.map +1 -0
  7. package/lib/types/bot.js +231 -0
  8. package/lib/types/bot.js.map +1 -0
  9. package/lib/types/config.d.ts +34 -0
  10. package/lib/types/config.d.ts.map +1 -0
  11. package/lib/types/config.js +41 -0
  12. package/lib/types/config.js.map +1 -0
  13. package/lib/types/decode.d.ts +39 -0
  14. package/lib/types/decode.d.ts.map +1 -0
  15. package/lib/types/decode.js +382 -0
  16. package/lib/types/decode.js.map +1 -0
  17. package/lib/types/errors.d.ts +33 -0
  18. package/lib/types/errors.d.ts.map +1 -0
  19. package/lib/types/errors.js +89 -0
  20. package/lib/types/errors.js.map +1 -0
  21. package/lib/types/identity.d.ts +19 -0
  22. package/lib/types/identity.d.ts.map +1 -0
  23. package/lib/types/identity.js +34 -0
  24. package/lib/types/identity.js.map +1 -0
  25. package/lib/types/index.d.ts +10 -0
  26. package/lib/types/index.d.ts.map +1 -0
  27. package/lib/types/index.js +8 -0
  28. package/lib/types/index.js.map +1 -0
  29. package/lib/types/media.d.ts +38 -0
  30. package/lib/types/media.d.ts.map +1 -0
  31. package/lib/types/media.js +65 -0
  32. package/lib/types/media.js.map +1 -0
  33. package/lib/types/modes/html.d.ts +16 -0
  34. package/lib/types/modes/html.d.ts.map +1 -0
  35. package/lib/types/modes/html.js +155 -0
  36. package/lib/types/modes/html.js.map +1 -0
  37. package/lib/types/modes/plain.d.ts +14 -0
  38. package/lib/types/modes/plain.d.ts.map +1 -0
  39. package/lib/types/modes/plain.js +56 -0
  40. package/lib/types/modes/plain.js.map +1 -0
  41. package/lib/types/modes/shared.d.ts +140 -0
  42. package/lib/types/modes/shared.d.ts.map +1 -0
  43. package/lib/types/modes/shared.js +405 -0
  44. package/lib/types/modes/shared.js.map +1 -0
  45. package/lib/types/polling.d.ts +26 -0
  46. package/lib/types/polling.d.ts.map +1 -0
  47. package/lib/types/polling.js +149 -0
  48. package/lib/types/polling.js.map +1 -0
  49. package/lib/types/request.d.ts +67 -0
  50. package/lib/types/request.d.ts.map +1 -0
  51. package/lib/types/request.js +158 -0
  52. package/lib/types/request.js.map +1 -0
  53. package/lib/types/secret.d.ts +27 -0
  54. package/lib/types/secret.d.ts.map +1 -0
  55. package/lib/types/secret.js +39 -0
  56. package/lib/types/secret.js.map +1 -0
  57. package/lib/types/send.d.ts +48 -0
  58. package/lib/types/send.d.ts.map +1 -0
  59. package/lib/types/send.js +326 -0
  60. package/lib/types/send.js.map +1 -0
  61. package/lib/types/types/game.d.ts +102 -0
  62. package/lib/types/types/game.d.ts.map +1 -0
  63. package/lib/types/types/game.js +5 -0
  64. package/lib/types/types/game.js.map +1 -0
  65. package/lib/types/types/index.d.ts +2751 -0
  66. package/lib/types/types/index.d.ts.map +1 -0
  67. package/lib/types/types/index.js +88 -0
  68. package/lib/types/types/index.js.map +1 -0
  69. package/lib/types/types/inline.d.ts +796 -0
  70. package/lib/types/types/inline.d.ts.map +1 -0
  71. package/lib/types/types/inline.js +4 -0
  72. package/lib/types/types/inline.js.map +1 -0
  73. package/lib/types/types/internal.d.ts +32 -0
  74. package/lib/types/types/internal.d.ts.map +1 -0
  75. package/lib/types/types/internal.js +30 -0
  76. package/lib/types/types/internal.js.map +1 -0
  77. package/lib/types/types/passport.d.ts +229 -0
  78. package/lib/types/types/passport.d.ts.map +1 -0
  79. package/lib/types/types/passport.js +3 -0
  80. package/lib/types/types/passport.js.map +1 -0
  81. package/lib/types/types/payment.d.ts +285 -0
  82. package/lib/types/types/payment.d.ts.map +1 -0
  83. package/lib/types/types/payment.js +6 -0
  84. package/lib/types/types/payment.js.map +1 -0
  85. package/lib/types/types/sticker.d.ts +221 -0
  86. package/lib/types/types/sticker.d.ts.map +1 -0
  87. package/lib/types/types/sticker.js +11 -0
  88. package/lib/types/types/sticker.js.map +1 -0
  89. package/lib/types/types/update.d.ts +97 -0
  90. package/lib/types/types/update.d.ts.map +1 -0
  91. package/lib/types/types/update.js +6 -0
  92. package/lib/types/types/update.js.map +1 -0
  93. package/lib/types/webhook.d.ts +29 -0
  94. package/lib/types/webhook.d.ts.map +1 -0
  95. package/lib/types/webhook.js +129 -0
  96. package/lib/types/webhook.js.map +1 -0
  97. package/package.json +61 -3
  98. package/src/bot.ts +349 -0
  99. package/src/config.ts +73 -0
  100. package/src/decode.ts +472 -0
  101. package/src/errors.ts +103 -0
  102. package/src/identity.ts +41 -0
  103. package/src/index.ts +14 -0
  104. package/src/media.ts +79 -0
  105. package/src/modes/html.ts +193 -0
  106. package/src/modes/plain.ts +75 -0
  107. package/src/modes/shared.ts +505 -0
  108. package/src/polling.ts +176 -0
  109. package/src/request.ts +224 -0
  110. package/src/secret.ts +46 -0
  111. package/src/send.ts +454 -0
  112. package/src/types/.eslintrc.yml +2 -0
  113. package/src/types/game.ts +112 -0
  114. package/src/types/index.ts +3028 -0
  115. package/src/types/inline.ts +857 -0
  116. package/src/types/internal.ts +64 -0
  117. package/src/types/passport.ts +256 -0
  118. package/src/types/payment.ts +304 -0
  119. package/src/types/sticker.ts +244 -0
  120. package/src/types/update.ts +107 -0
  121. package/src/webhook.ts +168 -0
  122. package/README.md +0 -3
@@ -0,0 +1,64 @@
1
+ import { invoke, type TelegramRequest } from '../request.ts'
2
+ import type {
3
+ EditMessageCaptionPayload,
4
+ EditMessageTextPayload,
5
+ GetUpdatesPayload,
6
+ Message,
7
+ SendMessagePayload,
8
+ Update,
9
+ } from './index.ts'
10
+
11
+ /**
12
+ * Augmentation target for the typed Bot API methods registered by the
13
+ * declaration files in this directory.
14
+ */
15
+ export interface Internal {
16
+ /** Cancellable overloads for the generated methods the adapter awaits with a signal. */
17
+ sendMessage(
18
+ payload: SendMessagePayload,
19
+ signal?: AbortSignal,
20
+ ): Promise<Message>
21
+ editMessageText(
22
+ payload: EditMessageTextPayload,
23
+ signal?: AbortSignal,
24
+ ): Promise<Message>
25
+ editMessageCaption(
26
+ payload: EditMessageCaptionPayload,
27
+ signal?: AbortSignal,
28
+ ): Promise<Message>
29
+ getUpdates(
30
+ payload: GetUpdatesPayload,
31
+ signal?: AbortSignal,
32
+ ): Promise<Update[]>
33
+ }
34
+
35
+ /**
36
+ * Client for every Bot API method declared in this directory.
37
+ *
38
+ * Each declaration file ends with `Internal.define('methodName')` calls; this
39
+ * class turns them into prototype methods over the shared transport in
40
+ * `request.ts`, so the full upstream method surface stays callable
41
+ * without duplicating method bodies. The `declare module './internal.ts'`
42
+ * blocks in those files provide the parameter and return types.
43
+ */
44
+ export class Internal {
45
+ constructor(private readonly request: TelegramRequest) {}
46
+
47
+ /**
48
+ * Register one Bot API method from a declaration file.
49
+ * @param method - Bot API method name.
50
+ */
51
+ static define(method: string): void {
52
+ Object.defineProperty(Internal.prototype, method, {
53
+ configurable: true,
54
+ writable: true,
55
+ value: async function (
56
+ this: Internal,
57
+ data: object = {},
58
+ signal?: AbortSignal,
59
+ ) {
60
+ return await invoke(this.request, method, data, signal)
61
+ },
62
+ })
63
+ }
64
+ }
@@ -0,0 +1,256 @@
1
+ import { Integer, Internal } from './index.ts'
2
+
3
+ /**
4
+ * Contains information about Telegram Passport data shared with the bot by the user.
5
+ * @see https://core.telegram.org/bots/api#passportdata
6
+ */
7
+ export interface PassportData {
8
+ /** Array with information about documents and other Telegram Passport elements that was shared with the bot */
9
+ data?: EncryptedPassportElement[]
10
+ /** Encrypted credentials required to decrypt the data */
11
+ credentials?: EncryptedCredentials
12
+ }
13
+
14
+ /**
15
+ * This object represents a file uploaded to Telegram Passport. Currently all Telegram Passport files are in JPEG format when decrypted and don't exceed 10MB.
16
+ * @see https://core.telegram.org/bots/api#passportfile
17
+ */
18
+ export interface PassportFile {
19
+ /** Identifier for this file, which can be used to download or reuse the file */
20
+ file_id?: string
21
+ /** Unique identifier for this file, which is supposed to be the same over time and for different bots. Can't be used to download or reuse the file. */
22
+ file_unique_id?: string
23
+ /** File size in bytes */
24
+ file_size?: Integer
25
+ /** Unix time when the file was uploaded */
26
+ file_date?: Integer
27
+ }
28
+
29
+ /**
30
+ * Contains information about documents or other Telegram Passport elements shared with the bot by the user.
31
+ * @see https://core.telegram.org/bots/api#encryptedpassportelement
32
+ */
33
+ export interface EncryptedPassportElement {
34
+ /** Element type. One of "personal_details", "passport", "driver_license", "identity_card", "internal_passport", "address", "utility_bill", "bank_statement", "rental_agreement", "passport_registration", "temporary_registration", "phone_number", "email". */
35
+ type?: string
36
+ /** Optional. Base64-encoded encrypted Telegram Passport element data provided by the user, available for "personal_details", "passport", "driver_license", "identity_card", "internal_passport" and "address" types. Can be decrypted and verified using the accompanying EncryptedCredentials. */
37
+ data?: string
38
+ /** Optional. User's verified phone number, available only for "phone_number" type */
39
+ phone_number?: string
40
+ /** Optional. User's verified email address, available only for "email" type */
41
+ email?: string
42
+ /** Optional. encrypted files with documents provided by the user, available for "utility_bill", "bank_statement", "rental_agreement", "passport_registration" and "temporary_registration" types. Files can be decrypted and verified using the accompanying EncryptedCredentials. */
43
+ files?: PassportFile[]
44
+ /** Optional. Encrypted file with the front side of the document, provided by the user. Available for "passport", "driver_license", "identity_card" and "internal_passport". The file can be decrypted and verified using the accompanying EncryptedCredentials. */
45
+ front_side?: PassportFile
46
+ /** Optional. Encrypted file with the reverse side of the document, provided by the user. Available for "driver_license" and "identity_card". The file can be decrypted and verified using the accompanying EncryptedCredentials. */
47
+ reverse_side?: PassportFile
48
+ /** Optional. Encrypted file with the selfie of the user holding a document, provided by the user; available for "passport", "driver_license", "identity_card" and "internal_passport". The file can be decrypted and verified using the accompanying EncryptedCredentials. */
49
+ selfie?: PassportFile
50
+ /** Optional. encrypted files with translated versions of documents provided by the user. Available if requested for "passport", "driver_license", "identity_card", "internal_passport", "utility_bill", "bank_statement", "rental_agreement", "passport_registration" and "temporary_registration" types. Files can be decrypted and verified using the accompanying EncryptedCredentials. */
51
+ translation?: PassportFile[]
52
+ /** Base64-encoded element hash for using in PassportElementErrorUnspecified */
53
+ hash?: string
54
+ }
55
+
56
+ /**
57
+ * Contains data required for decrypting and authenticating EncryptedPassportElement. See the Telegram Passport Documentation for a complete description of the data decryption and authentication processes.
58
+ * @see https://core.telegram.org/bots/api#encryptedcredentials
59
+ */
60
+ export interface EncryptedCredentials {
61
+ /** Base64-encoded encrypted JSON-serialized data with unique user's payload, data hashes and secrets required for EncryptedPassportElement decryption and authentication */
62
+ data?: string
63
+ /** Base64-encoded data hash for data authentication */
64
+ hash?: string
65
+ /** Base64-encoded secret, encrypted with the bot's public RSA key, required for data decryption */
66
+ secret?: string
67
+ }
68
+
69
+ export interface SetPassportDataErrorsPayload {
70
+ /** User identifier */
71
+ user_id?: Integer
72
+ /** A JSON-serialized array describing the errors */
73
+ errors?: PassportElementError[]
74
+ }
75
+
76
+ /**
77
+ * This object represents an error in the Telegram Passport element which was submitted that should be resolved by the user. It should be one of:
78
+ * - PassportElementErrorDataField
79
+ * - PassportElementErrorFrontSide
80
+ * - PassportElementErrorReverseSide
81
+ * - PassportElementErrorSelfie
82
+ * - PassportElementErrorFile
83
+ * - PassportElementErrorFiles
84
+ * - PassportElementErrorTranslationFile
85
+ * - PassportElementErrorTranslationFiles
86
+ * - PassportElementErrorUnspecified
87
+ * @see https://core.telegram.org/bots/api#passportelementerror
88
+ */
89
+ export type PassportElementError =
90
+ | PassportElementErrorDataField
91
+ | PassportElementErrorFrontSide
92
+ | PassportElementErrorReverseSide
93
+ | PassportElementErrorSelfie
94
+ | PassportElementErrorFile
95
+ | PassportElementErrorFiles
96
+ | PassportElementErrorTranslationFile
97
+ | PassportElementErrorTranslationFiles
98
+ | PassportElementErrorUnspecified
99
+
100
+ /**
101
+ * Represents an issue in one of the data fields that was provided by the user. The error is considered resolved when the field's value changes.
102
+ * @see https://core.telegram.org/bots/api#passportelementerrordatafield
103
+ */
104
+ export interface PassportElementErrorDataField {
105
+ /** Error source, must be data */
106
+ source?: string
107
+ /** The section of the user's Telegram Passport which has the error, one of "personal_details", "passport", "driver_license", "identity_card", "internal_passport", "address" */
108
+ type?: string
109
+ /** Name of the data field which has the error */
110
+ field_name?: string
111
+ /** Base64-encoded data hash */
112
+ data_hash?: string
113
+ /** Error message */
114
+ message?: string
115
+ }
116
+
117
+ /**
118
+ * Represents an issue with the front side of a document. The error is considered resolved when the file with the front side of the document changes.
119
+ * @see https://core.telegram.org/bots/api#passportelementerrorfrontside
120
+ */
121
+ export interface PassportElementErrorFrontSide {
122
+ /** Error source, must be front_side */
123
+ source?: string
124
+ /** The section of the user's Telegram Passport which has the issue, one of "passport", "driver_license", "identity_card", "internal_passport" */
125
+ type?: string
126
+ /** Base64-encoded hash of the file with the front side of the document */
127
+ file_hash?: string
128
+ /** Error message */
129
+ message?: string
130
+ }
131
+
132
+ /**
133
+ * Represents an issue with the reverse side of a document. The error is considered resolved when the file with reverse side of the document changes.
134
+ * @see https://core.telegram.org/bots/api#passportelementerrorreverseside
135
+ */
136
+ export interface PassportElementErrorReverseSide {
137
+ /** Error source, must be reverse_side */
138
+ source?: string
139
+ /** The section of the user's Telegram Passport which has the issue, one of "driver_license", "identity_card" */
140
+ type?: string
141
+ /** Base64-encoded hash of the file with the reverse side of the document */
142
+ file_hash?: string
143
+ /** Error message */
144
+ message?: string
145
+ }
146
+
147
+ /**
148
+ * Represents an issue with the selfie with a document. The error is considered resolved when the file with the selfie changes.
149
+ * @see https://core.telegram.org/bots/api#passportelementerrorselfie
150
+ */
151
+ export interface PassportElementErrorSelfie {
152
+ /** Error source, must be selfie */
153
+ source?: string
154
+ /** The section of the user's Telegram Passport which has the issue, one of "passport", "driver_license", "identity_card", "internal_passport" */
155
+ type?: string
156
+ /** Base64-encoded hash of the file with the selfie */
157
+ file_hash?: string
158
+ /** Error message */
159
+ message?: string
160
+ }
161
+
162
+ /**
163
+ * Represents an issue with a document scan. The error is considered resolved when the file with the document scan changes.
164
+ * @see https://core.telegram.org/bots/api#passportelementerrorfile
165
+ */
166
+ export interface PassportElementErrorFile {
167
+ /** Error source, must be file */
168
+ source?: string
169
+ /** The section of the user's Telegram Passport which has the issue, one of "utility_bill", "bank_statement", "rental_agreement", "passport_registration", "temporary_registration" */
170
+ type?: string
171
+ /** Base64-encoded file hash */
172
+ file_hash?: string
173
+ /** Error message */
174
+ message?: string
175
+ }
176
+
177
+ /**
178
+ * Represents an issue with a list of scans. The error is considered resolved when the list of files containing the scans changes.
179
+ * @see https://core.telegram.org/bots/api#passportelementerrorfiles
180
+ */
181
+ export interface PassportElementErrorFiles {
182
+ /** Error source, must be files */
183
+ source?: string
184
+ /** The section of the user's Telegram Passport which has the issue, one of "utility_bill", "bank_statement", "rental_agreement", "passport_registration", "temporary_registration" */
185
+ type?: string
186
+ /** List of base64-encoded file hashes */
187
+ file_hashes?: string[]
188
+ /** Error message */
189
+ message?: string
190
+ }
191
+
192
+ /**
193
+ * Represents an issue with one of the files that constitute the translation of a document. The error is considered resolved when the file changes.
194
+ * @see https://core.telegram.org/bots/api#passportelementerrortranslationfile
195
+ */
196
+ export interface PassportElementErrorTranslationFile {
197
+ /** Error source, must be translation_file */
198
+ source?: string
199
+ /** Type of element of the user's Telegram Passport which has the issue, one of "passport", "driver_license", "identity_card", "internal_passport", "utility_bill", "bank_statement", "rental_agreement", "passport_registration", "temporary_registration" */
200
+ type?: string
201
+ /** Base64-encoded file hash */
202
+ file_hash?: string
203
+ /** Error message */
204
+ message?: string
205
+ }
206
+
207
+ /**
208
+ * Represents an issue with the translated version of a document. The error is considered resolved when a file with the document translation change.
209
+ * @see https://core.telegram.org/bots/api#passportelementerrortranslationfiles
210
+ */
211
+ export interface PassportElementErrorTranslationFiles {
212
+ /** Error source, must be translation_files */
213
+ source?: string
214
+ /** Type of element of the user's Telegram Passport which has the issue, one of "passport", "driver_license", "identity_card", "internal_passport", "utility_bill", "bank_statement", "rental_agreement", "passport_registration", "temporary_registration" */
215
+ type?: string
216
+ /** List of base64-encoded file hashes */
217
+ file_hashes?: string[]
218
+ /** Error message */
219
+ message?: string
220
+ }
221
+
222
+ /**
223
+ * Represents an issue in an unspecified place. The error is considered resolved when new data is added.
224
+ * @see https://core.telegram.org/bots/api#passportelementerrorunspecified
225
+ */
226
+ export interface PassportElementErrorUnspecified {
227
+ /** Error source, must be unspecified */
228
+ source?: string
229
+ /** Type of element of the user's Telegram Passport which has the issue */
230
+ type?: string
231
+ /** Base64-encoded element hash */
232
+ element_hash?: string
233
+ /** Error message */
234
+ message?: string
235
+ }
236
+
237
+ declare module './index.ts' {
238
+ interface Message {
239
+ /** Optional. Telegram Passport data */
240
+ passport_data?: PassportData
241
+ }
242
+ }
243
+
244
+ declare module './internal.ts' {
245
+ interface Internal {
246
+ /**
247
+ * Informs a user that some of the Telegram Passport elements they provided contains errors. The user will not be able to re-submit their Passport to you until the errors are fixed (the contents of the field for which you returned the error must change). Returns True on success.
248
+ *
249
+ * Use this if the data submitted by the user doesn't satisfy the standards your service requires for any reason. For example, if a birthday date seems invalid, a submitted document is blurry, a scan shows evidence of tampering, etc. Supply some details in the error message to make sure the user knows how to correct the issues.
250
+ * @see https://core.telegram.org/bots/api#setpassportdataerrors
251
+ */
252
+ setPassportDataErrors(payload: SetPassportDataErrorsPayload): Promise<boolean>
253
+ }
254
+ }
255
+
256
+ Internal.define('setPassportDataErrors')
@@ -0,0 +1,304 @@
1
+ import { InlineKeyboardMarkup, Integer, Internal, Message, User } from './index.ts'
2
+
3
+ export interface SendInvoicePayload {
4
+ /** Unique identifier for the target chat or username of the target channel (in the format @channelusername) */
5
+ chat_id?: Integer | string
6
+ /** Unique identifier for the target message thread (topic) of the forum; for forum supergroups only */
7
+ message_thread_id?: number
8
+ /** Product name, 1-32 characters */
9
+ title?: string
10
+ /** Product description, 1-255 characters */
11
+ description?: string
12
+ /** Bot-defined invoice payload, 1-128 bytes. This will not be displayed to the user, use for your internal processes. */
13
+ payload?: string
14
+ /** Payments provider token, obtained via Botfather */
15
+ provider_token?: string
16
+ /** Three-letter ISO 4217 currency code, see more on currencies */
17
+ currency?: string
18
+ /** Price breakdown, a JSON-serialized list of components (e.g. product price, tax, discount, delivery cost, delivery tax, bonus, etc.) */
19
+ prices?: LabeledPrice[]
20
+ /** The maximum accepted amount for tips in the smallest units of the currency (integer, not float/double). For example, for a maximum tip of US$ 1.45 pass max_tip_amount = 145. See the exp parameter in currencies.json, it shows the number of digits past the decimal point for each currency (2 for the majority of currencies). Defaults to 0 */
21
+ max_tip_amount?: Integer
22
+ /** A JSON-serialized array of suggested amounts of tips in the smallest units of the currency (integer, not float/double). At most 4 suggested tip amounts can be specified. The suggested tip amounts must be positive, passed in a strictly increased order and must not exceed max_tip_amount. */
23
+ suggested_tip_amounts?: Integer[]
24
+ /** Unique deep-linking parameter. If left empty, forwarded copies of the sent message will have a Pay button, allowing multiple users to pay directly from the forwarded message, using the same invoice. If non-empty, forwarded copies of the sent message will have a URL button with a deep link to the bot (instead of a Pay button), with the value used as the start parameter */
25
+ start_parameter?: string
26
+ /** A JSON-serialized data about the invoice, which will be shared with the payment provider. A detailed description of required fields should be provided by the payment provider. */
27
+ provider_data?: string
28
+ /** URL of the product photo for the invoice. Can be a photo of the goods or a marketing image for a service. People like it better when they see what they are paying for. */
29
+ photo_url?: string
30
+ /** Photo size */
31
+ photo_size?: Integer
32
+ /** Photo width */
33
+ photo_width?: Integer
34
+ /** Photo height */
35
+ photo_height?: Integer
36
+ /** Pass True, if you require the user's full name to complete the order */
37
+ need_name?: boolean
38
+ /** Pass True, if you require the user's phone number to complete the order */
39
+ need_phone_number?: boolean
40
+ /** Pass True, if you require the user's email address to complete the order */
41
+ need_email?: boolean
42
+ /** Pass True, if you require the user's shipping address to complete the order */
43
+ need_shipping_address?: boolean
44
+ /** Pass True, if user's phone number should be sent to provider */
45
+ send_phone_number_to_provider?: boolean
46
+ /** Pass True, if user's email address should be sent to provider */
47
+ send_email_to_provider?: boolean
48
+ /** Pass True, if the final price depends on the shipping method */
49
+ is_flexible?: boolean
50
+ /** Sends the message silently. Users will receive a notification with no sound. */
51
+ disable_notification?: boolean
52
+ /** Protects the contents of the sent message from forwarding and saving */
53
+ protect_content?: boolean
54
+ /** If the message is a reply, ID of the original message */
55
+ reply_to_message_id?: Integer
56
+ /** Pass True, if the message should be sent even if the specified replied-to message is not found */
57
+ allow_sending_without_reply?: boolean
58
+ /** A JSON-serialized object for an inline keyboard. If empty, one 'Pay total price' button will be shown. If not empty, the first button must be a Pay button. */
59
+ reply_markup?: InlineKeyboardMarkup
60
+ }
61
+
62
+ export interface CreateInvoiceLinkPayload {
63
+ /** Product name, 1-32 characters */
64
+ title: string
65
+ /** Product description, 1-255 characters */
66
+ description: string
67
+ /** Bot-defined invoice payload, 1-128 bytes. This will not be displayed to the user, use for your internal processes. */
68
+ payload: string
69
+ /** Payment provider token, obtained via BotFather */
70
+ provider_token: string
71
+ /** Three-letter ISO 4217 currency code, see more on currencies */
72
+ currency: string
73
+ /** Price breakdown, a JSON-serialized list of components (e.g. product price, tax, discount, delivery cost, delivery tax, bonus, etc.) */
74
+ prices: LabeledPrice[]
75
+ /** The maximum accepted amount for tips in the smallest units of the currency (integer, not float/double). For example, for a maximum tip of US$ 1.45 pass max_tip_amount = 145. See the exp parameter in currencies.json, it shows the number of digits past the decimal point for each currency (2 for the majority of currencies). Defaults to 0 */
76
+ max_tip_amount?: number
77
+ /** A JSON-serialized array of suggested amounts of tips in the smallest units of the currency (integer, not float/double). At most 4 suggested tip amounts can be specified. The suggested tip amounts must be positive, passed in a strictly increased order and must not exceed max_tip_amount. */
78
+ suggested_tip_amounts?: number[]
79
+ /** JSON-serialized data about the invoice, which will be shared with the payment provider. A detailed description of required fields should be provided by the payment provider. */
80
+ provider_data?: string
81
+ /** URL of the product photo for the invoice. Can be a photo of the goods or a marketing image for a service. */
82
+ photo_url?: string
83
+ /** Photo size in bytes */
84
+ photo_size?: number
85
+ /** Photo width */
86
+ photo_width?: number
87
+ /** Photo height */
88
+ photo_height?: number
89
+ /** Pass True if you require the user's full name to complete the order */
90
+ need_name?: boolean
91
+ /** Pass True if you require the user's phone number to complete the order */
92
+ need_phone_number?: boolean
93
+ /** Pass True if you require the user's email address to complete the order */
94
+ need_email?: boolean
95
+ /** Pass True if you require the user's shipping address to complete the order */
96
+ need_shipping_address?: boolean
97
+ /** Pass True if the user's phone number should be sent to the provider */
98
+ send_phone_number_to_provider?: boolean
99
+ /** Pass True if the user's email address should be sent to the provider */
100
+ send_email_to_provider?: boolean
101
+ /** Pass True if the final price depends on the shipping method */
102
+ is_flexible?: boolean
103
+ }
104
+
105
+ export interface AnswerShippingQueryPayload {
106
+ /** Unique identifier for the query to be answered */
107
+ shipping_query_id?: string
108
+ /** Specify True if delivery to the specified address is possible and False if there are any problems (for example, if delivery to the specified address is not possible) */
109
+ ok?: boolean
110
+ /** Required if ok is True. A JSON-serialized array of available shipping options. */
111
+ shipping_options?: ShippingOption[]
112
+ /** Required if ok is False. Error message in human readable form that explains why it is impossible to complete the order (e.g. "Sorry, delivery to your desired address is unavailable'). Telegram will display this message to the user. */
113
+ error_message?: string
114
+ }
115
+
116
+ export interface AnswerPreCheckoutQueryPayload {
117
+ /** Unique identifier for the query to be answered */
118
+ pre_checkout_query_id?: string
119
+ /** Specify True if everything is alright (goods are available, etc.) and the bot is ready to proceed with the order. Use False if there are any problems. */
120
+ ok?: boolean
121
+ /** Required if ok is False. Error message in human readable form that explains the reason for failure to proceed with the checkout (e.g. "Sorry, somebody just bought the last of our amazing black T-shirts while you were busy filling out your payment details. Please choose a different color or garment!"). Telegram will display this message to the user. */
122
+ error_message?: string
123
+ }
124
+
125
+ /**
126
+ * This object represents a portion of the price for goods or services.
127
+ * @see https://core.telegram.org/bots/api#labeledprice
128
+ */
129
+ export interface LabeledPrice {
130
+ /** Portion label */
131
+ label?: string
132
+ /** Price of the product in the smallest units of the currency (integer, not float/double). For example, for a price of US$ 1.45 pass amount = 145. See the exp parameter in currencies.json, it shows the number of digits past the decimal point for each currency (2 for the majority of currencies). */
133
+ amount?: Integer
134
+ }
135
+
136
+ /**
137
+ * This object contains basic information about an invoice.
138
+ * @see https://core.telegram.org/bots/api#invoice
139
+ */
140
+ export interface Invoice {
141
+ /** Product name */
142
+ title?: string
143
+ /** Product description */
144
+ description?: string
145
+ /** Unique bot deep-linking parameter that can be used to generate this invoice */
146
+ start_parameter?: string
147
+ /** Three-letter ISO 4217 currency code */
148
+ currency?: string
149
+ /** Total price in the smallest units of the currency (integer, not float/double). For example, for a price of US$ 1.45 pass amount = 145. See the exp parameter in currencies.json, it shows the number of digits past the decimal point for each currency (2 for the majority of currencies). */
150
+ total_amount?: Integer
151
+ }
152
+
153
+ /**
154
+ * This object represents a shipping address.
155
+ * @see https://core.telegram.org/bots/api#shippingaddress
156
+ */
157
+ export interface ShippingAddress {
158
+ /** ISO 3166-1 alpha-2 country code */
159
+ country_code?: string
160
+ /** State, if applicable */
161
+ state?: string
162
+ /** City */
163
+ city?: string
164
+ /** First line for the address */
165
+ street_line1?: string
166
+ /** Second line for the address */
167
+ street_line2?: string
168
+ /** Address post code */
169
+ post_code?: string
170
+ }
171
+
172
+ /**
173
+ * This object represents information about an order.
174
+ * @see https://core.telegram.org/bots/api#orderinfo
175
+ */
176
+ export interface OrderInfo {
177
+ /** Optional. User name */
178
+ name?: string
179
+ /** Optional. User's phone number */
180
+ phone_number?: string
181
+ /** Optional. User email */
182
+ email?: string
183
+ /** Optional. User shipping address */
184
+ shipping_address?: ShippingAddress
185
+ }
186
+
187
+ /**
188
+ * This object represents one shipping option.
189
+ * @see https://core.telegram.org/bots/api#shippingoption
190
+ */
191
+ export interface ShippingOption {
192
+ /** Shipping option identifier */
193
+ id?: string
194
+ /** Option title */
195
+ title?: string
196
+ /** List of price portions */
197
+ prices?: LabeledPrice[]
198
+ }
199
+
200
+ /**
201
+ * This object contains basic information about a successful payment.
202
+ * @see https://core.telegram.org/bots/api#successfulpayment
203
+ */
204
+ export interface SuccessfulPayment {
205
+ /** Three-letter ISO 4217 currency code */
206
+ currency?: string
207
+ /** Total price in the smallest units of the currency (integer, not float/double). For example, for a price of US$ 1.45 pass amount = 145. See the exp parameter in currencies.json, it shows the number of digits past the decimal point for each currency (2 for the majority of currencies). */
208
+ total_amount?: Integer
209
+ /** Bot specified invoice payload */
210
+ invoice_payload?: string
211
+ /** Optional. Identifier of the shipping option chosen by the user */
212
+ shipping_option_id?: string
213
+ /** Optional. Order info provided by the user */
214
+ order_info?: OrderInfo
215
+ /** Telegram payment identifier */
216
+ telegram_payment_charge_id?: string
217
+ /** Provider payment identifier */
218
+ provider_payment_charge_id?: string
219
+ }
220
+
221
+ /**
222
+ * This object contains information about an incoming shipping query.
223
+ * @see https://core.telegram.org/bots/api#shippingquery
224
+ */
225
+ export interface ShippingQuery {
226
+ /** Unique query identifier */
227
+ id?: string
228
+ /** User who sent the query */
229
+ from?: User
230
+ /** Bot specified invoice payload */
231
+ invoice_payload?: string
232
+ /** User specified shipping address */
233
+ shipping_address?: ShippingAddress
234
+ }
235
+
236
+ /**
237
+ * This object contains information about an incoming pre-checkout query.
238
+ * @see https://core.telegram.org/bots/api#precheckoutquery
239
+ */
240
+ export interface PreCheckoutQuery {
241
+ /** Unique query identifier */
242
+ id?: string
243
+ /** User who sent the query */
244
+ from?: User
245
+ /** Three-letter ISO 4217 currency code */
246
+ currency?: string
247
+ /** Total price in the smallest units of the currency (integer, not float/double). For example, for a price of US$ 1.45 pass amount = 145. See the exp parameter in currencies.json, it shows the number of digits past the decimal point for each currency (2 for the majority of currencies). */
248
+ total_amount?: Integer
249
+ /** Bot specified invoice payload */
250
+ invoice_payload?: string
251
+ /** Optional. Identifier of the shipping option chosen by the user */
252
+ shipping_option_id?: string
253
+ /** Optional. Order info provided by the user */
254
+ order_info?: OrderInfo
255
+ }
256
+
257
+ declare module './index.ts' {
258
+ interface Message {
259
+ /** Optional. Message is an invoice for a payment, information about the invoice. More about payments » */
260
+ invoice?: Invoice
261
+ /** Optional. Message is a service message about a successful payment, information about the payment. More about payments » */
262
+ successful_payment?: SuccessfulPayment
263
+ }
264
+ }
265
+
266
+ declare module './update.ts' {
267
+ interface Update {
268
+ /** Optional. New incoming shipping query. Only for invoices with flexible price */
269
+ shipping_query?: ShippingQuery
270
+ /** Optional. New incoming pre-checkout query. Contains full information about checkout */
271
+ pre_checkout_query?: PreCheckoutQuery
272
+ }
273
+ }
274
+
275
+ declare module './internal.ts' {
276
+ interface Internal {
277
+ /**
278
+ * Use this method to send invoices. On success, the sent Message is returned.
279
+ * @see https://core.telegram.org/bots/api#sendinvoice
280
+ */
281
+ sendInvoice(payload: SendInvoicePayload): Promise<Message>
282
+ /**
283
+ * Use this method to create a link for an invoice. Returns the created invoice link as String on success.
284
+ * @see https://core.telegram.org/bots/api#createinvoicelink
285
+ */
286
+ createInvoiceLink(payload: CreateInvoiceLinkPayload): Promise<string>
287
+ /**
288
+ * If you sent an invoice requesting a shipping address and the parameter is_flexible was specified, the Bot API will send an Update with a shipping_query field to the bot. Use this method to reply to shipping queries. On success, True is returned.
289
+ * @see https://core.telegram.org/bots/api#answershippingquery
290
+ */
291
+ answerShippingQuery(payload: AnswerShippingQueryPayload): Promise<boolean>
292
+ /**
293
+ * Once the user has confirmed their payment and shipping details, the Bot API sends the final confirmation in the form of an Update with the field pre_checkout_query. Use this method to respond to such pre-checkout queries. On success, True is returned.
294
+ * Note: The Bot API must receive an answer within 10 seconds after the pre-checkout query was sent.
295
+ * @see https://core.telegram.org/bots/api#answerprecheckoutquery
296
+ */
297
+ answerPreCheckoutQuery(payload: AnswerPreCheckoutQueryPayload): Promise<boolean>
298
+ }
299
+ }
300
+
301
+ Internal.define('sendInvoice')
302
+ Internal.define('createInvoiceLink')
303
+ Internal.define('answerShippingQuery')
304
+ Internal.define('answerPreCheckoutQuery')