teleproto 1.214.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 (222) hide show
  1. package/CryptoFile.d.ts +2 -0
  2. package/CryptoFile.js +37 -0
  3. package/Helpers.d.ts +150 -0
  4. package/Helpers.js +477 -0
  5. package/LICENSE +23 -0
  6. package/Password.d.ts +14 -0
  7. package/Password.js +270 -0
  8. package/README.md +98 -0
  9. package/Utils.d.ts +227 -0
  10. package/Utils.js +1247 -0
  11. package/Version.d.ts +1 -0
  12. package/Version.js +4 -0
  13. package/client/2fa.d.ts +48 -0
  14. package/client/2fa.js +108 -0
  15. package/client/TelegramClient.d.ts +1043 -0
  16. package/client/TelegramClient.js +1181 -0
  17. package/client/account.d.ts +0 -0
  18. package/client/account.js +1 -0
  19. package/client/auth.d.ts +92 -0
  20. package/client/auth.js +388 -0
  21. package/client/bots.d.ts +6 -0
  22. package/client/bots.js +23 -0
  23. package/client/buttons.d.ts +4 -0
  24. package/client/buttons.js +86 -0
  25. package/client/chats.d.ts +45 -0
  26. package/client/chats.js +350 -0
  27. package/client/dialogs.d.ts +52 -0
  28. package/client/dialogs.js +174 -0
  29. package/client/downloads.d.ts +156 -0
  30. package/client/downloads.js +614 -0
  31. package/client/fs.d.ts +1 -0
  32. package/client/fs.js +17 -0
  33. package/client/index.d.ts +15 -0
  34. package/client/index.js +64 -0
  35. package/client/messageParse.d.ts +17 -0
  36. package/client/messageParse.js +191 -0
  37. package/client/messages.d.ts +263 -0
  38. package/client/messages.js +813 -0
  39. package/client/os.d.ts +2 -0
  40. package/client/os.js +37 -0
  41. package/client/path.d.ts +2 -0
  42. package/client/path.js +7 -0
  43. package/client/telegramBaseClient.d.ts +237 -0
  44. package/client/telegramBaseClient.js +368 -0
  45. package/client/updates.d.ts +33 -0
  46. package/client/updates.js +260 -0
  47. package/client/uploads.d.ts +136 -0
  48. package/client/uploads.js +514 -0
  49. package/client/users.d.ts +29 -0
  50. package/client/users.js +490 -0
  51. package/crypto/AuthKey.d.ts +19 -0
  52. package/crypto/AuthKey.js +76 -0
  53. package/crypto/CTR.d.ts +5 -0
  54. package/crypto/CTR.js +16 -0
  55. package/crypto/Factorizator.d.ts +19 -0
  56. package/crypto/Factorizator.js +74 -0
  57. package/crypto/IGE.d.ts +11 -0
  58. package/crypto/IGE.js +115 -0
  59. package/crypto/RSA.d.ts +14 -0
  60. package/crypto/RSA.js +70 -0
  61. package/crypto/converters.d.ts +19 -0
  62. package/crypto/converters.js +52 -0
  63. package/crypto/crypto.d.ts +19 -0
  64. package/crypto/crypto.js +58 -0
  65. package/crypto/words.d.ts +6 -0
  66. package/crypto/words.js +47 -0
  67. package/define.d.ts +77 -0
  68. package/entityCache.d.ts +7 -0
  69. package/entityCache.js +79 -0
  70. package/errors/Common.d.ts +71 -0
  71. package/errors/Common.js +122 -0
  72. package/errors/RPCBaseErrors.d.ts +84 -0
  73. package/errors/RPCBaseErrors.js +134 -0
  74. package/errors/RPCErrorList.d.ts +37 -0
  75. package/errors/RPCErrorList.js +117 -0
  76. package/errors/index.d.ts +11 -0
  77. package/errors/index.js +32 -0
  78. package/events/Album.d.ts +36 -0
  79. package/events/Album.js +104 -0
  80. package/events/CallbackQuery.d.ts +73 -0
  81. package/events/CallbackQuery.js +193 -0
  82. package/events/DeletedMessage.d.ts +45 -0
  83. package/events/DeletedMessage.js +63 -0
  84. package/events/EditedMessage.d.ts +30 -0
  85. package/events/EditedMessage.js +41 -0
  86. package/events/NewMessage.d.ts +89 -0
  87. package/events/NewMessage.js +182 -0
  88. package/events/Raw.d.ts +29 -0
  89. package/events/Raw.js +43 -0
  90. package/events/common.d.ts +66 -0
  91. package/events/common.js +141 -0
  92. package/events/index.d.ts +2 -0
  93. package/events/index.js +8 -0
  94. package/extensions/AsyncQueue.d.ts +10 -0
  95. package/extensions/AsyncQueue.js +32 -0
  96. package/extensions/BinaryReader.d.ts +99 -0
  97. package/extensions/BinaryReader.js +242 -0
  98. package/extensions/BinaryWriter.d.ts +6 -0
  99. package/extensions/BinaryWriter.js +15 -0
  100. package/extensions/Deferred.d.ts +8 -0
  101. package/extensions/Deferred.js +16 -0
  102. package/extensions/Logger.d.ts +54 -0
  103. package/extensions/Logger.js +128 -0
  104. package/extensions/MessagePacker.d.ts +21 -0
  105. package/extensions/MessagePacker.js +154 -0
  106. package/extensions/PendingState.d.ts +12 -0
  107. package/extensions/PendingState.js +29 -0
  108. package/extensions/PromisedNetSockets.d.ts +24 -0
  109. package/extensions/PromisedNetSockets.js +192 -0
  110. package/extensions/PromisedWebSockets.d.ts +18 -0
  111. package/extensions/PromisedWebSockets.js +124 -0
  112. package/extensions/html.d.ts +5 -0
  113. package/extensions/html.js +228 -0
  114. package/extensions/index.d.ts +7 -0
  115. package/extensions/index.js +17 -0
  116. package/extensions/markdown.d.ts +5 -0
  117. package/extensions/markdown.js +76 -0
  118. package/extensions/markdownv2.d.ts +5 -0
  119. package/extensions/markdownv2.js +51 -0
  120. package/extensions/net.d.ts +1 -0
  121. package/extensions/net.js +17 -0
  122. package/extensions/socks.d.ts +1 -0
  123. package/extensions/socks.js +17 -0
  124. package/index.d.ts +14 -0
  125. package/index.js +62 -0
  126. package/inspect.d.ts +1 -0
  127. package/inspect.js +5 -0
  128. package/network/Authenticator.d.ts +12 -0
  129. package/network/Authenticator.js +192 -0
  130. package/network/MTProtoPlainSender.d.ts +19 -0
  131. package/network/MTProtoPlainSender.js +74 -0
  132. package/network/MTProtoSender.d.ts +290 -0
  133. package/network/MTProtoSender.js +873 -0
  134. package/network/MTProtoState.d.ts +102 -0
  135. package/network/MTProtoState.js +267 -0
  136. package/network/RequestState.d.ts +18 -0
  137. package/network/RequestState.js +35 -0
  138. package/network/connection/Connection.d.ts +69 -0
  139. package/network/connection/Connection.js +162 -0
  140. package/network/connection/TCPAbridged.d.ts +19 -0
  141. package/network/connection/TCPAbridged.js +58 -0
  142. package/network/connection/TCPFull.d.ts +16 -0
  143. package/network/connection/TCPFull.js +61 -0
  144. package/network/connection/TCPMTProxy.d.ts +49 -0
  145. package/network/connection/TCPMTProxy.js +121 -0
  146. package/network/connection/TCPObfuscated.d.ts +18 -0
  147. package/network/connection/TCPObfuscated.js +78 -0
  148. package/network/connection/index.d.ts +4 -0
  149. package/network/connection/index.js +11 -0
  150. package/network/index.d.ts +11 -0
  151. package/network/index.js +23 -0
  152. package/package.json +50 -0
  153. package/requestIter.d.ts +24 -0
  154. package/requestIter.js +109 -0
  155. package/sessions/Abstract.d.ts +103 -0
  156. package/sessions/Abstract.js +6 -0
  157. package/sessions/Memory.d.ts +38 -0
  158. package/sessions/Memory.js +272 -0
  159. package/sessions/StoreSession.d.ts +14 -0
  160. package/sessions/StoreSession.js +77 -0
  161. package/sessions/StringSession.d.ts +32 -0
  162. package/sessions/StringSession.js +116 -0
  163. package/sessions/index.d.ts +4 -0
  164. package/sessions/index.js +11 -0
  165. package/sessions/localStorage.d.ts +1 -0
  166. package/sessions/localStorage.js +4 -0
  167. package/tl/AllTLObjects.d.ts +3 -0
  168. package/tl/AllTLObjects.js +17 -0
  169. package/tl/MTProtoRequest.d.ts +18 -0
  170. package/tl/MTProtoRequest.js +38 -0
  171. package/tl/api.d.ts +32488 -0
  172. package/tl/api.js +507 -0
  173. package/tl/apiTl.d.ts +2 -0
  174. package/tl/apiTl.js +2209 -0
  175. package/tl/core/GZIPPacked.d.ts +15 -0
  176. package/tl/core/GZIPPacked.js +51 -0
  177. package/tl/core/MessageContainer.d.ts +12 -0
  178. package/tl/core/MessageContainer.js +42 -0
  179. package/tl/core/RPCResult.d.ts +14 -0
  180. package/tl/core/RPCResult.js +32 -0
  181. package/tl/core/TLMessage.d.ts +10 -0
  182. package/tl/core/TLMessage.js +14 -0
  183. package/tl/core/index.d.ts +6 -0
  184. package/tl/core/index.js +16 -0
  185. package/tl/custom/button.d.ts +24 -0
  186. package/tl/custom/button.js +78 -0
  187. package/tl/custom/chatGetter.d.ts +29 -0
  188. package/tl/custom/chatGetter.js +116 -0
  189. package/tl/custom/dialog.d.ts +30 -0
  190. package/tl/custom/dialog.js +40 -0
  191. package/tl/custom/draft.d.ts +21 -0
  192. package/tl/custom/draft.js +48 -0
  193. package/tl/custom/file.d.ts +21 -0
  194. package/tl/custom/file.js +68 -0
  195. package/tl/custom/forward.d.ts +15 -0
  196. package/tl/custom/forward.js +47 -0
  197. package/tl/custom/index.d.ts +1 -0
  198. package/tl/custom/index.js +5 -0
  199. package/tl/custom/inlineResult.d.ts +32 -0
  200. package/tl/custom/inlineResult.js +87 -0
  201. package/tl/custom/inlineResults.d.ts +20 -0
  202. package/tl/custom/inlineResults.js +26 -0
  203. package/tl/custom/message.d.ts +427 -0
  204. package/tl/custom/message.js +716 -0
  205. package/tl/custom/messageButton.d.ts +54 -0
  206. package/tl/custom/messageButton.js +152 -0
  207. package/tl/custom/senderGetter.d.ts +28 -0
  208. package/tl/custom/senderGetter.js +55 -0
  209. package/tl/generateModule.d.ts +1 -0
  210. package/tl/generateModule.js +17 -0
  211. package/tl/generationHelpers.d.ts +11 -0
  212. package/tl/generationHelpers.js +289 -0
  213. package/tl/index.d.ts +3 -0
  214. package/tl/index.js +10 -0
  215. package/tl/patched/index.d.ts +2 -0
  216. package/tl/patched/index.js +76 -0
  217. package/tl/schemaTl.d.ts +2 -0
  218. package/tl/schemaTl.js +64 -0
  219. package/tl/types-generator/generate.d.ts +1 -0
  220. package/tl/types-generator/generate.js +84 -0
  221. package/tl/types-generator/template.d.ts +6 -0
  222. package/tl/types-generator/template.js +257 -0
@@ -0,0 +1,1043 @@
1
+ import { TelegramBaseClient, TelegramClientParams } from "./telegramBaseClient";
2
+ import * as authMethods from "./auth";
3
+ import * as downloadMethods from "./downloads";
4
+ import * as parseMethods from "./messageParse";
5
+ import * as messageMethods from "./messages";
6
+ import * as uploadMethods from "./uploads";
7
+ import * as chatMethods from "./chats";
8
+ import * as dialogMethods from "./dialogs";
9
+ import * as twoFA from "./2fa";
10
+ import type { ButtonLike, Entity, EntityLike, MessageIDLike } from "../define";
11
+ import { Api } from "../tl";
12
+ import type { EventBuilder } from "../events/common";
13
+ import { MTProtoSender } from "../network";
14
+ import { DownloadMediaInterface } from "./downloads";
15
+ import { NewMessage, NewMessageEvent } from "../events";
16
+ import { Session } from "../sessions";
17
+ import { Album, AlbumEvent } from "../events/Album";
18
+ import { CallbackQuery, CallbackQueryEvent } from "../events/CallbackQuery";
19
+ import { EditedMessage, EditedMessageEvent } from "../events/EditedMessage";
20
+ import { DeletedMessage, DeletedMessageEvent } from "../events/DeletedMessage";
21
+ import { inspect } from "../inspect";
22
+ /**
23
+ * The TelegramClient uses several methods in different files to provide all the common functionality in a nice interface.</br>
24
+ * **In short, to create a client you must do:**
25
+ *
26
+ * ```ts
27
+ * import {TelegramClient} from "teleproto";
28
+ *
29
+ * const client = new TelegramClient(new StringSession(''),apiId,apiHash,{});
30
+ * ```
31
+ *
32
+ * You don't need to import any methods that are inside the TelegramClient class as they binding in it.
33
+ */
34
+ export declare class TelegramClient extends TelegramBaseClient {
35
+ /**
36
+ * @param session - a session to be used to save the connection and auth key to. This can be a custom session that inherits MemorySession.
37
+ * @param apiId - The API ID you obtained from https://my.telegram.org.
38
+ * @param apiHash - The API hash you obtained from https://my.telegram.org.
39
+ * @param clientParams - see {@link TelegramClientParams}
40
+ */
41
+ constructor(session: string | Session, apiId: number, apiHash: string, clientParams: TelegramClientParams);
42
+ /**
43
+ * Used to handle all aspects of connecting to telegram.<br/>
44
+ * This method will connect to the telegram servers and check if the user is already logged in.<br/>
45
+ * in the case of a new connection this will sign in if the phone already exists or sign up otherwise<br/>
46
+ * By using this method you are **agreeing to Telegram's Terms of Service** https://core.telegram.org/api/terms.<br/>
47
+ * this method also calls {@link getMe} to tell telegram that we want to receive updates.<br/>
48
+ * @param authParams - see UserAuthParams and BotAuthParams
49
+ * @return nothing
50
+ * @example
51
+ * ```ts
52
+ * // this example assumes you've installed and imported the input package. npm i input.
53
+ * // This package uses CLI to receive input from the user. you can use your own callback function.
54
+ * import { TelegramClient } from "teleproto";
55
+ * import { StringSession } from "teleproto/sessions";
56
+ *
57
+ * const client = new TelegramClient(new StringSession(''), apiId, apiHash, {});
58
+ * // logging in as a bot account
59
+ * await client.start(botToken="123456:abcdfgh123456789);
60
+ * // logging in as a user account
61
+ * await client.start({
62
+ * phoneNumber: async () => await input.text("number ?"),
63
+ * password: async () => await input.text("password?"),
64
+ * phoneCode: async () => await input.text("Code ?"),
65
+ * onError: (err) => console.log(err),
66
+ * });
67
+ * >Number ? +1234567897
68
+ * >Code ? 12345
69
+ * >password ? 111111
70
+ * Logged in as user...
71
+ *
72
+ * You can now use the client instance to call other api requests.
73
+ */
74
+ start(authParams: authMethods.UserAuthParams | authMethods.BotAuthParams): Promise<void>;
75
+ /**
76
+ * Checks whether the current client is authorized or not. (logged in as a user)
77
+ * @example
78
+ * ```ts
79
+ * await client.connect();
80
+ * if (await client.checkAuthorization()){
81
+ * console.log("I am logged in!");
82
+ * }else{
83
+ * console.log("I am connected to telegram servers but not logged in with any account/bot");
84
+ * }
85
+ * ```
86
+ * @return boolean (true of authorized else false)
87
+ */
88
+ checkAuthorization(): Promise<boolean>;
89
+ /**
90
+ * Logs in as a user. Should only be used when not already logged in.<br/>
91
+ * This method will send a code when needed.<br/>
92
+ * This will also sign up if needed.
93
+ * @example
94
+ * ```ts
95
+ * await client.connect();
96
+ * // we should only use this when we are not already authorized.
97
+ * // This function is very similar to `client.start`
98
+ * // The minor difference that start checks if already authorized and supports bots as well.
99
+ * if (!await client.checkAuthorization()){
100
+ * const phoneNumber = "+123456789";
101
+ * await client.signIn({
102
+ * apiId:132456,
103
+ * apiHash:"132456",
104
+ * },{
105
+ * phoneNumber: async () => await input.text("number ?"),
106
+ * password: async () => await input.text("password?"),
107
+ * phoneCode: async () => await input.text("Code ?"),
108
+ * onError: (err) => console.log(err),
109
+ * })
110
+ * }
111
+ * ```
112
+ * @param apiCredentials - credentials to be used.
113
+ * @param authParams - user auth params.
114
+ */
115
+ signInUser(apiCredentials: authMethods.ApiCredentials, authParams: authMethods.UserAuthParams): Promise<Api.TypeUser>;
116
+ /**
117
+ * logs the user using a QR code to be scanned.<br/>
118
+ * this function generates the QR code that needs to be scanned by mobile.
119
+ * @example
120
+ * '''ts
121
+ * await client.connect();
122
+ * const user = await client.signInUserWithQrCode({ apiId, apiHash },
123
+ * {
124
+ * onError: async function(p1: Error) {
125
+ * console.log("error", p1);
126
+ * // true = stop the authentication processes
127
+ * return true;
128
+ * },
129
+ * qrCode: async (code) => {
130
+ * console.log("Convert the next string to a QR code and scan it");
131
+ * console.log(
132
+ * `tg://login?token=${code.token.toString("base64url")}`
133
+ * );
134
+ * },
135
+ * password: async (hint) => {
136
+ * // password if needed
137
+ * return "1111";
138
+ * }
139
+ * }
140
+ * );
141
+ * console.log("user is", user);
142
+ *
143
+ * '''
144
+ * @param apiCredentials - credentials to be used.
145
+ * @param authParams - user auth params.
146
+ */
147
+ signInUserWithQrCode(apiCredentials: authMethods.ApiCredentials, authParams: authMethods.QrCodeAuthParams): Promise<Api.TypeUser>;
148
+ /**
149
+ * Sends a telegram authentication code to the phone number.
150
+ * @example
151
+ * ```ts
152
+ * await client.connect();
153
+ * const {phoneCodeHash,isCodeViaApp} = await client.sendCode({
154
+ * apiId:1234,
155
+ * apiHash:"123456789abcfghj",
156
+ * },"+123456798"});
157
+ * ```
158
+ * @param apiCredentials - credentials to be used.
159
+ * @param phoneNumber - the phone number to send the code to
160
+ * @param forceSMS - whether to send it as an SMS or a normal in app message
161
+ * @return the phone code hash and whether it was sent via app
162
+ */
163
+ sendCode(apiCredentials: authMethods.ApiCredentials, phoneNumber: string, forceSMS?: boolean): Promise<{
164
+ phoneCodeHash: string;
165
+ isCodeViaApp: boolean;
166
+ }>;
167
+ /**
168
+ * Uses the 2FA password to sign in the account.<br/>
169
+ * This function should be used after the user has signed in with the code they received.
170
+ * @param apiCredentials - credentials to be used.
171
+ * @param authParams - user auth params.
172
+ * @returns the logged in user.
173
+ */
174
+ signInWithPassword(apiCredentials: authMethods.ApiCredentials, authParams: authMethods.UserPasswordAuthParams): Promise<Api.TypeUser>;
175
+ /**
176
+ * Used to sign in as a bot.
177
+ * @example
178
+ * ```ts
179
+ * await client.connect();
180
+ * const bot = await client.signInBot({
181
+ * apiId:1234,
182
+ * apiHash:"12345",
183
+ * },{
184
+ * botToken:"123456:abcdfghae4fg654",
185
+ * });
186
+ * // we are now logged in as a bot
187
+ * console.log("Logged in",bot);
188
+ * ```
189
+ * @param apiCredentials - credentials to be used.
190
+ * @param authParams - user auth params.
191
+ * @return instance User of the logged in bot.
192
+ */
193
+ signInBot(apiCredentials: authMethods.ApiCredentials, authParams: authMethods.BotAuthParams): Promise<Api.TypeUser>;
194
+ /**
195
+ * Changes the 2FA settings of the logged in user.
196
+ Note that this method may be *incredibly* slow depending on the
197
+ prime numbers that must be used during the process to make sure
198
+ that everything is safe.
199
+
200
+ Has no effect if both current and new password are omitted.
201
+
202
+ * @param client: The telegram client instance
203
+ * @param isCheckPassword: Must be ``true`` if you want to check the current password
204
+ * @param currentPassword: The current password, to authorize changing to ``new_password``.
205
+ Must be set if changing existing 2FA settings.
206
+ Must **not** be set if 2FA is currently disabled.
207
+ Passing this by itself will remove 2FA (if correct).
208
+ * @param newPassword: The password to set as 2FA.
209
+ If 2FA was already enabled, ``currentPassword`` **must** be set.
210
+ Leaving this blank or `undefined` will remove the password.
211
+ * @param hint: Hint to be displayed by Telegram when it asks for 2FA.
212
+ Must be set when changing or creating a new password.
213
+ Has no effect if ``newPassword`` is not set.
214
+ * @param email: Recovery and verification email. If present, you must also
215
+ set `emailCodeCallback`, else it raises an Error.
216
+ * @param emailCodeCallback: If an email is provided, a callback that returns the code sent
217
+ to it must also be set. This callback may be asynchronous.
218
+ It should return a string with the code. The length of the
219
+ code will be passed to the callback as an input parameter.
220
+ * @param onEmailCodeError: Called when an error happens while sending an email.
221
+
222
+ If the callback returns an invalid code, it will raise an rpc error with the message
223
+ ``CODE_INVALID``
224
+
225
+ * @returns Promise<void>
226
+ * @throws this method can throw:
227
+ "PASSWORD_HASH_INVALID" if you entered a wrong password (or set it to undefined).
228
+ "EMAIL_INVALID" if the entered email is wrong
229
+ "EMAIL_HASH_EXPIRED" if the user took too long to verify their email
230
+ */
231
+ updateTwoFaSettings({ isCheckPassword, currentPassword, newPassword, hint, email, emailCodeCallback, onEmailCodeError, }: twoFA.TwoFaParams): Promise<void>;
232
+ /**
233
+ * Makes an inline query to the specified bot and gets the result list.<br/>
234
+ * This is equivalent to writing `@pic something` in clients
235
+ * @param bot - the bot entity to which the inline query should be made
236
+ * @param query - the query string that should be made for that bot (up to 512 characters). can be empty
237
+ * @param entity - The entity where the inline query is being made from.<br/>
238
+ * Certain bots use this to display different results depending on where it's used, such as private chats, groups or channels.<br/>
239
+ * If specified, it will also be the default entity where the message will be sent after clicked.<br/>
240
+ * Otherwise, the “empty peer” will be used, which some bots may not handle correctly.
241
+ * @param offset - String offset of the results to be returned. can be empty
242
+ * @param geoPoint - The geo point location information to send to the bot for localised results. Available under some bots.
243
+ * @return a list of InlineResults
244
+ * @example
245
+ * ```ts
246
+ * // Makes the query to @pic
247
+ * const results = await client.inlineQuery("pic", "something");
248
+ * // clicks on the first result
249
+ * await results[0].click();
250
+ * ```
251
+ */
252
+ inlineQuery(bot: EntityLike, query: string, entity?: Api.InputPeerSelf, offset?: string, geoPoint?: Api.TypeInputGeoPoint): Promise<import("../tl/custom/inlineResults").InlineResults>;
253
+ /**
254
+ * Builds a ReplyInlineMarkup or ReplyKeyboardMarkup for the given buttons.<br/><br/>
255
+ * Does nothing if either no buttons are provided or the provided argument is already a reply markup.<br/><br/>
256
+ * this function is called internally when passing an array of buttons.
257
+
258
+ * @param buttons - The button, array of buttons, array of array of buttons or markup to convert into a markup.
259
+ * @param inlineOnly - Whether the buttons **must** be inline buttons only or not.
260
+ * @example
261
+ * ```ts
262
+ * import {Button} from "teleproto/tl/custom/button";
263
+ * // PS this function is not async
264
+ * const markup = client.buildReplyMarkup(Button.inline("Hello!"));
265
+ *
266
+ * await client.sendMessage(chat, {
267
+ * message: "click me!",
268
+ * buttons: markup,
269
+ * }
270
+ *
271
+ * // The following example can also be used in a simpler way like so
272
+ *
273
+ * await client.sendMessage(chat, {
274
+ * message: "click me!",
275
+ * buttons: [Button.inline("Hello!")],
276
+ * }
277
+ * ```
278
+ */
279
+ buildReplyMarkup(buttons: Api.TypeReplyMarkup | undefined | ButtonLike | ButtonLike[] | ButtonLike[][], inlineOnly?: boolean): Api.TypeReplyMarkup | undefined;
280
+ /**
281
+ * Low-level method to download files from their input location.
282
+ * downloadMedia should generally be used over this.
283
+ * @param inputLocation - The file location from which the file will be downloaded. See getInputLocation source for a complete list of supported types.
284
+ * @param fileParams - {@link DownloadFileParams}
285
+ * @return a Buffer downloaded from the inputFile.
286
+ * @example
287
+ * ```ts
288
+ * const photo = message.photo;
289
+ * const buffer = await client.downloadFile(
290
+ * new Api.InputPhotoFileLocation({
291
+ * id: photo.id,
292
+ * accessHash: photo.accessHash,
293
+ * fileReference: photo.fileReference,
294
+ * thumbSize: size.type
295
+ * }),
296
+ * {
297
+ * dcId: photo.dcId,
298
+ * fileSize: "m",
299
+ * }
300
+ * );
301
+ * ```
302
+ */
303
+ downloadFile(inputLocation: Api.TypeInputFileLocation, fileParams?: downloadMethods.DownloadFileParamsV2): Promise<string | Buffer<ArrayBufferLike> | undefined>;
304
+ /**
305
+ * Iterates over a file download, yielding chunks of the file.
306
+ * This method can be used to stream files in a more convenient way, since it offers more control (pausing, resuming, etc.)
307
+ * @param iterFileParams - {@link IterDownloadFunction}
308
+ * @return a Buffer downloaded from the inputFile.
309
+ * @example
310
+ * ```ts
311
+ * const photo = message.photo;
312
+ * for await (const chunk of client.iterDownload({
313
+ * file: new Api.InputPhotoFileLocation({
314
+ * id: photo.id,
315
+ * accessHash: photo.accessHash,
316
+ * fileReference: photo.fileReference,
317
+ * thumbSize: size.type
318
+ * }),
319
+ * offset: start,
320
+ * limit: end,
321
+ * requestSize:2048*1024
322
+ * )){
323
+ * console.log("Downloaded chunk of size",chunk.length);
324
+ * };
325
+ * ```
326
+ */
327
+ iterDownload(iterFileParams: downloadMethods.IterDownloadFunction): downloadMethods.DirectDownloadIter;
328
+ /**
329
+ * Downloads the profile photo from the given user,chat or channel.<br/>
330
+ * This method will return an empty buffer in case of no profile photo.
331
+ * @param entity - where to download the photo from.
332
+ * @param downloadProfilePhotoParams - {@link DownloadProfilePhotoParams}
333
+ * @return buffer containing the profile photo. can be empty in case of no profile photo.
334
+ * @example
335
+ * ```ts
336
+ * // Download your own profile photo
337
+ * const buffer = await client.downloadProfilePhoto('me')
338
+ * console.log("Downloaded image is",buffer);
339
+ * // if you want to save it as a file you can use the fs module on node for that.
340
+ * import { promises as fs } from 'fs';
341
+ * await fs.writeFile("picture.jpg",buffer);
342
+ * ```
343
+ */
344
+ downloadProfilePhoto(entity: EntityLike, downloadProfilePhotoParams?: downloadMethods.DownloadProfilePhotoParams): Promise<string | Buffer<ArrayBufferLike> | undefined>;
345
+ /**
346
+ * Downloads the given media from a message or a media object.<br/>
347
+ * this will return an empty Buffer in case of wrong or empty media.
348
+ * @param messageOrMedia - instance of a message or a media.
349
+ * @param downloadParams {@link DownloadMediaInterface}
350
+ * @return a buffer containing the downloaded data if outputFile is undefined else nothing.
351
+ * @example ```ts
352
+ * const buffer = await client.downloadMedia(message, {})
353
+ * // to save it to a file later on using fs.
354
+ * import { promises as fs } from 'fs';
355
+ * await fs.writeFile("file",buffer);
356
+ * // to use a progress callback you can pass it like so.
357
+ * const buffer = await client.downloadMedia(message, {
358
+ * progressCallback : console.log
359
+ * })
360
+ * ```
361
+ */
362
+ downloadMedia(messageOrMedia: Api.Message | Api.TypeMessageMedia, downloadParams?: DownloadMediaInterface): Promise<string | Buffer<ArrayBufferLike> | undefined>;
363
+ /**
364
+ * This property is the default parse mode used when sending messages. Defaults to {@link MarkdownParser}.<br/>
365
+ * It will always be either undefined or an object with parse and unparse methods.<br/>
366
+ * When setting a different value it should be one of:<br/>
367
+ *<br/>
368
+ * - Object with parse and unparse methods.<br/>
369
+ * - A str indicating the parse_mode. For Markdown 'md' or 'markdown' may be used. For HTML, 'html' may be used.<br/>
370
+ * The parse method should be a function accepting a single parameter, the text to parse, and returning a tuple consisting of (parsed message str, [MessageEntity instances]).<br/>
371
+ * <br/>
372
+ * The unparse method should be the inverse of parse such that text == unparse(parse(text)).<br/>
373
+ * <br/>
374
+ * See {@link Api.TypeMessageEntity} for allowed message entities.
375
+ * @example
376
+ * ```ts
377
+ * // gets the current parse mode.
378
+ * console.log("parse mode is :", client.parseMode)
379
+ * ```
380
+ */
381
+ get parseMode(): parseMethods.ParseInterface | undefined;
382
+ /** Setter for parseMode.
383
+ * {@link parseMode}
384
+ * @param mode can be md,markdown for Markdown or html for html. can also pass a custom mode.
385
+ * pass undefined for no parsing.
386
+ * @example
387
+ * // sets the mode to HTML
388
+ * client.setParseMode("html");
389
+ * await client.sendMessage("me",{message:"<u>This is an underline text</u>"});
390
+ * // disable formatting
391
+ * client.setParseMode(undefined);
392
+ * await client.sendMessage("me",{message:"<u> this will be sent as it is</u> ** with no formatting **});
393
+ */
394
+ setParseMode(mode: "md" | "md2" | "markdown" | "markdownv2" | "html" | parseMethods.ParseInterface | undefined): void;
395
+ /**
396
+ * Iterates over the messages for a given chat.
397
+ * <br/>
398
+ * The default order is from newest to oldest but can be changed with the reverse param.<br/>
399
+ * If either `search`, `filter` or `fromUser` are provided this will use {@link Api.messages.Search} instead of {@link Api.messages.GetHistory}.
400
+ * @remarks
401
+ * Telegram limits GetHistory requests every 10 requests (1 000 messages) therefore a sleep of 1 seconds will be the default for this limit.
402
+ * @param entity - The entity from whom to retrieve the message history.<br/>
403
+ * It may be undefined to perform a global search, or to get messages by their ID from no particular chat<br/>
404
+ * **Note** that some of the offsets will not work if this is the case.<br/>
405
+ * **Note** that if you want to perform a global search, you must set a non-empty search string, a filter. or fromUser.
406
+ * @param iterParams - {@link IterMessagesParams}
407
+ * @yield Instances of custom {@link Message}
408
+ * @example
409
+ * ```ts
410
+ * // From most-recent to oldest
411
+ * for await (const message of client.iterMessages(chat,{}){
412
+ * console.log(message.id, message.text)
413
+ * }
414
+ *
415
+ * // From oldest to most-recent
416
+ * for await (const message of client.iterMessages(chat,{reverse:true}){
417
+ * console.log(message.id, message.text)
418
+ * }
419
+ *
420
+ * // Filter by sender
421
+ * for await (const message of client.iterMessages(chat,{fromUser:"me"}){
422
+ * console.log(message.id, message.text)
423
+ * }
424
+ *
425
+ * // Server-side search with fuzzy text
426
+ * for await (const message of client.iterMessages(chat,{search:"hello"}){
427
+ * console.log(message.id, message.text)
428
+ * }
429
+ *
430
+ * // Filter by message type:
431
+ * import { Api } from "teleproto";
432
+ * for await (const message of client.iterMessages(chat,{filter: Api.InputMessagesFilterPhotos}){
433
+ * console.log(message.id, message.photo)
434
+ * }
435
+ *
436
+ * // Getting comments from a post in a channel:
437
+ * * for await (const message of client.iterMessages(chat,{replyTo: 123}){
438
+ * console.log(message.chat.title,, message.text)
439
+ * }
440
+ * ```
441
+ */
442
+ iterMessages(entity: EntityLike | undefined, iterParams?: Partial<messageMethods.IterMessagesParams>): messageMethods._MessagesIter | messageMethods._IDsIter;
443
+ /**
444
+ * Same as iterMessages() but returns a TotalList instead.<br/>
445
+ * if the `limit` is not set, it will be 1 by default unless both `minId` **and** `maxId` are set. in which case the entire range will be returned.<br/>
446
+ * @param entity - The entity from whom to retrieve the message history. see {@link iterMessages}.<br/>
447
+ * @param getMessagesParams - see {@link IterMessagesParams}.
448
+ * @return {@link TotalList} of messages.
449
+ * @example
450
+ * ```ts
451
+ * // The totalList has a .total attribute which will show the complete number of messages even if none are fetched.
452
+ * // Get 0 photos and print the total to show how many photos there are
453
+ * import { Api } from "teleproto";
454
+ * const photos = await client.getMessages(chat, {limit: 0, filter:Api.InputMessagesFilterPhotos})
455
+ * console.log(photos.total)
456
+ *
457
+ * // Get all the photos
458
+ * const photos = await client.getMessages(chat, {limit: undefined, filter:Api.InputMessagesFilterPhotos})
459
+ *
460
+ // Get messages by ID:
461
+ * const messages = await client.getMessages(chat, {ids:1337})
462
+ * const message_1337 = messages[0];
463
+ * ```
464
+ */
465
+ getMessages(entity: EntityLike | undefined, getMessagesParams?: Partial<messageMethods.IterMessagesParams>): Promise<import("../Helpers").TotalList<Api.Message>>;
466
+ /**
467
+ * Sends a message to the specified user, chat or channel.<br/>
468
+ * The default parse mode is the same as the official applications (a custom flavour of markdown). **bold**, `code` or __italic__ are available.<br/>
469
+ * In addition you can send [links](https://example.com) and [mentions](@username) (or using IDs like in the Bot API: [mention](tg://user?id=123456789)) and pre blocks with three backticks.<br/>
470
+ * <br/>
471
+ * Sending a /start command with a parameter (like ?start=data) is also done through this method. Simply send '/start data' to the bot.<br/>
472
+ * <br/>
473
+ * See also Message.respond() and Message.reply().
474
+ *
475
+ * @param entity - Who to sent the message to.
476
+ * @param sendMessageParams - see {@link SendMessageParams}
477
+ * @return
478
+ * The sent custom Message.
479
+ * @example
480
+ * ```ts
481
+ * // Markdown is the default.
482
+ * await client.sendMessage("me",{message:"Hello **world!**});
483
+ *
484
+ * // Defaults to another parse mode.
485
+ * client.setParseMode("HTML");
486
+ *
487
+ * await client.sendMessage('me', {message:'Some <b>bold</b> and <i>italic</i> text'})
488
+ * await client.sendMessage('me', {message:'An <a href="https://example.com">URL</a>'})
489
+ * await client.sendMessage('me', {message:'<a href="tg://user?id=me">Mentions</a>'})
490
+ *
491
+ * // Explicit parse mode.
492
+ * // No parse mode by default
493
+ * client.setParseMode(undefined);
494
+ * //...but here I want markdown
495
+ * await client.sendMessage('me', {message:'Hello, **world**!', {parseMode:"md"}})
496
+ *
497
+ * // ...and here I need HTML
498
+ * await client.sendMessage('me', {message:'Hello, <i>world</i>!', {parseMode='html'}})
499
+ *
500
+ *
501
+ * // Scheduling a message to be sent after 5 minutes
502
+ *
503
+ * await client.sendMessage(chat, {message:'Hi, future!', schedule:(60 * 5) + (Date.now() / 1000)})
504
+ *
505
+ * ```
506
+ */
507
+ sendMessage(entity: EntityLike, sendMessageParams?: messageMethods.SendMessageParams): Promise<Api.Message>;
508
+ /**
509
+ * Forwards the given messages to the specified entity.<br/>
510
+ *<br/>
511
+ * If you want to "forward" a message without the forward header
512
+ * (the "forwarded from" text), you should use `sendMessage` with
513
+ * the original message instead. This will send a copy of it.
514
+ *<br/>
515
+ * See also {@link Message.forwardTo}`.
516
+ * @param entity - To which entity the message(s) will be forwarded.
517
+ * @param forwardMessagesParams - see {@link ForwardMessagesParams}
518
+ * @return The list of forwarded Message, Note.<br/>
519
+ * if some messages failed to be forwarded the returned list will have them as undefined.
520
+ * @example ```ts
521
+ * // a single one
522
+ * await client.forwardMessages(chat, {messages: message});
523
+ * // or
524
+ * await client.forwardMessages(chat, {messages:messageId,fromPeer:fromChat});
525
+ * // or
526
+ * await message.forwardTo(chat)
527
+ *
528
+ * // multiple
529
+ * await client.forwardMessages(chat, {messages:messages});
530
+ * // or
531
+ * await client.forwardMessages(chat, {messages:messageIds,fromPeer:fromChat});
532
+ *
533
+ * // Forwarding as a copy
534
+ * await client.sendMessage(chat, {message:message});
535
+ * ```
536
+ */
537
+ forwardMessages(entity: EntityLike, forwardMessagesParams: messageMethods.ForwardMessagesParams): Promise<Api.Message[]>;
538
+ /**
539
+ * Used to edit a message by changing it's text or media
540
+ * message refers to the message to be edited not what to edit
541
+ * text refers to the new text
542
+ * See also Message.edit()<br/>
543
+ * Notes: It is not possible to edit the media of a message that doesn't contain media.
544
+ * @param entity - From which chat to edit the message.<br/>
545
+ * This can also be the message to be edited, and the entity will be inferred from it, so the next parameter will be assumed to be the message text.<br/>
546
+ * You may also pass a InputBotInlineMessageID, which is the only way to edit messages that were sent after the user selects an inline query result. Not supported yet!
547
+ * @param editMessageParams - see {@link EditMessageParams}.
548
+ * @return The edited Message.
549
+ * @throws
550
+ * `MESSAGE_AUTHOR_REQUIRED` if you're not the author of the message but tried editing it anyway.
551
+ * `MESSAGE_NOT_MODIFIED` if the contents of the message were not modified at all.
552
+ * `MESSAGE_ID_INVALID` if the ID of the message is invalid (the ID itself may be correct, but the message with that ID cannot be edited).<br/>
553
+ * For example, when trying to edit messages with a reply markup (or clear markup) this error will be raised.
554
+ * @example
555
+ * ```ts
556
+ * const message = await client.sendMessage(chat,{message:"Hi!"});
557
+ *
558
+ * await client.editMessage(chat,{message:message,text:"Hello!"}
559
+ * // or
560
+ * await client.editMessage(chat,{message:message.id,text:"Hello!"}
561
+ * ```
562
+ */
563
+ editMessage(entity: EntityLike, editMessageParams: messageMethods.EditMessageParams): Promise<Api.Message>;
564
+ /**
565
+ * Deletes the given messages, optionally "for everyone".
566
+ *
567
+ * See also {@link Message.delete}`.
568
+ *
569
+ * @remarks This method does **not** validate that the message IDs belong to the chat that you passed! It's possible for the method to delete messages from different private chats and small group chats at once, so make sure to pass the right IDs.
570
+ * @param entity - From who the message will be deleted. This can actually be `undefined` for normal chats, but **must** be present for channels and megagroups.
571
+ * @param messageIds - The IDs (or ID) or messages to be deleted.
572
+ * @param revoke - Whether the message should be deleted for everyone or not.
573
+ * By default it has the opposite behaviour of official clients,
574
+ * and it will delete the message for everyone.
575
+ * Disabling this has no effect on channels or megagroups,
576
+ * since it will unconditionally delete the message for everyone.
577
+ * @return
578
+ * A list of {@link AffectedMessages}, each item being the result for the delete calls of the messages in chunks of 100 each.
579
+ * @example
580
+ * ```ts
581
+ * await client.deleteMessages(chat, messages);
582
+ *
583
+ * await client.deleteMessages(chat, messages, {revoke:false});
584
+ * ```
585
+ */
586
+ deleteMessages(entity: EntityLike | undefined, messageIds: MessageIDLike[], { revoke }: {
587
+ revoke?: boolean | undefined;
588
+ }): Promise<Api.messages.AffectedMessages[]>;
589
+ /**
590
+ * Pins a message in a chat.
591
+ *
592
+ * See also {@link Message.pin}`.
593
+ *
594
+ * @remarks The default behavior is to **not** notify members, unlike the official applications.
595
+ * @param entity - The chat where the message should be pinned.
596
+ * @param message - The message or the message ID to pin. If it's `undefined`, all messages will be unpinned instead.
597
+ * @param pinMessageParams - see {@link UpdatePinMessageParams}.
598
+ * @return
599
+ * The pinned message. if message is undefined the return will be {@link AffectedHistory}
600
+ * @example
601
+ * ```ts
602
+ * const message = await client.sendMessage(chat, 'teleproto is awesome!');
603
+ *
604
+ * await client.pinMessage(chat, message);
605
+ * ```
606
+ */
607
+ pinMessage(entity: EntityLike, message?: undefined, pinMessageParams?: messageMethods.UpdatePinMessageParams): Promise<Api.messages.AffectedHistory>;
608
+ pinMessage(entity: EntityLike, message: MessageIDLike, pinMessageParams?: messageMethods.UpdatePinMessageParams): Promise<Api.Message>;
609
+ /**
610
+ * Unpins a message in a chat.
611
+ *
612
+ * See also {@link Message.unpin}`.
613
+ *
614
+ * @remarks The default behavior is to **not** notify members, unlike the official applications.
615
+ * @param entity - The chat where the message should be unpinned.
616
+ * @param message - The message or the message ID to unpin. If it's `undefined`, all messages will be unpinned instead.
617
+ * @param pinMessageParams - see {@link UpdatePinMessageParams}.
618
+ * @return
619
+ * The pinned message. if message is undefined the return will be {@link AffectedHistory}
620
+ * @example
621
+ * ```ts
622
+ * const message = await client.sendMessage(chat, 'teleproto is awesome!');
623
+ *
624
+ * // unpin one message
625
+ * await client.unpinMessage(chat, message);
626
+ *
627
+ * // unpin all messages
628
+ * await client.unpinMessage(chat);
629
+ * ```
630
+ */
631
+ unpinMessage(entity: EntityLike, message?: undefined, pinMessageParams?: messageMethods.UpdatePinMessageParams): Promise<Api.messages.AffectedHistory>;
632
+ unpinMessage(entity: EntityLike, message: MessageIDLike, pinMessageParams?: messageMethods.UpdatePinMessageParams): Promise<undefined>;
633
+ /**
634
+ * Marks messages as read and optionally clears mentions. <br/>
635
+ * This effectively marks a message as read (or more than one) in the given conversation. <br />
636
+ * If a message or maximum ID is provided, all the messages up to and
637
+ * including such ID will be marked as read (for all messages whose ID ≤ max_id).
638
+ *
639
+ * See also {@link Message.markRead}`.
640
+ *
641
+ * @remarks If neither message nor maximum ID are provided, all messages will be marked as read by assuming that `max_id = 0`.
642
+ * @param entity - The chat where the message should be pinned.
643
+ * @param message - The message or the message ID to pin. If it's `undefined`, all messages will be unpinned instead.
644
+ * @param markAsReadParams - see {@link MarkAsReadParams}.
645
+ * @return boolean
646
+ * @example
647
+ * ```ts
648
+ * // using a Message object
649
+ * const message = await client.sendMessage(chat, 'teleproto is awesome!');
650
+ * await client.markAsRead(chat, message)
651
+ * // ...or using the int ID of a Message
652
+ * await client.markAsRead(chat, message.id);
653
+ *
654
+ * // ...or passing a list of messages to mark as read
655
+ * await client.markAsRead(chat, messages)
656
+ * ```
657
+ */
658
+ markAsRead(entity: EntityLike, message?: MessageIDLike | MessageIDLike[], markAsReadParams?: messageMethods.MarkAsReadParams): Promise<boolean>;
659
+ /**
660
+ * Iterator over the dialogs (open conversations/subscribed channels) sequentially.<br/>
661
+ * The order is the same as the one seen in official applications. (dialogs that had recent messages come first)
662
+ * @param iterDialogsParams - see {@link IterDialogsParams}
663
+ * @yield instances of custom {@link Dialog}.
664
+ * @example
665
+ * ```ts
666
+ * // logs all dialog IDs and their title.
667
+ * for await (const dialog of client.iterDialogs({})){
668
+ * console.log(`${dialog.id}: ${dialog.title}`);
669
+ * }
670
+ * ```
671
+ */
672
+ iterDialogs(iterDialogsParams?: dialogMethods.IterDialogsParams): dialogMethods._DialogsIter;
673
+ /**
674
+ * Same as iterDialogs but returns a TotalList instead of an iterator.
675
+ * @param params - {@link IterDialogsParams}
676
+ * @example
677
+ * ```ts
678
+ * // Get all open conversation, print the title of the first
679
+ * const dialogs = await client.getDialogs({});
680
+ * const first = dialogs[0];
681
+ * console.log(first.title);
682
+ * <br/>
683
+ * // Use the dialog somewhere else
684
+ * await client.sendMessage(first, {message: "hi"});
685
+ * <br/>
686
+ * // Getting only non-archived dialogs (both equivalent)
687
+ * non_archived = await client.get_dialogs({folder:0})
688
+ * non_archived = await client.get_dialogs({archived:false})
689
+ * <br/>
690
+ * // Getting only archived dialogs (both equivalent)
691
+ * archived = await client.get_dialogs({folder:1})
692
+ * archived = await client.get_dialogs({archived:true})
693
+ * ```
694
+ */
695
+ getDialogs(params?: dialogMethods.IterDialogsParams): Promise<import("../Helpers").TotalList<import("../tl/custom/dialog").Dialog>>;
696
+ /**
697
+ * Iterates over the participants belonging to a specified chat , channel or supergroup.<br/>
698
+ * <br/>
699
+ * Channels can return a maximum of 200 users while supergroups can return up to 10 000.<br/>
700
+ * You must be an admin to retrieve users from a channel.<br/>
701
+ * @param entity - The entity from which to retrieve the participants list.
702
+ * @param params - {@link IterParticipantsParams}
703
+ * @remarks
704
+ * The filter ChannelParticipantsBanned will return restricted users. If you want banned users you should use ChannelParticipantsKicked instead.
705
+ * @yield The User objects returned by GetParticipants with an additional .participant attribute<br/>
706
+ * which is the matched ChannelParticipant type for channels/supergroup or ChatParticipants for normal chats.
707
+ * @example
708
+ * ```ts
709
+ * // logs all user IDs in a chat.
710
+ * for await (const user of client.iterParticipants(chat)){
711
+ * console.log("User id",user.id);
712
+ * }
713
+ *
714
+ * // Searches by name.
715
+ * for await (const user of client.iterParticipants(chat, {search: "name"})){
716
+ * console.log("Username is ",user.username); // Some users don't have a username so this can be undefined.
717
+ * }
718
+ *
719
+ * // Filter by admins.
720
+ * import { Api } from "teleproto";
721
+ *
722
+ * for await (const user of client.iterParticipants(chat, {filter: Api.ChannelParticipantsAdmins})){
723
+ * console.log("admin first name is ",user.firstName);
724
+ * }
725
+ * ```
726
+ */
727
+ iterParticipants(entity: EntityLike, params?: chatMethods.IterParticipantsParams): chatMethods._ParticipantsIter;
728
+ /**
729
+ * Exact same as iterParticipants but returns a TotalList instead.<br/>
730
+ * This can be used if you want to retrieve a list instead of iterating over the users.
731
+ * @param entity - entity to get users from.
732
+ * @param params - {@link IterParticipantsParams}.
733
+ * @return
734
+ */
735
+ getParticipants(entity: EntityLike, params?: chatMethods.IterParticipantsParams): Promise<import("../Helpers").TotalList<Api.User>>;
736
+ /**
737
+ * Kicks a user from a chat.
738
+ *
739
+ * Kicking yourself (`'me'`) will result in leaving the chat.
740
+ *
741
+ * @note
742
+ * Attempting to kick someone who was banned will remove their
743
+ * restrictions (and thus unbanning them), since kicking is just
744
+ * ban + unban.
745
+ *
746
+ * @example
747
+ * // Kick some user from some chat, and deleting the service message
748
+ * const msg = await client.kickParticipant(chat, user);
749
+ * await msg.delete();
750
+ *
751
+ * // Leaving chat
752
+ * await client.kickParticipant(chat, 'me');
753
+ */
754
+ kickParticipant(entity: EntityLike, participant: EntityLike): Promise<Api.TypeMessage | Map<number, Api.Message> | (Api.Message | undefined)[] | undefined>;
755
+ /** TODO */
756
+ on(event: any): (f: {
757
+ (event: any): void;
758
+ }) => (event: any) => void;
759
+ /**
760
+ * Registers a new event handler callback.<br/>
761
+ * <br/>
762
+ * The callback will be called when the specified event occurs.
763
+ * @param callback - The callable function accepting one parameter to be used.<br/>
764
+ * **Note** the event type passed in the callback will change depending on the eventBuilder.
765
+ * @param event -The event builder class or instance to be used,
766
+ * for example ``new events.NewMessage({});``.
767
+ * If left unspecified, {@link Raw} (the {@link Api.TypeUpdate} objects with no further processing) will be passed instead.<br>
768
+ *
769
+ * @example
770
+ *```ts
771
+ * import {TelegramClient} from "teleproto";
772
+ * import { NewMessage } from "teleproto/events";
773
+ * import { NewMessageEvent } from "teleproto/events";
774
+ * const client = new TelegramClient(new StringSession(''), apiId, apiHash, {});
775
+ *
776
+ * async function handler(event: NewMessageEvent) {
777
+ * ...
778
+ * }
779
+ * client.addEventHandler(handler, new NewMessage({}));
780
+ ```
781
+ */
782
+ addEventHandler(callback: {
783
+ (event: NewMessageEvent): void;
784
+ }, event: NewMessage): void;
785
+ addEventHandler(callback: {
786
+ (event: CallbackQueryEvent): void;
787
+ }, event: CallbackQuery): void;
788
+ addEventHandler(callback: {
789
+ (event: AlbumEvent): void;
790
+ }, event: Album): void;
791
+ addEventHandler(callback: {
792
+ (event: EditedMessageEvent): void;
793
+ }, event: EditedMessage): void;
794
+ addEventHandler(callback: {
795
+ (event: DeletedMessageEvent): void;
796
+ }, event: DeletedMessage): void;
797
+ addEventHandler(callback: {
798
+ (event: any): void;
799
+ }, event?: EventBuilder): void;
800
+ /**
801
+ * Inverse operation of addEventHandler().<br>
802
+ *
803
+ * @param callback - the callback function to be removed.
804
+ * @param event - the type of the event.
805
+ */
806
+ removeEventHandler(callback: CallableFunction, event: EventBuilder): void;
807
+ /**
808
+ * Lists all registered event handlers.
809
+ * @return pair of [eventBuilder,CallableFunction]
810
+ */
811
+ listEventHandlers(): [EventBuilder, CallableFunction][];
812
+ /**
813
+ * Uploads a file to Telegram's servers, without sending it.
814
+ * @remarks generally it's better to use {@link sendFile} instead.
815
+ * This method returns a handle (an instance of InputFile or InputFileBig, as required) which can be later used before it expires (they are usable during less than a day).<br/>
816
+ * Uploading a file will simply return a "handle" to the file stored remotely in the Telegram servers,
817
+ * which can be later used on. This will not upload the file to your own chat or any chat at all.
818
+ * This also can be used to update profile pictures
819
+ * @param fileParams see {@link UploadFileParams}
820
+ * @return {@link Api.InputFileBig} if the file size is larger than 10mb otherwise {@link Api.InputFile}
821
+ * @example
822
+ * ```ts
823
+ * import { CustomFile } from "teleproto/client/uploads";
824
+ * const toUpload = new CustomFile("photo.jpg", fs.statSync("../photo.jpg").size, "../photo.jpg");
825
+ * const file = await client.uploadFile({
826
+ * file: toUpload,
827
+ * workers: 1,
828
+ * });
829
+ * await client.invoke(new Api.photos.UploadProfilePhoto({
830
+ * file: file,
831
+ * }));
832
+ * ```
833
+ */
834
+ uploadFile(fileParams: uploadMethods.UploadFileParams): Promise<Api.InputFile | Api.InputFileBig>;
835
+ /**
836
+ * Sends message with the given file to the specified entity.
837
+ * This uses {@link uploadFile} internally so if you want more control over uploads you can use that.
838
+ * @param entity - who will receive the file.
839
+ * @param sendFileParams - see {@link SendFileInterface}
840
+ * @example
841
+ * ```
842
+ * // Normal files like photos
843
+ * await client.sendFile(chat, {file:'/my/photos/me.jpg', caption:"It's me!"})
844
+ * // or
845
+ * await client.sendMessage(chat, {message:"It's me!", file:'/my/photos/me.jpg'})
846
+ *
847
+ * Voice notes or round videos
848
+ * await client.sendFile(chat, {file: '/my/songs/song.mp3', voiceNote:True})
849
+ * await client.sendFile(chat, {file: '/my/videos/video.mp4', videoNote:True})
850
+ *
851
+ * // Custom thumbnails
852
+ * await client.sendFile(chat, {file:'/my/documents/doc.txt', thumb:'photo.jpg'})
853
+ *
854
+ * // Only documents
855
+ * await client.sendFile(chat, {file:'/my/photos/photo.png', forceDocument:True})
856
+ *
857
+ * //logging progress
858
+ * await client.sendFile(chat, {file: file, progressCallback=console.log})
859
+ *
860
+ * // Dices, including dart and other future emoji
861
+ * await client.sendFile(chat, {file:new Api.InputMediaDice("")})
862
+ * await client.sendFile(chat, {file:new Api.InputMediaDice("🎯")})
863
+ *
864
+ * // Contacts
865
+ * await client.sendFile(chat, {file: new Api.InputMediaContact({
866
+ * phoneNumber:'+1 123 456 789',
867
+ * firstName:'Example',
868
+ * lastName:'',
869
+ * vcard:''
870
+ * }))
871
+ * ```
872
+ */
873
+ sendFile(entity: EntityLike, sendFileParams: uploadMethods.SendFileInterface): Promise<Api.Message>;
874
+ /**
875
+ * invokes raw Telegram requests.<br/>
876
+ * This is a low level method that can be used to call manually any Telegram API method.<br/>
877
+ * Generally this should only be used when there isn't a friendly method that does what you need.<br/>
878
+ * All available requests and types are found under the `Api.` namespace.
879
+ * @param request - The request to send. this should be of type request.
880
+ * @param dcId - Optional dc id to use when sending.
881
+ * @return The response from Telegram.
882
+ * @example
883
+ * ```ts
884
+ * //
885
+ * const result = await client.invoke(new Api.account.CheckUsername({
886
+ * username: 'some string here'
887
+ * }));
888
+ * console.log("does this username exist?",result);
889
+ *
890
+ * ```
891
+ */
892
+ invoke<R extends Api.AnyRequest>(request: R, dcId?: number): Promise<R["__response"]>;
893
+ invokeWithSender<R extends Api.AnyRequest>(request: R, sender?: MTProtoSender): Promise<R["__response"]>;
894
+ /**
895
+ * Gets the current logged in {@link Api.User}.
896
+ * If the user has not logged in this will throw an error.
897
+ * @param inputPeer - Whether to return the input peer version {@link Api.InputPeerUser} or the whole user {@link Api.User}.
898
+ * @return Your own {@link Api.User}
899
+ * @example
900
+ * ```ts
901
+ * const me = await client.getMe();
902
+ * console.log("My username is",me.username);
903
+ * ```
904
+ */
905
+ getMe(inputPeer: true): Promise<Api.InputPeerUser>;
906
+ getMe(inputPeer?: false): Promise<Api.User>;
907
+ /**
908
+ * Return true if the signed-in user is a bot, false otherwise.
909
+ * @example
910
+ * ```ts
911
+ * if (await client.isBot()){
912
+ * console.log("I am a bot. PI is 3.14159265359);
913
+ * } else {
914
+ * console.log("I am a human. Pies are delicious);
915
+ * }
916
+ * ```
917
+ */
918
+ isBot(): Promise<boolean | undefined>;
919
+ /**
920
+ * Returns true if the user is authorized (logged in).
921
+ * @example
922
+ * if (await client.isUserAuthorized()){
923
+ * console.log("I am authorized. I can call functions and use requests");
924
+ * }else{
925
+ * console.log("I am not logged in. I need to sign in first before being able to call methods");
926
+ * }
927
+ */
928
+ isUserAuthorized(): Promise<boolean>;
929
+ /**
930
+ * Turns the given entity into a valid Telegram {@link Api.User}, {@link Api.Chat} or {@link Api.Channel}.<br/>
931
+ * You can also pass a list or iterable of entities, and they will be efficiently fetched from the network.
932
+ * @remarks Telegram does not allow to get user profile by integer id if current client had never "saw" it.
933
+ * @param entity - If a username is given, the username will be resolved making an API call every time.<br/>
934
+ * Resolving usernames is an expensive operation and will start hitting flood waits around 50 usernames in a short period of time.<br/>
935
+ * <br/>
936
+ * Similar limits apply to invite links, and you should use their ID instead.<br/>
937
+ * Using phone numbers (from people in your contact list), exact names, integer IDs or Peer rely on a getInputEntity first,<br/>
938
+ * which in turn needs the entity to be in cache, unless a InputPeer was passed.<br/>
939
+ * <br/>
940
+ * If the entity can't be found, ValueError will be raised.
941
+ * @return
942
+ * {@link Api.Chat},{@link Api.Chat} or {@link Api.Channel} corresponding to the input entity. A list will be returned if more than one was given.
943
+ * @example
944
+ * ```ts
945
+ * const me = await client.getEntity("me");
946
+ * console.log("My name is", utils.getDisplayName(me));
947
+ *
948
+ * const chat = await client.getInputEntity("username");
949
+ * for await (const message of client.iterMessages(chat)) {
950
+ * console.log("Message text is", message.text);
951
+ * }
952
+ *
953
+ * // Note that you could have used the username directly, but it's
954
+ * // good to use getInputEntity if you will reuse it a lot.
955
+ * ```
956
+ */
957
+ getEntity(entity: EntityLike): Promise<Entity>;
958
+ getEntity(entity: EntityLike[]): Promise<Entity[]>;
959
+ /**
960
+ * Turns the given entity into its input entity version.<br/>
961
+ * Almost all requests use this kind of InputPeer, so this is the most suitable call to make for those cases.<br/>
962
+ * **Generally you should let the library do its job** and don't worry about getting the input entity first, but if you're going to use an entity often, consider making the call.
963
+ * @param entity - If a username or invite link is given, the library will use the cache.<br/>
964
+ * This means that it's possible to be using a username that changed or an old invite link (this only happens if an invite link for a small group chat is used after it was upgraded to a mega-group).
965
+ *<br/>
966
+ * - If the username or ID from the invite link is not found in the cache, it will be fetched. The same rules apply to phone numbers ('+34 123456789') from people in your contact list.
967
+ *<br/>
968
+ * - If an exact name is given, it must be in the cache too. This is not reliable as different people can share the same name and which entity is returned is arbitrary,<br/>
969
+ * and should be used only for quick tests.
970
+ *<br/>
971
+ * - If a positive integer ID is given, the entity will be searched in cached users, chats or channels, without making any call.
972
+ *<br/>
973
+ * - If a negative integer ID is given, the entity will be searched exactly as either a chat (prefixed with -) or as a channel (prefixed with -100).
974
+ *<br/>
975
+ * - If a Peer is given, it will be searched exactly in the cache as either a user, chat or channel.
976
+ *<br/>
977
+ * - If the given object can be turned into an input entity directly, said operation will be done.
978
+ *<br/>
979
+ * -If the entity can't be found, this will throw an error.
980
+ * @return
981
+ * {@link Api.InputPeerUser} , {@link Api.InputPeerChat} , {@link Api.InputPeerChannel} or {@link Api.InputPeerSelf} if the parameter is "me" or "self"
982
+ * @example
983
+ * ```ts
984
+ * // If you're going to use "username" often in your code
985
+ * // (make a lot of calls), consider getting its input entity
986
+ * // once, and then using the "user" everywhere instead.
987
+ * user = await client.getInputEntity('username')
988
+ *
989
+ * // The same applies to IDs, chats or channels.
990
+ * chat = await client.getInputEntity(-123456789)
991
+ * ```
992
+ */
993
+ getInputEntity(entity: EntityLike): Promise<Api.TypeInputPeer>;
994
+ /**
995
+ * Gets the ID for the given entity.<br/>
996
+ * This method needs to be async because peer supports usernames, invite-links, phone numbers (from people in your contact list), etc.<br/>
997
+ * <br/>
998
+ * If addMark is false, then a positive ID will be returned instead. By default, bot-API style IDs (signed) are returned.
999
+ * @param peer
1000
+ * @param addMark - whether to return a bot api style id.
1001
+ * @return the ID of the entity.
1002
+ * @example
1003
+ * ```ts
1004
+ * console.log(await client.getPeerId("me"));
1005
+ * ```
1006
+ */
1007
+ getPeerId(peer: EntityLike, addMark?: boolean): Promise<string>;
1008
+ /** @hidden */
1009
+ _getInputDialog(peer: any): Promise<any>;
1010
+ /** @hidden */
1011
+ _getInputNotify(notify: any): Promise<any>;
1012
+ /** @hidden */
1013
+ _handleReconnect(): Promise<void>;
1014
+ connect(): Promise<boolean>;
1015
+ /** @hidden */
1016
+ _switchDC(newDc: number): Promise<boolean>;
1017
+ /**
1018
+ * Returns the DC ip in case of node or the DC web address in case of browser.<br/>
1019
+ * This will do an API request to fill the cache if it's the first time it's called.
1020
+ * @param dcId The DC ID.
1021
+ * @param downloadDC whether to use -1 DCs or not
1022
+ * @param web if true this will get the web DCs.
1023
+ * TODO, hardcode IPs.
1024
+ * (These only support downloading/uploading and not creating a new AUTH key)
1025
+ */
1026
+ getDC(dcId: number, downloadDC?: boolean, web?: boolean): Promise<{
1027
+ id: number;
1028
+ ipAddress: string;
1029
+ port: number;
1030
+ }>;
1031
+ /** @hidden */
1032
+ _removeSender(dcId: number): void;
1033
+ /** @hidden */
1034
+ _getResponseMessage(req: any, result: any, inputChat: any): Api.TypeMessage | Map<number, Api.Message> | (Api.Message | undefined)[] | undefined;
1035
+ /** @hidden */
1036
+ [inspect.custom](): {
1037
+ [key: string]: any;
1038
+ };
1039
+ /**
1040
+ * Small hack for using it in browsers
1041
+ */
1042
+ static get events(): any;
1043
+ }