teleproto 1.222.0 → 1.222.1

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 (110) hide show
  1. package/Helpers.js +4 -4
  2. package/LICENSE.txt +24 -24
  3. package/Password.js +2 -2
  4. package/README.md +138 -98
  5. package/Utils.d.ts +1 -1
  6. package/Version.d.ts +1 -1
  7. package/Version.js +1 -1
  8. package/client/TelegramClient.d.ts +2 -10
  9. package/client/TelegramClient.js +6 -16
  10. package/client/chats.d.ts +0 -4
  11. package/client/chats.js +0 -10
  12. package/client/downloads.js +3 -3
  13. package/client/messageParse.d.ts +1 -1
  14. package/client/messageParse.js +20 -20
  15. package/client/messages.d.ts +3 -3
  16. package/client/telegramBaseClient.d.ts +5 -18
  17. package/client/telegramBaseClient.js +5 -13
  18. package/client/uploads.d.ts +3 -3
  19. package/client/uploads.js +3 -3
  20. package/client/users.js +1 -1
  21. package/define.d.ts +77 -77
  22. package/entityCache.js +6 -6
  23. package/errors/Common.js +2 -2
  24. package/extensions/BinaryReader.js +2 -2
  25. package/extensions/PromisedNetSockets.js +2 -4
  26. package/extensions/index.d.ts +0 -1
  27. package/extensions/index.js +1 -3
  28. package/network/MTProtoSender.js +4 -4
  29. package/network/connection/Connection.d.ts +5 -7
  30. package/network/connection/Connection.js +2 -3
  31. package/network/connection/TCPAbridged.d.ts +2 -2
  32. package/network/connection/TCPFull.d.ts +3 -3
  33. package/network/connection/TCPFull.js +1 -1
  34. package/network/connection/TCPMTProxy.d.ts +3 -4
  35. package/network/connection/TCPMTProxy.js +1 -2
  36. package/package.json +34 -50
  37. package/sessions/StoreSession.js +2 -2
  38. package/tl/api.d.ts +1 -33951
  39. package/tl/api.js +4 -506
  40. package/tl/core/GZIPPacked.d.ts +1 -1
  41. package/tl/core/GZIPPacked.js +2 -2
  42. package/tl/custom/button.d.ts +0 -4
  43. package/tl/custom/button.js +0 -5
  44. package/tl/custom/chatGetter.d.ts +0 -4
  45. package/tl/custom/chatGetter.js +0 -4
  46. package/tl/custom/dialog.d.ts +0 -4
  47. package/tl/custom/dialog.js +0 -4
  48. package/tl/custom/draft.d.ts +0 -4
  49. package/tl/custom/draft.js +0 -5
  50. package/tl/custom/file.d.ts +0 -4
  51. package/tl/custom/file.js +0 -5
  52. package/tl/custom/forward.d.ts +0 -4
  53. package/tl/custom/forward.js +0 -4
  54. package/tl/custom/inlineResult.d.ts +0 -4
  55. package/tl/custom/inlineResult.js +0 -5
  56. package/tl/custom/inlineResults.d.ts +0 -4
  57. package/tl/custom/inlineResults.js +0 -5
  58. package/tl/custom/message.d.ts +1 -5
  59. package/tl/custom/message.js +0 -4
  60. package/tl/custom/messageButton.d.ts +1 -5
  61. package/tl/custom/messageButton.js +0 -5
  62. package/tl/custom/senderGetter.d.ts +0 -4
  63. package/tl/custom/senderGetter.js +0 -5
  64. package/tl/generated/api-definitions.d.ts +2 -0
  65. package/tl/generated/api-definitions.js +2 -0
  66. package/tl/generated/api.d.ts +33948 -0
  67. package/tl/generated/api.js +4 -0
  68. package/tl/index.d.ts +3 -2
  69. package/tl/index.js +10 -7
  70. package/tl/runtime/createApi.d.ts +23 -0
  71. package/tl/runtime/createApi.js +455 -0
  72. package/tl/runtime/helpers.d.ts +3 -0
  73. package/tl/runtime/helpers.js +53 -0
  74. package/tl/runtime/patches/messages.d.ts +1 -0
  75. package/tl/{patched/index.js → runtime/patches/messages.js} +26 -20
  76. package/tl/{AllTLObjects.d.ts → runtime/registry.d.ts} +1 -1
  77. package/tl/{AllTLObjects.js → runtime/registry.js} +2 -2
  78. package/CryptoFile.d.ts +0 -2
  79. package/CryptoFile.js +0 -37
  80. package/client/fs.d.ts +0 -1
  81. package/client/fs.js +0 -17
  82. package/client/os.d.ts +0 -2
  83. package/client/os.js +0 -37
  84. package/client/path.d.ts +0 -2
  85. package/client/path.js +0 -7
  86. package/extensions/PromisedWebSockets.d.ts +0 -18
  87. package/extensions/PromisedWebSockets.js +0 -124
  88. package/extensions/net.d.ts +0 -1
  89. package/extensions/net.js +0 -17
  90. package/extensions/socks.d.ts +0 -1
  91. package/extensions/socks.js +0 -17
  92. package/inspect.d.ts +0 -1
  93. package/inspect.js +0 -5
  94. package/sessions/localStorage.d.ts +0 -1
  95. package/sessions/localStorage.js +0 -4
  96. package/tl/MTProtoRequest.d.ts +0 -18
  97. package/tl/MTProtoRequest.js +0 -38
  98. package/tl/apiTl.d.ts +0 -2
  99. package/tl/apiTl.js +0 -2298
  100. package/tl/generateModule.d.ts +0 -1
  101. package/tl/generateModule.js +0 -17
  102. package/tl/generationHelpers.d.ts +0 -11
  103. package/tl/generationHelpers.js +0 -289
  104. package/tl/patched/index.d.ts +0 -2
  105. package/tl/schemaTl.d.ts +0 -2
  106. package/tl/schemaTl.js +0 -68
  107. package/tl/types-generator/generate.d.ts +0 -1
  108. package/tl/types-generator/generate.js +0 -84
  109. package/tl/types-generator/template.d.ts +0 -6
  110. package/tl/types-generator/template.js +0 -257
package/Helpers.js CHANGED
@@ -29,7 +29,7 @@ exports.bufferXor = bufferXor;
29
29
  exports.crc32 = crc32;
30
30
  exports._entityType = _entityType;
31
31
  const big_integer_1 = __importDefault(require("big-integer"));
32
- const CryptoFile_1 = __importDefault(require("./CryptoFile"));
32
+ const crypto_1 = __importDefault(require("crypto"));
33
33
  /**
34
34
  * converts a buffer to big int
35
35
  * @param buffer
@@ -185,7 +185,7 @@ function bigIntMod(n, m) {
185
185
  * @returns {Buffer}
186
186
  */
187
187
  function generateRandomBytes(count) {
188
- return Buffer.from(CryptoFile_1.default.randomBytes(count));
188
+ return Buffer.from(crypto_1.default.randomBytes(count));
189
189
  }
190
190
  /**
191
191
  * Calculate the key based on Telegram guidelines, specifying whether it's the client or not
@@ -291,7 +291,7 @@ function convertToLittle(buf) {
291
291
  * @returns {Promise}
292
292
  */
293
293
  function sha1(data) {
294
- const shaSum = CryptoFile_1.default.createHash("sha1");
294
+ const shaSum = crypto_1.default.createHash("sha1");
295
295
  shaSum.update(data);
296
296
  // @ts-ignore
297
297
  return shaSum.digest();
@@ -302,7 +302,7 @@ function sha1(data) {
302
302
  * @returns {Promise}
303
303
  */
304
304
  function sha256(data) {
305
- const shaSum = CryptoFile_1.default.createHash("sha256");
305
+ const shaSum = crypto_1.default.createHash("sha256");
306
306
  shaSum.update(data);
307
307
  // @ts-ignore
308
308
  return shaSum.digest();
package/LICENSE.txt CHANGED
@@ -1,25 +1,25 @@
1
- MIT License
2
-
3
- Copyright (c) 2025 sanyok12345. All rights reserved.
4
-
5
- This project, teleproto, is an independent work originally derived from GramJS.
6
- GramJS is an open source project licensed under the MIT License.
7
- Portions of teleproto are adapted from GramJS and remain subject to the MIT terms.
8
-
9
- Permission is hereby granted, free of charge, to any person obtaining a copy
10
- of this software and associated documentation files (the "Software"), to deal
11
- in the Software without restriction, including without limitation the rights
12
- to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
13
- copies of the Software, and to permit persons to whom the Software is
14
- furnished to do so, subject to the following conditions:
15
-
16
- The above copyright notice and this permission notice shall be included in all
17
- copies or substantial portions of the Software.
18
-
19
- THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
20
- IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
21
- FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
22
- AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
23
- LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
24
- OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
1
+ MIT License
2
+
3
+ Copyright (c) 2025 sanyok12345. All rights reserved.
4
+
5
+ This project, teleproto, is an independent work originally derived from GramJS.
6
+ GramJS is an open source project licensed under the MIT License.
7
+ Portions of teleproto are adapted from GramJS and remain subject to the MIT terms.
8
+
9
+ Permission is hereby granted, free of charge, to any person obtaining a copy
10
+ of this software and associated documentation files (the "Software"), to deal
11
+ in the Software without restriction, including without limitation the rights
12
+ to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
13
+ copies of the Software, and to permit persons to whom the Software is
14
+ furnished to do so, subject to the following conditions:
15
+
16
+ The above copyright notice and this permission notice shall be included in all
17
+ copies or substantial portions of the Software.
18
+
19
+ THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
20
+ IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
21
+ FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
22
+ AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
23
+ LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
24
+ OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
25
25
  SOFTWARE.
package/Password.js CHANGED
@@ -8,7 +8,7 @@ exports.computeDigest = computeDigest;
8
8
  const tl_1 = require("./tl");
9
9
  const Helpers_1 = require("./Helpers");
10
10
  const big_integer_1 = __importDefault(require("big-integer"));
11
- const CryptoFile_1 = __importDefault(require("./CryptoFile"));
11
+ const crypto_1 = __importDefault(require("crypto"));
12
12
  const SIZE_FOR_HASH = 256;
13
13
  /**
14
14
  *
@@ -154,7 +154,7 @@ function xor(a, b) {
154
154
  * @returns {*}
155
155
  */
156
156
  function pbkdf2sha512(password, salt, iterations) {
157
- return CryptoFile_1.default.pbkdf2Sync(password, salt, iterations, 64, "sha512");
157
+ return crypto_1.default.pbkdf2Sync(password, salt, iterations, 64, "sha512");
158
158
  }
159
159
  /**
160
160
  *
package/README.md CHANGED
@@ -1,98 +1,138 @@
1
- # teleproto
2
-
3
- A modern Telegram client library written in TypeScript for Node.js, forked from [GramJS](https://github.com/gram-js/gramjs) with performance and size improvements.
4
-
5
- ## Quick Start
6
-
7
- Here's how to get started with teleproto:
8
-
9
- ### Installation
10
-
11
- ```bash
12
- $ npm i teleproto
13
- ```
14
-
15
- ### Authentication Setup
16
-
17
- 1. Login to your [Telegram account](https://my.telegram.org/)
18
- 2. Click "API development tools" and create an application
19
- 3. Save your API ID and hash (never share these with anyone)
20
-
21
- ### Basic Usage
22
-
23
- ```javascript
24
- import { TelegramClient } from "teleproto";
25
- import { StringSession } from "teleproto/sessions";
26
- import readline from "readline";
27
-
28
- const apiId = 123456; // Replace with your API ID
29
- const apiHash = "123456abcdefg"; // Replace with your API Hash
30
- const stringSession = new StringSession(""); // Save the string session for later use
31
-
32
- const rl = readline.createInterface({
33
- input: process.stdin,
34
- output: process.stdout,
35
- });
36
-
37
- async function main() {
38
- console.log("Starting teleproto client...");
39
- const client = new TelegramClient(stringSession, apiId, apiHash, {
40
- connectionRetries: 5,
41
- });
42
-
43
- await client.start({
44
- phoneNumber: async () =>
45
- await new Promise(resolve => rl.question("Phone number: ", resolve)),
46
- password: async () =>
47
- await new Promise(resolve => rl.question("Password: ", resolve)),
48
- phoneCode: async () =>
49
- await new Promise(resolve => rl.question("Verification code: ", resolve)),
50
- onError: (err) => console.error(err),
51
- });
52
-
53
- console.log("Connected successfully!");
54
- console.log("Session string:", client.session.save()); // Save this to avoid login next time
55
-
56
- // Send a message to yourself
57
- await client.sendMessage("me", { message: "Hello from teleproto!" });
58
-
59
- // Disconnect when done
60
- await client.disconnect();
61
- rl.close();
62
- }
63
-
64
- main();
65
- ```
66
-
67
- You can also use `StoreSession` to save auth data to a folder instead of a string:
68
-
69
- ```javascript
70
- import { StoreSession } from "teleproto/sessions";
71
- const storeSession = new StoreSession("session_folder");
72
- const client = new TelegramClient(storeSession, apiId, apiHash, {});
73
- ```
74
-
75
- ## API Usage
76
-
77
- ### Calling Raw API Methods
78
-
79
- ```javascript
80
- await client.invoke(new Api.RequestClass({ param1: "value1" }));
81
- ```
82
-
83
- ### Event Handling
84
-
85
- ```javascript
86
- import { NewMessage } from "teleproto/events";
87
-
88
- client.addEventHandler(async (event) => {
89
- console.log("New message received:", event.message.text);
90
-
91
- if (event.message.text === "Hello") {
92
- await event.message.reply("Hi there!");
93
- }
94
- }, new NewMessage({}));
95
- ```
96
-
97
- # Ask a question
98
- If you have any questions or need help, feel free to join our [Telegram group](https://t.me/TeleprotoChat) or open an issue on GitHub
1
+ # teleproto
2
+
3
+ <p align="center">
4
+ <img src="https://img.shields.io/npm/v/teleproto" alt="npm version">
5
+ <img src="https://img.shields.io/badge/node-%3E%3D18.0.0-brightgreen" alt="node version">
6
+ <img src="https://img.shields.io/badge/language-TypeScript-3178c6" alt="typescript">
7
+ <img src="https://img.shields.io/badge/license-MIT-blue" alt="license">
8
+ </p>
9
+
10
+ Modern Telegram MTProto client for Node.js, written in TypeScript.
11
+ `teleproto` is a high-performance fork of GramJS focused on clean API ergonomics, runtime reliability, and up-to-date Telegram layers.
12
+
13
+ ## Features
14
+
15
+ - **MTProto-first**: Full Telegram API access through high-level client methods and raw `Api` calls.
16
+ - **TypeScript-friendly**: Strong typings across client methods, events, sessions, and TL objects.
17
+ - **Session options**: Use `StringSession` for portability or `StoreSession` for local persistence.
18
+ - **Event system**: Handle updates with builders like `NewMessage`, `EditedMessage`, `CallbackQuery`, and more.
19
+ - **Examples included**: Ready-to-run scripts in `teleproto_examples`.
20
+
21
+ ## Installation
22
+
23
+ ```bash
24
+ npm i teleproto
25
+ ```
26
+
27
+ ## Quick Start
28
+
29
+ 1. Open https://my.telegram.org
30
+ 2. Create an app in **API development tools**
31
+ 3. Copy your `api_id` and `api_hash`
32
+
33
+ ```ts
34
+ import { TelegramClient } from "teleproto";
35
+ import { StringSession } from "teleproto/sessions";
36
+ import readline from "readline";
37
+
38
+ const apiId = 123456;
39
+ const apiHash = "0123456789abcdef0123456789abcdef";
40
+ const session = new StringSession("");
41
+
42
+ const rl = readline.createInterface({
43
+ input: process.stdin,
44
+ output: process.stdout,
45
+ });
46
+
47
+ const ask = (q: string) =>
48
+ new Promise<string>((resolve) => rl.question(q, resolve));
49
+
50
+ async function main() {
51
+ const client = new TelegramClient(session, apiId, apiHash, {
52
+ connectionRetries: 5,
53
+ });
54
+
55
+ await client.start({
56
+ phoneNumber: async () => await ask("Phone number: "),
57
+ password: async () => await ask("2FA password (if enabled): "),
58
+ phoneCode: async () => await ask("Code from Telegram: "),
59
+ onError: (err) => console.error(err),
60
+ });
61
+
62
+ console.log("Connected as:", (await client.getMe())?.username || "unknown");
63
+ console.log("String session:\n", client.session.save());
64
+
65
+ await client.sendMessage("me", { message: "Hello from teleproto!" });
66
+ await client.disconnect();
67
+ rl.close();
68
+ }
69
+
70
+ main().catch(console.error);
71
+ ```
72
+
73
+ ## Sessions
74
+
75
+ Use `StringSession` when you want to store auth as a single string:
76
+
77
+ ```ts
78
+ import { StringSession } from "teleproto/sessions";
79
+ const session = new StringSession("");
80
+ ```
81
+
82
+ Use `StoreSession` when you want local folder-based persistence:
83
+
84
+ ```ts
85
+ import { StoreSession } from "teleproto/sessions";
86
+ const session = new StoreSession("teleproto_session");
87
+ ```
88
+
89
+ ## Events
90
+
91
+ ```ts
92
+ import { NewMessage } from "teleproto/events";
93
+
94
+ client.addEventHandler(
95
+ async (event) => {
96
+ const text = event.message.message || "";
97
+ if (/^hello$/i.test(text.trim())) {
98
+ await event.message.reply({ message: "Hi there!" });
99
+ }
100
+ },
101
+ new NewMessage({})
102
+ );
103
+ ```
104
+
105
+ ## Raw API
106
+
107
+ ```ts
108
+ import { Api } from "teleproto";
109
+
110
+ const result = await client.invoke(
111
+ new Api.help.GetConfig()
112
+ );
113
+ console.log(result);
114
+ ```
115
+
116
+ ## Examples
117
+
118
+ Practical scripts are available in `teleproto_examples`:
119
+
120
+ - `print_updates.ts`
121
+ - `print_messages.ts`
122
+ - `replier.ts`
123
+ - `interactive_terminal.ts`
124
+
125
+ Run any example from the project root:
126
+
127
+ ```bash
128
+ npx ts-node --transpile-only teleproto_examples/print_updates.ts
129
+ ```
130
+
131
+ ## Community
132
+
133
+ - Telegram chat: https://t.me/TeleprotoChat
134
+ - Issues: https://github.com/sanyok12345/teleproto/issues
135
+
136
+ ## License
137
+
138
+ MIT
package/Utils.d.ts CHANGED
@@ -149,7 +149,7 @@ export declare function getInputMedia(media: any, { isPhoto, attributes, forceDo
149
149
  * @param fileSize
150
150
  * @returns {Number}
151
151
  */
152
- export declare function getAppropriatedPartSize(fileSize: bigInt.BigInteger): 128 | 256 | 512;
152
+ export declare function getAppropriatedPartSize(fileSize: bigInt.BigInteger): 256 | 512 | 128;
153
153
  export declare function getPeer(peer: EntityLike | any): any;
154
154
  export declare function sanitizeParseMode(mode: string | ParseInterface): ParseInterface;
155
155
  /**
package/Version.d.ts CHANGED
@@ -1 +1 @@
1
- export declare const version = "1.222.0";
1
+ export declare const version = "1.222.1";
package/Version.js CHANGED
@@ -1,4 +1,4 @@
1
1
  "use strict";
2
2
  Object.defineProperty(exports, "__esModule", { value: true });
3
3
  exports.version = void 0;
4
- exports.version = "1.222.0";
4
+ exports.version = "1.222.1";
@@ -18,7 +18,6 @@ import { Album, AlbumEvent } from "../events/Album";
18
18
  import { CallbackQuery, CallbackQueryEvent } from "../events/CallbackQuery";
19
19
  import { EditedMessage, EditedMessageEvent } from "../events/EditedMessage";
20
20
  import { DeletedMessage, DeletedMessageEvent } from "../events/DeletedMessage";
21
- import { inspect } from "../inspect";
22
21
  /**
23
22
  * The TelegramClient uses several methods in different files to provide all the common functionality in a nice interface.</br>
24
23
  * **In short, to create a client you must do:**
@@ -1078,15 +1077,14 @@ export declare class TelegramClient extends TelegramBaseClient {
1078
1077
  /** @hidden */
1079
1078
  _switchDC(newDc: number): Promise<boolean>;
1080
1079
  /**
1081
- * Returns the DC ip in case of node or the DC web address in case of browser.<br/>
1080
+ * Returns the DC IP address.<br/>
1082
1081
  * This will do an API request to fill the cache if it's the first time it's called.
1083
1082
  * @param dcId The DC ID.
1084
1083
  * @param downloadDC whether to use -1 DCs or not
1085
- * @param web if true this will get the web DCs.
1086
1084
  * TODO, hardcode IPs.
1087
1085
  * (These only support downloading/uploading and not creating a new AUTH key)
1088
1086
  */
1089
- getDC(dcId: number, downloadDC?: boolean, web?: boolean): Promise<{
1087
+ getDC(dcId: number, downloadDC?: boolean): Promise<{
1090
1088
  id: number;
1091
1089
  ipAddress: string;
1092
1090
  port: number;
@@ -1096,11 +1094,5 @@ export declare class TelegramClient extends TelegramBaseClient {
1096
1094
  /** @hidden */
1097
1095
  _getResponseMessage(req: any, result: any, inputChat: any): Api.TypeMessage | Map<number, Api.Message> | (Api.Message | undefined)[] | undefined;
1098
1096
  /** @hidden */
1099
- [inspect.custom](): {
1100
- [key: string]: any;
1101
- };
1102
- /**
1103
- * Small hack for using it in browsers
1104
- */
1105
1097
  static get events(): any;
1106
1098
  }
@@ -50,11 +50,9 @@ const twoFA = __importStar(require("./2fa"));
50
50
  const tl_1 = require("../tl");
51
51
  const Utils_1 = require("../Utils");
52
52
  const network_1 = require("../network");
53
- const AllTLObjects_1 = require("../tl/AllTLObjects");
54
- const Helpers_1 = require("../Helpers");
53
+ const registry_1 = require("../tl/runtime/registry");
55
54
  const updates_1 = require("./updates");
56
55
  const Logger_1 = require("../extensions/Logger");
57
- const inspect_1 = require("../inspect");
58
56
  /**
59
57
  * The TelegramClient uses several methods in different files to provide all the common functionality in a nice interface.</br>
60
58
  * **In short, to create a client you must do:**
@@ -1167,12 +1165,11 @@ class TelegramClient extends telegramBaseClient_1.TelegramBaseClient {
1167
1165
  }
1168
1166
  const connection = new this._connection({
1169
1167
  ip: this.session.serverAddress,
1170
- port: this.useWSS ? 443 : 80,
1168
+ port: this.session.port || 80,
1171
1169
  dcId: this.session.dcId,
1172
1170
  loggers: this._log,
1173
1171
  proxy: this._proxy,
1174
1172
  socket: this.networkSocket,
1175
- testServers: this.testServers,
1176
1173
  });
1177
1174
  if (!(await this._sender.connect(connection, false))) {
1178
1175
  if (!this._loopStarted) {
@@ -1184,9 +1181,9 @@ class TelegramClient extends telegramBaseClient_1.TelegramBaseClient {
1184
1181
  this.session.setAuthKey(this._sender.authKey);
1185
1182
  this.session.save();
1186
1183
  this._initRequest.query = new tl_1.Api.help.GetConfig();
1187
- this._log.info(`Using LAYER ${AllTLObjects_1.LAYER} for initial connect`);
1184
+ this._log.info(`Using LAYER ${registry_1.LAYER} for initial connect`);
1188
1185
  await this._sender.send(new tl_1.Api.InvokeWithLayer({
1189
- layer: AllTLObjects_1.LAYER,
1186
+ layer: registry_1.LAYER,
1190
1187
  query: this._initRequest,
1191
1188
  }));
1192
1189
  if (!this._loopStarted) {
@@ -1215,15 +1212,14 @@ class TelegramClient extends telegramBaseClient_1.TelegramBaseClient {
1215
1212
  return await this.connect();
1216
1213
  }
1217
1214
  /**
1218
- * Returns the DC ip in case of node or the DC web address in case of browser.<br/>
1215
+ * Returns the DC IP address.<br/>
1219
1216
  * This will do an API request to fill the cache if it's the first time it's called.
1220
1217
  * @param dcId The DC ID.
1221
1218
  * @param downloadDC whether to use -1 DCs or not
1222
- * @param web if true this will get the web DCs.
1223
1219
  * TODO, hardcode IPs.
1224
1220
  * (These only support downloading/uploading and not creating a new AUTH key)
1225
1221
  */
1226
- async getDC(dcId, downloadDC = false, web = false) {
1222
+ async getDC(dcId, downloadDC = false) {
1227
1223
  this._log.debug(`Getting DC ${dcId}`);
1228
1224
  if (!this._config) {
1229
1225
  this._config = await this.invoke(new tl_1.Api.help.GetConfig());
@@ -1248,12 +1244,6 @@ class TelegramClient extends telegramBaseClient_1.TelegramBaseClient {
1248
1244
  return parseMethods._getResponseMessage(this, req, result, inputChat);
1249
1245
  }
1250
1246
  /** @hidden */
1251
- [inspect_1.inspect.custom]() {
1252
- return (0, Helpers_1.betterConsoleLog)(this);
1253
- }
1254
- /**
1255
- * Small hack for using it in browsers
1256
- */
1257
1247
  static get events() {
1258
1248
  return require("../events");
1259
1249
  }
package/client/chats.d.ts CHANGED
@@ -3,7 +3,6 @@ import type { EntityLike } from "../define";
3
3
  import { TotalList } from "../Helpers";
4
4
  import { RequestIter } from "../requestIter";
5
5
  import { Api } from "../tl";
6
- import { inspect } from "../inspect";
7
6
  interface ParticipantsIterInterface {
8
7
  entity: EntityLike;
9
8
  filter: any;
@@ -14,9 +13,6 @@ interface ParticipantsIterInterface {
14
13
  export declare class _ParticipantsIter extends RequestIter {
15
14
  private filterEntity;
16
15
  private requests?;
17
- [inspect.custom](): {
18
- [key: string]: any;
19
- };
20
16
  _init({ entity, filter, offset, search, showTotal, }: ParticipantsIterInterface): Promise<boolean | void>;
21
17
  _loadNextChunk(): Promise<boolean | undefined>;
22
18
  [Symbol.asyncIterator](): AsyncIterator<Api.User, any, undefined>;
package/client/chats.js CHANGED
@@ -12,15 +12,11 @@ const requestIter_1 = require("../requestIter");
12
12
  const __1 = require("..");
13
13
  const tl_1 = require("../tl");
14
14
  const big_integer_1 = __importDefault(require("big-integer"));
15
- const inspect_1 = require("../inspect");
16
15
  const Utils_1 = require("../Utils");
17
16
  const _MAX_PARTICIPANTS_CHUNK_SIZE = 200;
18
17
  const _MAX_ADMIN_LOG_CHUNK_SIZE = 100;
19
18
  const _MAX_PROFILE_PHOTO_CHUNK_SIZE = 100;
20
19
  class _ChatAction {
21
- [inspect_1.inspect.custom]() {
22
- return (0, Helpers_1.betterConsoleLog)(this);
23
- }
24
20
  constructor(client, chat, action, params = {
25
21
  delay: 4,
26
22
  autoCancel: true,
@@ -85,9 +81,6 @@ _ChatAction._str_mapping = {
85
81
  cancel: new tl_1.Api.SendMessageCancelAction(),
86
82
  };
87
83
  class _ParticipantsIter extends requestIter_1.RequestIter {
88
- [inspect_1.inspect.custom]() {
89
- return (0, Helpers_1.betterConsoleLog)(this);
90
- }
91
84
  async _init({ entity, filter, offset, search, showTotal, }) {
92
85
  var _a, _b;
93
86
  if (!offset) {
@@ -238,9 +231,6 @@ class _ParticipantsIter extends requestIter_1.RequestIter {
238
231
  }
239
232
  exports._ParticipantsIter = _ParticipantsIter;
240
233
  class _AdminLogIter extends requestIter_1.RequestIter {
241
- [inspect_1.inspect.custom]() {
242
- return (0, Helpers_1.betterConsoleLog)(this);
243
- }
244
234
  async _init(entity, searchArgs, filterArgs) {
245
235
  let eventsFilter = undefined;
246
236
  if (filterArgs &&
@@ -59,10 +59,10 @@ const Helpers_1 = require("../Helpers");
59
59
  const __1 = require("..");
60
60
  const requestIter_1 = require("../requestIter");
61
61
  const errors_1 = require("../errors");
62
- const fs_1 = require("./fs");
62
+ const fs_1 = require("fs");
63
63
  const extensions_1 = require("../extensions");
64
- const fs = __importStar(require("./fs"));
65
- const path_1 = __importDefault(require("./path"));
64
+ const fs = __importStar(require("fs"));
65
+ const path_1 = __importDefault(require("path"));
66
66
  const big_integer_1 = __importDefault(require("big-integer"));
67
67
  // All types
68
68
  const sizeTypes = ["w", "y", "d", "x", "c", "m", "b", "a", "s"];
@@ -1,4 +1,4 @@
1
- import { Api } from "../tl/api";
1
+ import { Api } from "../tl";
2
2
  import type { EntityLike } from "../define";
3
3
  import type { TelegramClient } from "./TelegramClient";
4
4
  export type messageEntities = typeof Api.MessageEntityBold | typeof Api.MessageEntityItalic | typeof Api.MessageEntityStrike | typeof Api.MessageEntityCode | typeof Api.MessageEntityPre;
@@ -8,21 +8,21 @@ exports._replaceWithMention = _replaceWithMention;
8
8
  exports._parseMessageText = _parseMessageText;
9
9
  exports._getResponseMessage = _getResponseMessage;
10
10
  const Utils_1 = require("../Utils");
11
- const api_1 = require("../tl/api");
11
+ const tl_1 = require("../tl");
12
12
  const index_1 = require("../index");
13
13
  const Helpers_1 = require("../Helpers");
14
14
  const big_integer_1 = __importDefault(require("big-integer"));
15
15
  exports.DEFAULT_DELIMITERS = {
16
- "**": api_1.Api.MessageEntityBold,
17
- __: api_1.Api.MessageEntityItalic,
18
- "~~": api_1.Api.MessageEntityStrike,
19
- "`": api_1.Api.MessageEntityCode,
20
- "```": api_1.Api.MessageEntityPre,
16
+ "**": tl_1.Api.MessageEntityBold,
17
+ __: tl_1.Api.MessageEntityItalic,
18
+ "~~": tl_1.Api.MessageEntityStrike,
19
+ "`": tl_1.Api.MessageEntityCode,
20
+ "```": tl_1.Api.MessageEntityPre,
21
21
  };
22
22
  /** @hidden */
23
23
  async function _replaceWithMention(client, entities, i, user) {
24
24
  try {
25
- entities[i] = new api_1.Api.InputMessageEntityMentionName({
25
+ entities[i] = new tl_1.Api.InputMessageEntityMentionName({
26
26
  offset: entities[i].offset,
27
27
  length: entities[i].length,
28
28
  userId: (await client.getInputEntity(user)),
@@ -50,7 +50,7 @@ async function _parseMessageText(client, message, parseMode) {
50
50
  const [rawMessage, msgEntities] = parseMode.parse(message);
51
51
  for (let i = msgEntities.length - 1; i >= 0; i--) {
52
52
  const e = msgEntities[i];
53
- if (e instanceof api_1.Api.MessageEntityTextUrl) {
53
+ if (e instanceof tl_1.Api.MessageEntityTextUrl) {
54
54
  const m = /^@|\+|tg:\/\/user\?id=(\d+)/.exec(e.url);
55
55
  if (m) {
56
56
  const userIdOrUsername = m[1] ? Number(m[1]) : e.url;
@@ -67,11 +67,11 @@ async function _parseMessageText(client, message, parseMode) {
67
67
  function _getResponseMessage(client, request, result, inputChat) {
68
68
  let updates = [];
69
69
  let entities = new Map();
70
- if (result instanceof api_1.Api.UpdateShort) {
70
+ if (result instanceof tl_1.Api.UpdateShort) {
71
71
  updates = [result.update];
72
72
  }
73
- else if (result instanceof api_1.Api.Updates ||
74
- result instanceof api_1.Api.UpdatesCombined) {
73
+ else if (result instanceof tl_1.Api.Updates ||
74
+ result instanceof tl_1.Api.UpdatesCombined) {
75
75
  updates = result.updates;
76
76
  for (const x of [...result.users, ...result.chats]) {
77
77
  entities.set(index_1.utils.getPeerId(x), x);
@@ -84,11 +84,11 @@ function _getResponseMessage(client, request, result, inputChat) {
84
84
  const idToMessage = new Map();
85
85
  let schedMessage;
86
86
  for (const update of updates) {
87
- if (update instanceof api_1.Api.UpdateMessageID) {
87
+ if (update instanceof tl_1.Api.UpdateMessageID) {
88
88
  randomToId.set(update.randomId.toString(), update.id);
89
89
  }
90
- else if (update instanceof api_1.Api.UpdateNewChannelMessage ||
91
- update instanceof api_1.Api.UpdateNewMessage) {
90
+ else if (update instanceof tl_1.Api.UpdateNewChannelMessage ||
91
+ update instanceof tl_1.Api.UpdateNewMessage) {
92
92
  update.message._finishInit(client, entities, inputChat);
93
93
  if ("randomId" in request || (0, Helpers_1.isArrayLike)(request)) {
94
94
  idToMessage.set(update.message.id, update.message);
@@ -97,7 +97,7 @@ function _getResponseMessage(client, request, result, inputChat) {
97
97
  return update.message;
98
98
  }
99
99
  }
100
- else if (update instanceof api_1.Api.UpdateEditMessage &&
100
+ else if (update instanceof tl_1.Api.UpdateEditMessage &&
101
101
  "peer" in request &&
102
102
  (0, Helpers_1._entityType)(request.peer) != Helpers_1._EntityType.CHANNEL) {
103
103
  update.message._finishInit(client, entities, inputChat);
@@ -108,7 +108,7 @@ function _getResponseMessage(client, request, result, inputChat) {
108
108
  return update.message;
109
109
  }
110
110
  }
111
- else if (update instanceof api_1.Api.UpdateEditChannelMessage &&
111
+ else if (update instanceof tl_1.Api.UpdateEditChannelMessage &&
112
112
  "peer" in request &&
113
113
  (0, Utils_1.getPeerId)(request.peer) ==
114
114
  (0, Utils_1.getPeerId)(update.message.peerId)) {
@@ -117,17 +117,17 @@ function _getResponseMessage(client, request, result, inputChat) {
117
117
  return update.message;
118
118
  }
119
119
  }
120
- else if (update instanceof api_1.Api.UpdateNewScheduledMessage) {
120
+ else if (update instanceof tl_1.Api.UpdateNewScheduledMessage) {
121
121
  update.message._finishInit(client, entities, inputChat);
122
122
  schedMessage = update.message;
123
123
  idToMessage.set(update.message.id, update.message);
124
124
  }
125
- else if (update instanceof api_1.Api.UpdateMessagePoll) {
125
+ else if (update instanceof tl_1.Api.UpdateMessagePoll) {
126
126
  if (request.media.poll.id == update.pollId) {
127
- const m = new api_1.Api.Message({
127
+ const m = new tl_1.Api.Message({
128
128
  id: request.id,
129
129
  peerId: index_1.utils.getPeerId(request.peer),
130
- media: new api_1.Api.MessageMediaPoll({
130
+ media: new tl_1.Api.MessageMediaPoll({
131
131
  poll: update.poll,
132
132
  results: update.results,
133
133
  }),