teleproto 1.225.1 → 1.225.2

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.
@@ -1,10 +1,7 @@
1
1
  MIT License
2
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.
3
+ Copyright (c) 2019 GramJS
4
+ Copyright (c) 2025-present sanyok12345
8
5
 
9
6
  Permission is hereby granted, free of charge, to any person obtaining a copy
10
7
  of this software and associated documentation files (the "Software"), to deal
@@ -22,4 +19,4 @@ FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
22
19
  AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
23
20
  LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
24
21
  OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
25
- SOFTWARE.
22
+ SOFTWARE.
package/README.md CHANGED
@@ -1,150 +1,115 @@
1
- # teleproto
1
+ [![npm](https://img.shields.io/npm/v/teleproto)](https://www.npmjs.com/package/teleproto)
2
+ [![License: MIT](https://img.shields.io/badge/License-MIT-blue)](./LICENSE)
2
3
 
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
- <a href="https://t.me/teleproto"><img src="https://img.shields.io/badge/Telegram-Chat-26A5E4?logo=telegram" alt="telegram chat"></a>
9
- </p>
4
+ This project was forked from the open source GramJS project in 2025 and is now developed independently.
10
5
 
11
- Modern Telegram MTProto client for Node.js, written in TypeScript.
12
- `teleproto` is a high-performance fork of GramJS focused on clean API ergonomics, runtime reliability, and up-to-date Telegram layers.
6
+ This README is just a fast *quick start*. Ongoing discussion happens in the [Telegram chat](https://t.me/teleproto).
13
7
 
14
- ## Features
8
+ # What is teleproto?
15
9
 
16
- - **MTProto-first**: Full Telegram API access through high-level client methods and raw `Api` calls.
17
- - **TypeScript-friendly**: Strong typings across client methods, events, sessions, and TL objects.
18
- - **Session options**: Use `StringSession` for portability or `StoreSession` for local persistence.
19
- - **Event system**: Handle updates with builders like `NewMessage`, `EditedMessage`, `CallbackQuery`, and more.
20
- - **Examples included**: Ready-to-run scripts in `teleproto_examples`.
10
+ teleproto is a TypeScript client for Telegram's MTProto API the same protocol Telegram's own apps speak. Through it, your code gets the full account surface: userbots, multi-account automation, file transfer, raw TL invocation when you need it. If you only need to push notifications from a bot, the official Bot API is simpler; teleproto exists for everything *beyond* that.
21
11
 
22
- ## Installation
12
+ # Installing teleproto
23
13
 
24
- ```bash
25
- npm i teleproto
26
- ```
14
+ % npm install teleproto
15
+
16
+ Pure JavaScript, no native build step — installs cleanly on Alpine, ARM, and serverless runtimes.
27
17
 
28
- ## Quick Start
18
+ # Connecting to Telegram
29
19
 
30
- 1. Open https://my.telegram.org
31
- 2. Create an app in **API development tools**
32
- 3. Copy your `api_id` and `api_hash`
20
+ You need an `api_id` and `api_hash` from <https://my.telegram.org>. Then:
33
21
 
34
22
  ```ts
35
23
  import { TelegramClient } from "teleproto";
36
24
  import { StringSession } from "teleproto/sessions";
37
- import readline from "readline";
25
+ import { createInterface } from "node:readline/promises";
26
+
27
+ const rl = createInterface({ input: process.stdin, output: process.stdout });
38
28
 
39
- const apiId = 123456;
40
- const apiHash = "0123456789abcdef0123456789abcdef";
29
+ const apiId = 0; // from https://my.telegram.org
30
+ const apiHash = ""; // from https://my.telegram.org
41
31
  const session = new StringSession("");
42
32
 
43
- const rl = readline.createInterface({
44
- input: process.stdin,
45
- output: process.stdout,
33
+ const client = new TelegramClient(session, apiId, apiHash, {
34
+ connectionRetries: 5,
46
35
  });
47
36
 
48
- const ask = (q: string) =>
49
- new Promise<string>((resolve) => rl.question(q, resolve));
50
-
51
- async function main() {
52
- const client = new TelegramClient(session, apiId, apiHash, {
53
- connectionRetries: 5,
54
- });
55
-
56
- await client.start({
57
- phoneNumber: async () => await ask("Phone number: "),
58
- password: async () => await ask("2FA password (if enabled): "),
59
- phoneCode: async () => await ask("Code from Telegram: "),
60
- onError: (err) => console.error(err),
61
- });
62
-
63
- console.log("Connected as:", (await client.getMe())?.username || "unknown");
64
- console.log("String session:\n", client.session.save());
37
+ await client.start({
38
+ phoneNumber: () => rl.question("Phone: "),
39
+ password: () => rl.question("2FA password: "),
40
+ phoneCode: () => rl.question("Code: "),
41
+ onError: console.error,
42
+ });
65
43
 
66
- await client.sendMessage("me", { message: "Hello from teleproto!" });
67
- await client.disconnect();
68
- rl.close();
69
- }
44
+ console.log(await client.getMe());
45
+ console.log("Session string:", client.session.save());
70
46
 
71
- main().catch(console.error);
47
+ rl.close();
72
48
  ```
73
49
 
74
- ## Sessions
75
-
76
- Use `StringSession` when you want to store auth as a single string:
50
+ The session string is your saved login. Drop it back into `new StringSession(saved)` next time and skip the auth flow entirely.
77
51
 
78
- ```ts
79
- import { StringSession } from "teleproto/sessions";
80
- const session = new StringSession("");
81
- ```
52
+ # Sending and receiving
82
53
 
83
- Use `StoreSession` when you want local folder-based persistence:
84
-
85
- ```ts
86
- import { StoreSession } from "teleproto/sessions";
87
- const session = new StoreSession("teleproto_session");
88
- ```
89
-
90
- ## Events
54
+ Send a message, listen for incoming ones:
91
55
 
92
56
  ```ts
93
57
  import { NewMessage } from "teleproto/events";
94
58
 
59
+ await client.sendMessage("me", { message: "hello from teleproto" });
60
+
95
61
  client.addEventHandler(
96
- async (event) => {
97
- const text = event.message.message || "";
98
- if (/^hello$/i.test(text.trim())) {
99
- await event.message.reply({ message: "Hi there!" });
100
- }
101
- },
102
- new NewMessage({})
62
+ (event) => console.log(event.message.message),
63
+ new NewMessage({}),
103
64
  );
104
65
  ```
105
66
 
106
- ## Raw API
67
+ # Raw MTProto API
68
+
69
+ Every method in Telegram's TL schema is callable directly through `Api.*`. teleproto follows the schema layer-for-layer, so what Telegram adds is usually available here within days.
107
70
 
108
71
  ```ts
109
72
  import { Api } from "teleproto";
110
73
 
111
- const result = await client.invoke(
112
- new Api.help.GetConfig()
113
- );
114
- console.log(result);
74
+ const config = await client.invoke(new Api.help.GetConfig());
115
75
  ```
116
76
 
117
- ## Examples
77
+ # Versioning
118
78
 
119
- Practical scripts are available in `teleproto_examples`:
79
+ teleproto uses a three-part version `MAJOR.LAYER.PATCH`:
120
80
 
121
- - `print_updates.ts`
122
- - `print_messages.ts`
123
- - `replier.ts`
124
- - `interactive_terminal.ts`
81
+ - **MAJOR** — bumped on breaking API changes in teleproto itself.
82
+ - **LAYER** — the Telegram TL schema layer the release ships against
83
+ (e.g. `1.225.x` ships layer 225).
84
+ - **PATCH** — fixes and non-breaking improvements within the same layer.
125
85
 
126
- Run any example from the project root:
86
+ This stays compatible with npm's range syntax:
127
87
 
128
- ```bash
129
- npx ts-node --transpile-only teleproto_examples/print_updates.ts
130
- ```
88
+ - `^1.225.0` accepts new layers and patches — recommended default.
89
+ - `~1.225.0` sticks to layer 225 only; useful if you depend on
90
+ schema specifics that newer layers might change.
91
+ - `1.225.1` is an exact pin.
92
+
93
+ # Examples
94
+
95
+ Runnable scripts live in [teleproto_examples/](teleproto_examples/):
96
+
97
+ - `print_updates.ts` — log every update the client receives
98
+ - `print_messages.ts` — listen for new messages only
99
+ - `replier.ts` — auto-reply pattern for bots and userbots
100
+ - `interactive_terminal.ts` — REPL against a live client
131
101
 
132
- ## Community
102
+ Each is self-contained. Set your credentials at the top and run:
133
103
 
134
- - [Telegram Chat](https://t.me/teleproto) — questions, discussions, updates
135
- - [GitHub Issues](https://github.com/sanyok12345/teleproto/issues) — bug reports and feature requests
104
+ % npx ts-node --transpile-only teleproto_examples/print_updates.ts
136
105
 
137
- ## Support the project ☕
106
+ # Code contributions
138
107
 
139
- If teleproto saves you time or powers your product — consider buying me a coffee.
140
- Every donation keeps the lights on and the commits flowing.
108
+ Please see [CONTRIBUTING.md][1].
141
109
 
142
- | Network | Address |
143
- |---------|---------|
144
- | **TON** | `sanyok12345.ton` |
145
- | **TRX** | `TXCtN1UrxST9ovq5tDN3Zb96eNF4164nK5` |
146
- | **SOL** | `B3XcKmAR9aG2nBiWSMDe76GGa55hPNgLQ92QR2SjRR6F` |
110
+ # License
147
111
 
148
- ## License
112
+ teleproto is distributed under the [MIT License][2].
149
113
 
150
- MIT
114
+ [1]: ./CONTRIBUTING.md
115
+ [2]: ./LICENSE
package/Version.d.ts CHANGED
@@ -1 +1 @@
1
- export declare const version = "1.225.1";
1
+ export declare const version = "1.225.2";
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.225.1";
4
+ exports.version = "1.225.2";
package/client/users.js CHANGED
@@ -435,7 +435,7 @@ async function getInputEntity(client, peer) {
435
435
  }
436
436
  throw new Error(`Could not find the input entity for ${JSON.stringify(peer)}.
437
437
  Please read https://` +
438
- "docs.telethon.dev/en/stable/concepts/entities.html to" +
438
+ "docs.teleproto.dev/concepts/entities to" +
439
439
  " find out more details.");
440
440
  }
441
441
  /** @hidden */
@@ -14,26 +14,22 @@ export declare class MTProtoState {
14
14
  private securityChecks;
15
15
  /**
16
16
  *
17
- `telethon.network.mtprotosender.MTProtoSender` needs to hold a state
18
- in order to be able to encrypt and decrypt incoming/outgoing messages,
19
- as well as generating the message IDs. Instances of this class hold
20
- together all the required information.
17
+ `MTProtoSender` needs to hold a state in order to encrypt and decrypt
18
+ incoming/outgoing messages, as well as generate message IDs. Instances
19
+ of this class hold together all the required information.
21
20
 
22
- It doesn't make sense to use `telethon.sessions.abstract.Session` for
23
- the sender because the sender should *not* be concerned about storing
24
- this information to disk, as one may create as many senders as they
25
- desire to any other data center, or some CDN. Using the same session
26
- for all these is not a good idea as each need their own authkey, and
27
- the concept of "copying" sessions with the unnecessary entities or
28
- updates state for these connections doesn't make sense.
21
+ A `Session` is intentionally not used here: the sender should *not* be
22
+ concerned with persisting this state to disk. Multiple senders may
23
+ exist for different data centers or CDNs, each requiring its own
24
+ authkey "copying" a session along with unrelated entities or update
25
+ state would make no sense.
29
26
 
30
- While it would be possible to have a `MTProtoPlainState` that does no
31
- encryption so that it was usable through the `MTProtoLayer` and thus
32
- avoid the need for a `MTProtoPlainSender`, the `MTProtoLayer` is more
33
- focused to efficiency and this state is also more advanced (since it
34
- supports gzipping and invoking after other message IDs). There are too
35
- many methods that would be needed to make it convenient to use for the
36
- authentication process, at which point the `MTProtoPlainSender` is better
27
+ A `MTProtoPlainState` doing no encryption could in principle be used
28
+ through `MTProtoLayer` and remove the need for `MTProtoPlainSender`,
29
+ but `MTProtoLayer` targets efficient throughput and this state class
30
+ is also more advanced (gzipping, invoking after other message IDs).
31
+ Too many helper methods would be needed to make it convenient during
32
+ authentication, where `MTProtoPlainSender` is the better fit.
37
33
  * @param authKey
38
34
  * @param loggers
39
35
  * @param securityChecks
@@ -16,26 +16,22 @@ const ReceivedIdsManager_1 = require("./ReceivedIdsManager");
16
16
  class MTProtoState {
17
17
  /**
18
18
  *
19
- `telethon.network.mtprotosender.MTProtoSender` needs to hold a state
20
- in order to be able to encrypt and decrypt incoming/outgoing messages,
21
- as well as generating the message IDs. Instances of this class hold
22
- together all the required information.
19
+ `MTProtoSender` needs to hold a state in order to encrypt and decrypt
20
+ incoming/outgoing messages, as well as generate message IDs. Instances
21
+ of this class hold together all the required information.
23
22
 
24
- It doesn't make sense to use `telethon.sessions.abstract.Session` for
25
- the sender because the sender should *not* be concerned about storing
26
- this information to disk, as one may create as many senders as they
27
- desire to any other data center, or some CDN. Using the same session
28
- for all these is not a good idea as each need their own authkey, and
29
- the concept of "copying" sessions with the unnecessary entities or
30
- updates state for these connections doesn't make sense.
23
+ A `Session` is intentionally not used here: the sender should *not* be
24
+ concerned with persisting this state to disk. Multiple senders may
25
+ exist for different data centers or CDNs, each requiring its own
26
+ authkey "copying" a session along with unrelated entities or update
27
+ state would make no sense.
31
28
 
32
- While it would be possible to have a `MTProtoPlainState` that does no
33
- encryption so that it was usable through the `MTProtoLayer` and thus
34
- avoid the need for a `MTProtoPlainSender`, the `MTProtoLayer` is more
35
- focused to efficiency and this state is also more advanced (since it
36
- supports gzipping and invoking after other message IDs). There are too
37
- many methods that would be needed to make it convenient to use for the
38
- authentication process, at which point the `MTProtoPlainSender` is better
29
+ A `MTProtoPlainState` doing no encryption could in principle be used
30
+ through `MTProtoLayer` and remove the need for `MTProtoPlainSender`,
31
+ but `MTProtoLayer` targets efficient throughput and this state class
32
+ is also more advanced (gzipping, invoking after other message IDs).
33
+ Too many helper methods would be needed to make it convenient during
34
+ authentication, where `MTProtoPlainSender` is the better fit.
39
35
  * @param authKey
40
36
  * @param loggers
41
37
  * @param securityChecks
package/package.json CHANGED
@@ -1,7 +1,7 @@
1
1
  {
2
2
  "name": "teleproto",
3
- "version": "1.225.1",
4
- "description": "NodeJS MTProto API Telegram client library,",
3
+ "version": "1.225.2",
4
+ "description": "Telegram MTProto API client library written in TypeScript",
5
5
  "main": "index.js",
6
6
  "types": "index.d.ts",
7
7
  "repository": {
@@ -15,13 +15,11 @@
15
15
  "keywords": [
16
16
  "telegram",
17
17
  "mtproto",
18
- "teleproto",
19
- "client",
20
- "nodejs",
18
+ "userbot",
21
19
  "typescript",
22
- "api"
20
+ "nodejs"
23
21
  ],
24
- "homepage": "https://github.com/sanyok12345/teleproto#readme",
22
+ "homepage": "https://docs.teleproto.dev",
25
23
  "dependencies": {
26
24
  "async-mutex": "^0.3.0",
27
25
  "big-integer": "^1.6.48",