telegram-cli-local 0.3.0__tar.gz → 0.5.0__tar.gz
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.
- {telegram_cli_local-0.3.0 → telegram_cli_local-0.5.0}/.agents/skills/telegram-cli/SKILL.md +42 -5
- {telegram_cli_local-0.3.0 → telegram_cli_local-0.5.0}/.claude/skills/telegram-cli/SKILL.md +42 -5
- {telegram_cli_local-0.3.0 → telegram_cli_local-0.5.0}/CHANGELOG.md +19 -0
- {telegram_cli_local-0.3.0 → telegram_cli_local-0.5.0}/PKG-INFO +100 -8
- telegram_cli_local-0.3.0/telegram_cli_local.egg-info/PKG-INFO → telegram_cli_local-0.5.0/README.md +95 -28
- {telegram_cli_local-0.3.0 → telegram_cli_local-0.5.0}/README.ru.md +97 -6
- {telegram_cli_local-0.3.0 → telegram_cli_local-0.5.0}/RELEASING.md +2 -2
- {telegram_cli_local-0.3.0 → telegram_cli_local-0.5.0}/pyproject.toml +4 -1
- {telegram_cli_local-0.3.0 → telegram_cli_local-0.5.0}/requirements.txt +1 -0
- telegram_cli_local-0.5.0/scripts/benchmark_crypto.py +34 -0
- {telegram_cli_local-0.3.0 → telegram_cli_local-0.5.0}/scripts/check_distribution.py +1 -0
- {telegram_cli_local-0.3.0 → telegram_cli_local-0.5.0}/tcli_skills/SKILL.md +42 -5
- {telegram_cli_local-0.3.0 → telegram_cli_local-0.5.0}/tcli_skills/__init__.py +1 -1
- telegram_cli_local-0.3.0/README.md → telegram_cli_local-0.5.0/telegram_cli_local.egg-info/PKG-INFO +120 -6
- {telegram_cli_local-0.3.0 → telegram_cli_local-0.5.0}/telegram_cli_local.egg-info/SOURCES.txt +1 -0
- telegram_cli_local-0.5.0/telegram_cli_local.egg-info/requires.txt +5 -0
- {telegram_cli_local-0.3.0 → telegram_cli_local-0.5.0}/tests/test_features.py +92 -0
- {telegram_cli_local-0.3.0 → telegram_cli_local-0.5.0}/tests/test_tg.py +233 -9
- {telegram_cli_local-0.3.0 → telegram_cli_local-0.5.0}/tg.py +280 -23
- telegram_cli_local-0.3.0/telegram_cli_local.egg-info/requires.txt +0 -1
- {telegram_cli_local-0.3.0 → telegram_cli_local-0.5.0}/AGENTS.md +0 -0
- {telegram_cli_local-0.3.0 → telegram_cli_local-0.5.0}/CLAUDE.md +0 -0
- {telegram_cli_local-0.3.0 → telegram_cli_local-0.5.0}/LICENSE +0 -0
- {telegram_cli_local-0.3.0 → telegram_cli_local-0.5.0}/MANIFEST.in +0 -0
- {telegram_cli_local-0.3.0 → telegram_cli_local-0.5.0}/scripts/check_docs.py +0 -0
- {telegram_cli_local-0.3.0 → telegram_cli_local-0.5.0}/setup.cfg +0 -0
- {telegram_cli_local-0.3.0 → telegram_cli_local-0.5.0}/telegram_cli_local.egg-info/dependency_links.txt +0 -0
- {telegram_cli_local-0.3.0 → telegram_cli_local-0.5.0}/telegram_cli_local.egg-info/entry_points.txt +0 -0
- {telegram_cli_local-0.3.0 → telegram_cli_local-0.5.0}/telegram_cli_local.egg-info/top_level.txt +0 -0
- {telegram_cli_local-0.3.0 → telegram_cli_local-0.5.0}/tests/test_docs.py +0 -0
|
@@ -1,12 +1,12 @@
|
|
|
1
1
|
---
|
|
2
2
|
name: telegram-cli
|
|
3
|
-
description: Use
|
|
3
|
+
description: Use Telegram CLI (tcli) with named user or bot sessions for messages, attachments, deletion, history, live updates, JSON automation and diagnostics.
|
|
4
4
|
---
|
|
5
5
|
|
|
6
6
|
# Telegram CLI
|
|
7
7
|
|
|
8
|
-
Use the installed `tcli` command from any directory
|
|
9
|
-
|
|
8
|
+
Use the installed `tcli` command from any directory with a user or bot account.
|
|
9
|
+
Respond in the user's language; CLI output and these instructions are English.
|
|
10
10
|
Do not infer a repository path from the skill's installation directory.
|
|
11
11
|
|
|
12
12
|
## Choose the command
|
|
@@ -34,12 +34,16 @@ If unavailable, inspect `tcli help`; do not assume newer commands exist based on
|
|
|
34
34
|
| Observe future messages and edits | `tcli watch "Chat" --edits --json` |
|
|
35
35
|
| Send literal text | `tcli send me "Text" --json` |
|
|
36
36
|
| Edit outgoing text or an attachment caption | `tcli edit me 123 "Corrected text" --json` |
|
|
37
|
+
| Delete specific messages for everyone | `tcli delete me 123 124 --json` |
|
|
38
|
+
| List local session files offline | `tcli sessions --json` |
|
|
39
|
+
| Sign in to a named user session | `tcli --session work login` |
|
|
40
|
+
| Sign in to a separate bot session | `tcli --session assistant login --bot` |
|
|
37
41
|
| Forward with attribution | `tcli forward "Source" 123 "Destination" --json` |
|
|
38
42
|
| Inspect pending scheduled messages | `tcli scheduled me --json` |
|
|
39
43
|
| Cancel specific scheduled messages | `tcli scheduled me --cancel 123 124 --json` |
|
|
40
44
|
| Download one attachment | `tcli download me 123 --output archive.zip --json` |
|
|
41
45
|
| Configure API credentials locally | `tcli config` |
|
|
42
|
-
| Sign in interactively in the user's terminal | `tcli login` |
|
|
46
|
+
| Sign in interactively in the user's terminal | `tcli login` or `tcli login --qr` |
|
|
43
47
|
| Check local setup, optionally connectivity | `tcli doctor` or `tcli doctor --connect` |
|
|
44
48
|
| End this CLI session when requested | `tcli logout` |
|
|
45
49
|
| Refresh supported agent skills offline | `tcli skills install --agent all` |
|
|
@@ -48,10 +52,41 @@ All example names, IDs, links and paths are placeholders. Resolve actual targets
|
|
|
48
52
|
Use `read` for one-time requests; start `watch` only for ongoing observation.
|
|
49
53
|
Use `thread` for the parent chain and `--around` for chronological neighbors; these are different views.
|
|
50
54
|
|
|
55
|
+
## Sessions, bots and deletion
|
|
56
|
+
|
|
57
|
+
Select the authorized account with `--session NAME` before or after the command; default is `default`.
|
|
58
|
+
Phone login reports where Telegram sent the code. If it does not arrive, run `tcli login --qr`
|
|
59
|
+
in a terminal and scan it in Telegram mobile under Settings > Devices > Link Desktop Device.
|
|
60
|
+
Do not assume a different named session belongs to the same person or bot. `sessions --json` lists
|
|
61
|
+
local file presence only, without checking identity or authorization; `doctor --connect` shows user/bot type.
|
|
62
|
+
Names use 1-32 lowercase ASCII letters/digits, underscores or hyphens, starting with letter/digit.
|
|
63
|
+
The default keeps the old account.session; others use sessions/NAME/account.session in the data directory.
|
|
64
|
+
API configuration is shared. Logout affects only the selected session. Do not copy or delete session files.
|
|
65
|
+
|
|
66
|
+
`login --bot` prompts locally with hidden input or reads TG_BOT_TOKEN. API_ID/API_HASH are still required.
|
|
67
|
+
Never collect bot tokens in chat or put them in command arguments. Existing login is reused;
|
|
68
|
+
changing account/type requires another session name. Never log out an unrelated account to switch.
|
|
69
|
+
Bots use MTProto, not HTTP Bot API. Bot capabilities in this CLI:
|
|
70
|
+
|
|
71
|
+
- Send text/files/albums, forward, edit outgoing messages and delete specified IDs within Telegram permissions.
|
|
72
|
+
- Read known IDs (`read --id`), follow `thread`, single download/resume and info, subject to access.
|
|
73
|
+
- Watch live new/edit events only; no history polling or replay guarantee. Privacy mode affects group events.
|
|
74
|
+
- No chats list, title selection, Saved Messages (`me`), history/search/export, pinned/topics/scheduled commands,
|
|
75
|
+
send --schedule, album/batch download. These modes fail with bot_unsupported.
|
|
76
|
+
- Use a known numeric chat ID or @username. A raw ID without a cached entity/access hash may fail.
|
|
77
|
+
Bots cannot initiate arbitrary private conversations; users must contact/add the bot first.
|
|
78
|
+
|
|
79
|
+
`delete CHAT ID [ID ...]` is irreversible, deletes for everyone and has no extra prompt.
|
|
80
|
+
Execute only for the user's explicitly authorized session, chat and IDs. The CLI checks every ID
|
|
81
|
+
belongs to the selected chat before deleting; missing or mismatched IDs abort without deletion.
|
|
82
|
+
`{ok:true,requested_ids:[...]}` means the server accepted the request, not proof for each ID.
|
|
83
|
+
Large requests can partially succeed; after uncertain failure inspect accessible IDs before retrying.
|
|
84
|
+
Use scheduled --cancel for pending scheduled IDs, not delete.
|
|
85
|
+
|
|
51
86
|
## Authorization and private data
|
|
52
87
|
|
|
53
88
|
- Read only the chats and history needed for the user's request. A request to read or develop the CLI
|
|
54
|
-
does not authorize sends, forwards, edits, scheduling or cancellation, including in Saved Messages.
|
|
89
|
+
does not authorize sends, forwards, edits, deletes, scheduling or cancellation, including in Saved Messages.
|
|
55
90
|
- For a write, use the user's authorized recipient, content and message ID where applicable. Existing
|
|
56
91
|
unambiguous authorization remains valid; do not ask for the same permission again. Clarify a genuinely
|
|
57
92
|
ambiguous recipient, time or action before executing that part.
|
|
@@ -270,6 +305,8 @@ JSON contains resulting plain text, not formatting entities or the original Mark
|
|
|
270
305
|
| `download` | {ok:true,files:[...]} |
|
|
271
306
|
| `export` | {ok:true,path,count} |
|
|
272
307
|
| `scheduled --cancel` | {ok:true,cancelled_ids:[...]} |
|
|
308
|
+
| `delete` | {ok:true,requested_ids:[...]} |
|
|
309
|
+
| `sessions` | Array of {name,path}; file presence only |
|
|
273
310
|
|
|
274
311
|
Download file records contain message_id, chat_id, absolute path, text (caption), grouped_id.
|
|
275
312
|
Errors with `--json` or `read --jsonl` go to stderr as {ok:false,error:{code,message,retry_after,...}}.
|
|
@@ -1,12 +1,12 @@
|
|
|
1
1
|
---
|
|
2
2
|
name: telegram-cli
|
|
3
|
-
description: Use
|
|
3
|
+
description: Use Telegram CLI (tcli) with named user or bot sessions for messages, attachments, deletion, history, live updates, JSON automation and diagnostics.
|
|
4
4
|
---
|
|
5
5
|
|
|
6
6
|
# Telegram CLI
|
|
7
7
|
|
|
8
|
-
Use the installed `tcli` command from any directory
|
|
9
|
-
|
|
8
|
+
Use the installed `tcli` command from any directory with a user or bot account.
|
|
9
|
+
Respond in the user's language; CLI output and these instructions are English.
|
|
10
10
|
Do not infer a repository path from the skill's installation directory.
|
|
11
11
|
|
|
12
12
|
## Choose the command
|
|
@@ -34,12 +34,16 @@ If unavailable, inspect `tcli help`; do not assume newer commands exist based on
|
|
|
34
34
|
| Observe future messages and edits | `tcli watch "Chat" --edits --json` |
|
|
35
35
|
| Send literal text | `tcli send me "Text" --json` |
|
|
36
36
|
| Edit outgoing text or an attachment caption | `tcli edit me 123 "Corrected text" --json` |
|
|
37
|
+
| Delete specific messages for everyone | `tcli delete me 123 124 --json` |
|
|
38
|
+
| List local session files offline | `tcli sessions --json` |
|
|
39
|
+
| Sign in to a named user session | `tcli --session work login` |
|
|
40
|
+
| Sign in to a separate bot session | `tcli --session assistant login --bot` |
|
|
37
41
|
| Forward with attribution | `tcli forward "Source" 123 "Destination" --json` |
|
|
38
42
|
| Inspect pending scheduled messages | `tcli scheduled me --json` |
|
|
39
43
|
| Cancel specific scheduled messages | `tcli scheduled me --cancel 123 124 --json` |
|
|
40
44
|
| Download one attachment | `tcli download me 123 --output archive.zip --json` |
|
|
41
45
|
| Configure API credentials locally | `tcli config` |
|
|
42
|
-
| Sign in interactively in the user's terminal | `tcli login` |
|
|
46
|
+
| Sign in interactively in the user's terminal | `tcli login` or `tcli login --qr` |
|
|
43
47
|
| Check local setup, optionally connectivity | `tcli doctor` or `tcli doctor --connect` |
|
|
44
48
|
| End this CLI session when requested | `tcli logout` |
|
|
45
49
|
| Refresh supported agent skills offline | `tcli skills install --agent all` |
|
|
@@ -48,10 +52,41 @@ All example names, IDs, links and paths are placeholders. Resolve actual targets
|
|
|
48
52
|
Use `read` for one-time requests; start `watch` only for ongoing observation.
|
|
49
53
|
Use `thread` for the parent chain and `--around` for chronological neighbors; these are different views.
|
|
50
54
|
|
|
55
|
+
## Sessions, bots and deletion
|
|
56
|
+
|
|
57
|
+
Select the authorized account with `--session NAME` before or after the command; default is `default`.
|
|
58
|
+
Phone login reports where Telegram sent the code. If it does not arrive, run `tcli login --qr`
|
|
59
|
+
in a terminal and scan it in Telegram mobile under Settings > Devices > Link Desktop Device.
|
|
60
|
+
Do not assume a different named session belongs to the same person or bot. `sessions --json` lists
|
|
61
|
+
local file presence only, without checking identity or authorization; `doctor --connect` shows user/bot type.
|
|
62
|
+
Names use 1-32 lowercase ASCII letters/digits, underscores or hyphens, starting with letter/digit.
|
|
63
|
+
The default keeps the old account.session; others use sessions/NAME/account.session in the data directory.
|
|
64
|
+
API configuration is shared. Logout affects only the selected session. Do not copy or delete session files.
|
|
65
|
+
|
|
66
|
+
`login --bot` prompts locally with hidden input or reads TG_BOT_TOKEN. API_ID/API_HASH are still required.
|
|
67
|
+
Never collect bot tokens in chat or put them in command arguments. Existing login is reused;
|
|
68
|
+
changing account/type requires another session name. Never log out an unrelated account to switch.
|
|
69
|
+
Bots use MTProto, not HTTP Bot API. Bot capabilities in this CLI:
|
|
70
|
+
|
|
71
|
+
- Send text/files/albums, forward, edit outgoing messages and delete specified IDs within Telegram permissions.
|
|
72
|
+
- Read known IDs (`read --id`), follow `thread`, single download/resume and info, subject to access.
|
|
73
|
+
- Watch live new/edit events only; no history polling or replay guarantee. Privacy mode affects group events.
|
|
74
|
+
- No chats list, title selection, Saved Messages (`me`), history/search/export, pinned/topics/scheduled commands,
|
|
75
|
+
send --schedule, album/batch download. These modes fail with bot_unsupported.
|
|
76
|
+
- Use a known numeric chat ID or @username. A raw ID without a cached entity/access hash may fail.
|
|
77
|
+
Bots cannot initiate arbitrary private conversations; users must contact/add the bot first.
|
|
78
|
+
|
|
79
|
+
`delete CHAT ID [ID ...]` is irreversible, deletes for everyone and has no extra prompt.
|
|
80
|
+
Execute only for the user's explicitly authorized session, chat and IDs. The CLI checks every ID
|
|
81
|
+
belongs to the selected chat before deleting; missing or mismatched IDs abort without deletion.
|
|
82
|
+
`{ok:true,requested_ids:[...]}` means the server accepted the request, not proof for each ID.
|
|
83
|
+
Large requests can partially succeed; after uncertain failure inspect accessible IDs before retrying.
|
|
84
|
+
Use scheduled --cancel for pending scheduled IDs, not delete.
|
|
85
|
+
|
|
51
86
|
## Authorization and private data
|
|
52
87
|
|
|
53
88
|
- Read only the chats and history needed for the user's request. A request to read or develop the CLI
|
|
54
|
-
does not authorize sends, forwards, edits, scheduling or cancellation, including in Saved Messages.
|
|
89
|
+
does not authorize sends, forwards, edits, deletes, scheduling or cancellation, including in Saved Messages.
|
|
55
90
|
- For a write, use the user's authorized recipient, content and message ID where applicable. Existing
|
|
56
91
|
unambiguous authorization remains valid; do not ask for the same permission again. Clarify a genuinely
|
|
57
92
|
ambiguous recipient, time or action before executing that part.
|
|
@@ -270,6 +305,8 @@ JSON contains resulting plain text, not formatting entities or the original Mark
|
|
|
270
305
|
| `download` | {ok:true,files:[...]} |
|
|
271
306
|
| `export` | {ok:true,path,count} |
|
|
272
307
|
| `scheduled --cancel` | {ok:true,cancelled_ids:[...]} |
|
|
308
|
+
| `delete` | {ok:true,requested_ids:[...]} |
|
|
309
|
+
| `sessions` | Array of {name,path}; file presence only |
|
|
273
310
|
|
|
274
311
|
Download file records contain message_id, chat_id, absolute path, text (caption), grouped_id.
|
|
275
312
|
Errors with `--json` or `read --jsonl` go to stderr as {ok:false,error:{code,message,retry_after,...}}.
|
|
@@ -7,6 +7,25 @@ move them into a versioned section when publishing a release.
|
|
|
7
7
|
|
|
8
8
|
No unreleased changes.
|
|
9
9
|
|
|
10
|
+
## 0.5.0 - 2026-11-11
|
|
11
|
+
|
|
12
|
+
- Show the delivery method chosen by Telegram during phone login.
|
|
13
|
+
- Add `login --qr` for sign-in with an already authorized Telegram mobile app.
|
|
14
|
+
- Pipeline up to four upload blocks per attachment to reduce time spent waiting for Telegram.
|
|
15
|
+
|
|
16
|
+
## 0.4.0 - 2026-10-25
|
|
17
|
+
|
|
18
|
+
### Added
|
|
19
|
+
|
|
20
|
+
- Add `delete CHAT ID...` with full chat-membership preflight and revoke-for-everyone semantics.
|
|
21
|
+
- Add named `--session` selection and offline `sessions` listing, preserving the existing default session.
|
|
22
|
+
- Support hidden-token bot login, direct bot peer resolution and live event-based bot watch;
|
|
23
|
+
reject unsupported bot modes with actionable errors and document capabilities and restrictions.
|
|
24
|
+
- Add a percentage bar that redraws in terminals for uploads, albums and downloads, keeping
|
|
25
|
+
redirected output line-based and JSON progress unchanged. End interrupted bars before errors.
|
|
26
|
+
- Add the optional `fast` extra with native cryptg encryption and an offline correctness/speed
|
|
27
|
+
benchmark, plus workflow performance guidance in both READMEs.
|
|
28
|
+
|
|
10
29
|
## 0.3.0 - 2026-10-19
|
|
11
30
|
|
|
12
31
|
### Changed
|
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
Metadata-Version: 2.4
|
|
2
2
|
Name: telegram-cli-local
|
|
3
|
-
Version: 0.
|
|
4
|
-
Summary: Telegram CLI for
|
|
3
|
+
Version: 0.5.0
|
|
4
|
+
Summary: Telegram CLI for user and bot accounts with named sessions
|
|
5
5
|
Author: BYxarek
|
|
6
6
|
License-Expression: Apache-2.0
|
|
7
7
|
Project-URL: Repository, https://github.com/BYxarek/telegram-cli
|
|
@@ -18,6 +18,9 @@ Requires-Python: >=3.10
|
|
|
18
18
|
Description-Content-Type: text/markdown
|
|
19
19
|
License-File: LICENSE
|
|
20
20
|
Requires-Dist: Telethon==1.45.0
|
|
21
|
+
Requires-Dist: qrcode==8.2
|
|
22
|
+
Provides-Extra: fast
|
|
23
|
+
Requires-Dist: cryptg<0.7,>=0.5.2; extra == "fast"
|
|
21
24
|
Dynamic: license-file
|
|
22
25
|
|
|
23
26
|
<div align="center">
|
|
@@ -50,8 +53,8 @@ tcli watch "Work chat" # Follow new messages
|
|
|
50
53
|
```
|
|
51
54
|
|
|
52
55
|
`tcli` is a local Python CLI built with [Telethon](https://docs.telethon.dev/).
|
|
53
|
-
It uses
|
|
54
|
-
`API_ID` and `API_HASH`;
|
|
56
|
+
It uses Telegram's MTProto API with a personal account or a bot. Both modes require your own
|
|
57
|
+
`API_ID` and `API_HASH`; bot login additionally requires a BotFather token.
|
|
55
58
|
|
|
56
59
|
## Features
|
|
57
60
|
|
|
@@ -71,8 +74,63 @@ are removed from displayed messages.
|
|
|
71
74
|
|
|
72
75
|
### Current scope
|
|
73
76
|
|
|
74
|
-
|
|
75
|
-
|
|
77
|
+
Named local user/bot sessions, text and attachments, message deletion, human-readable output,
|
|
78
|
+
and optional JSON. A full-screen interface is not available.
|
|
79
|
+
|
|
80
|
+
## Sessions, bots and deletion
|
|
81
|
+
|
|
82
|
+
```console
|
|
83
|
+
tcli config
|
|
84
|
+
tcli --session work login
|
|
85
|
+
tcli --session assistant login --bot
|
|
86
|
+
tcli sessions --json
|
|
87
|
+
tcli --session work delete me 123 124 --json
|
|
88
|
+
tcli --session assistant send @example_channel "Status update"
|
|
89
|
+
tcli --session assistant watch @example_channel --edits --json
|
|
90
|
+
```
|
|
91
|
+
|
|
92
|
+
Examples are placeholders; do not execute sends or deletes without explicit authorization.
|
|
93
|
+
`--session NAME` can precede or follow the command. Names contain 1-32 lowercase ASCII
|
|
94
|
+
letters/digits, underscores or hyphens, starting with a letter/digit; Windows device names
|
|
95
|
+
are rejected. `default` keeps the existing `account.session`. Other sessions live under
|
|
96
|
+
`sessions/NAME/account.session` in the same local data directory. API configuration is shared;
|
|
97
|
+
`config` updates it for all sessions. `sessions` lists local file presence offline, not account
|
|
98
|
+
identity or authorization. `doctor --connect` shows the selected account type. `logout` revokes
|
|
99
|
+
only the selected session. Use different session names for different accounts, and avoid
|
|
100
|
+
concurrent processes on the same session. Choosing a new name does not copy existing authorization.
|
|
101
|
+
|
|
102
|
+
`login --bot` reads a token via hidden input or `TG_BOT_TOKEN`, only during login. It does not
|
|
103
|
+
store the token in config or accept it as a command-line argument. Existing authorized sessions
|
|
104
|
+
are reused; login never switches accounts in place. A different account type requires another
|
|
105
|
+
session name. Tokens and session files grant account access; never commit or share them.
|
|
106
|
+
|
|
107
|
+
| Operation | Bot session |
|
|
108
|
+
| --- | --- |
|
|
109
|
+
| Send text/files/albums, forward, edit outgoing messages | Supported, subject to Telegram access and posting permissions |
|
|
110
|
+
| Delete specific IDs | Supported within Telegram permissions; deleting others' messages may require admin rights |
|
|
111
|
+
| `read --id`, `thread`, single `download` including `--resume`, `info` | Supported for accessible known messages/chats; Telegram may reject requests |
|
|
112
|
+
| `watch`, `watch --edits` | Live MTProto events only; no history polling or replay guarantee after downtime |
|
|
113
|
+
| `chats`, history reads/search/export, `pinned`, `topics`, `scheduled`, `send --schedule`, album/batch download | Rejected with `bot_unsupported` in this CLI |
|
|
114
|
+
| Chat selectors | Known numeric ID or `@username`; titles and `me` are rejected |
|
|
115
|
+
|
|
116
|
+
A bot has no Saved Messages and cannot initiate private conversations with arbitrary users:
|
|
117
|
+
the user must first contact it or add it to a group. Groups/channels must grant the necessary
|
|
118
|
+
rights. Group privacy mode affects incoming updates. A numeric peer must already be known to
|
|
119
|
+
the selected session, usually from an update; a raw ID alone does not supply an access hash.
|
|
120
|
+
This uses Telethon/MTProto, not the HTTP Bot API; HTTP Bot API file-size limits are not CLI limits.
|
|
121
|
+
See [Telegram's bot FAQ](https://core.telegram.org/bots/faq),
|
|
122
|
+
[history restriction](https://core.telegram.org/method/messages.getHistory), and
|
|
123
|
+
[known-message retrieval](https://core.telegram.org/method/messages.getMessages).
|
|
124
|
+
|
|
125
|
+
`delete CHAT ID [ID ...]` deletes for everyone (`revoke=True`), without an extra prompt.
|
|
126
|
+
All requested messages are fetched and checked against the selected chat before any deletion;
|
|
127
|
+
a missing ID or a different chat aborts the operation. Duplicate IDs are removed. This check
|
|
128
|
+
is necessary because [Telethon does not validate the chat for deletion](https://docs.telethon.dev/en/stable/modules/client.html#telethon.client.messages.MessageMethods.delete_messages).
|
|
129
|
+
JSON success is `{ok:true,requested_ids:[...]}`: Telegram accepted the request, but does not
|
|
130
|
+
provide per-ID proof of deletion. Telegram determines permissions and message restrictions.
|
|
131
|
+
Large sets may use several server requests and partially succeed before a failure; an uncertain
|
|
132
|
+
network result is not proof that nothing was deleted. Deletion cannot be undone. Scheduled
|
|
133
|
+
messages still use `scheduled --cancel`, not `delete`.
|
|
76
134
|
|
|
77
135
|
## Extended history and automation
|
|
78
136
|
|
|
@@ -268,6 +326,10 @@ tcli login
|
|
|
268
326
|
It does not connect to Telegram. Run it again to replace credentials; invalid input leaves existing settings intact.
|
|
269
327
|
|
|
270
328
|
`login` asks for your international phone number, Telegram login code, and 2FA password if enabled.
|
|
329
|
+
The CLI displays the delivery method chosen by Telegram. If Telegram sends an in-app code,
|
|
330
|
+
open the service chat named **Telegram** on an already signed-in device.
|
|
331
|
+
If the code does not arrive, run `tcli login --qr` in a terminal and scan the QR code in the
|
|
332
|
+
Telegram mobile app under **Settings → Devices → Link Desktop Device**.
|
|
271
333
|
Code and password input is hidden. The session is saved for later commands.
|
|
272
334
|
|
|
273
335
|
### 3. Read and send
|
|
@@ -331,7 +393,9 @@ the CLI displays metadata. Deletion and inline media playback are not supported.
|
|
|
331
393
|
| Command | Purpose |
|
|
332
394
|
| --- | --- |
|
|
333
395
|
| `tcli config` | Save or replace API credentials |
|
|
334
|
-
| `tcli login` | Sign in
|
|
396
|
+
| `tcli login` | Sign in by phone or with `--qr`; use `--bot` for a bot |
|
|
397
|
+
| `tcli sessions --json` | List local named session files offline |
|
|
398
|
+
| `tcli delete CHAT ID [ID ...]` | Delete the selected messages for everyone |
|
|
335
399
|
| `tcli chats --limit 100` | List up to 100 chats; default: 50 |
|
|
336
400
|
| `tcli read "Chat" --limit 20` | Read recent messages; default: 20 |
|
|
337
401
|
| `tcli send "Chat" "Text"` | Send one plain-text message |
|
|
@@ -483,12 +547,39 @@ Upload/download progress is enabled automatically when stderr is a terminal. `--
|
|
|
483
547
|
it when redirected; `--no-progress` disables it. These flags apply to attachment sends and downloads.
|
|
484
548
|
Progress includes transferred/total bytes, percentage, and average bytes per second; album upload
|
|
485
549
|
progress is weighted by local file sizes. Updates are throttled to twice per second, plus completion.
|
|
550
|
+
Human output includes a bar such as `[##########----------] 50.0%`. In a terminal it redraws
|
|
551
|
+
in place; redirected output uses separate lines. Unknown sizes have an empty bar without a percentage.
|
|
486
552
|
With `--json`, stderr receives JSONL events with `event="transfer_progress"`, `operation`, `file`,
|
|
487
553
|
`transferred_bytes`, `total_bytes`, `percent` (null for unknown/zero size), and `bytes_per_second`.
|
|
488
554
|
Errors are still JSON objects on stderr; distinguish them from progress by `ok=false`.
|
|
489
555
|
Stdout contains only the final result. Progress measures transfer work, not confirmed delivery;
|
|
490
556
|
cached uploads may produce no progress events.
|
|
491
557
|
|
|
558
|
+
### Performance
|
|
559
|
+
|
|
560
|
+
Install the optional native encryption accelerator from a source checkout:
|
|
561
|
+
|
|
562
|
+
```console
|
|
563
|
+
python -m pip install -e ".[fast]"
|
|
564
|
+
python scripts/benchmark_crypto.py
|
|
565
|
+
```
|
|
566
|
+
|
|
567
|
+
Telethon automatically uses `cryptg` when installed, reducing encryption/decryption CPU work
|
|
568
|
+
without changing message handling. The offline benchmark compares the existing fallback with
|
|
569
|
+
cryptg on synthetic data and checks identical ciphertext and successful decryption; its speedup
|
|
570
|
+
is for AES only, not end-to-end Telegram throughput. The base installation remains usable without it.
|
|
571
|
+
See [Telethon's transfer FAQ](https://docs.telethon.dev/en/stable/quick-references/faq.html#file-download-is-slow-or-sending-files-takes-too-long).
|
|
572
|
+
|
|
573
|
+
For faster workflows, forward existing Telegram attachments instead of downloading and uploading
|
|
574
|
+
them again, use `--jsonl` for large history reads, and apply server-side date/sender/media filters
|
|
575
|
+
before filename matching. Keep filename scan bounds as small as the task allows. Disable progress
|
|
576
|
+
with `--no-progress` when measuring transfer speed. Avoid concurrent CLI processes on one session.
|
|
577
|
+
For local attachments larger than 512 KiB, `send --attach` keeps up to four 512 KiB blocks
|
|
578
|
+
in flight over one Telegram connection. This also applies to individual files in an album.
|
|
579
|
+
Progress counts acknowledged bytes, and the CLI submits the message after all its blocks are saved.
|
|
580
|
+
Resumable downloads already use Telethon's maximum default request size (512 KiB).
|
|
581
|
+
Plain text has no byte-transfer callback: the CLI reports the confirmed message ID after sending.
|
|
582
|
+
|
|
492
583
|
### Text formatting
|
|
493
584
|
|
|
494
585
|
```console
|
|
@@ -655,7 +746,8 @@ Increase `--limit` if your chat is not in the first page.
|
|
|
655
746
|
**Telegram asks you to wait?** Wait for the reported FloodWait period.
|
|
656
747
|
After a connection failure, check recent history before retrying a send to avoid duplicates.
|
|
657
748
|
|
|
658
|
-
**Can I use a bot?**
|
|
749
|
+
**Can I use a bot?** Yes: use a separate `--session NAME` and `login --bot`. See the capabilities
|
|
750
|
+
and restrictions under [Sessions, bots and deletion](#sessions-bots-and-deletion).
|
|
659
751
|
|
|
660
752
|
**Can I still run the Python file?** Yes: `python tg.py ...` from the project root
|
|
661
753
|
with dependencies installed uses the same commands.
|
telegram_cli_local-0.3.0/telegram_cli_local.egg-info/PKG-INFO → telegram_cli_local-0.5.0/README.md
RENAMED
|
@@ -1,25 +1,3 @@
|
|
|
1
|
-
Metadata-Version: 2.4
|
|
2
|
-
Name: telegram-cli-local
|
|
3
|
-
Version: 0.3.0
|
|
4
|
-
Summary: Telegram CLI for a personal account
|
|
5
|
-
Author: BYxarek
|
|
6
|
-
License-Expression: Apache-2.0
|
|
7
|
-
Project-URL: Repository, https://github.com/BYxarek/telegram-cli
|
|
8
|
-
Project-URL: Issues, https://github.com/BYxarek/telegram-cli/issues
|
|
9
|
-
Keywords: telegram,cli,telethon,agent-skills
|
|
10
|
-
Classifier: Development Status :: 4 - Beta
|
|
11
|
-
Classifier: Environment :: Console
|
|
12
|
-
Classifier: Intended Audience :: End Users/Desktop
|
|
13
|
-
Classifier: Operating System :: OS Independent
|
|
14
|
-
Classifier: Programming Language :: Python :: 3
|
|
15
|
-
Classifier: Programming Language :: Python :: 3 :: Only
|
|
16
|
-
Classifier: Topic :: Communications :: Chat
|
|
17
|
-
Requires-Python: >=3.10
|
|
18
|
-
Description-Content-Type: text/markdown
|
|
19
|
-
License-File: LICENSE
|
|
20
|
-
Requires-Dist: Telethon==1.45.0
|
|
21
|
-
Dynamic: license-file
|
|
22
|
-
|
|
23
1
|
<div align="center">
|
|
24
2
|
|
|
25
3
|
# tcli · Telegram in your terminal
|
|
@@ -50,8 +28,8 @@ tcli watch "Work chat" # Follow new messages
|
|
|
50
28
|
```
|
|
51
29
|
|
|
52
30
|
`tcli` is a local Python CLI built with [Telethon](https://docs.telethon.dev/).
|
|
53
|
-
It uses
|
|
54
|
-
`API_ID` and `API_HASH`;
|
|
31
|
+
It uses Telegram's MTProto API with a personal account or a bot. Both modes require your own
|
|
32
|
+
`API_ID` and `API_HASH`; bot login additionally requires a BotFather token.
|
|
55
33
|
|
|
56
34
|
## Features
|
|
57
35
|
|
|
@@ -71,8 +49,63 @@ are removed from displayed messages.
|
|
|
71
49
|
|
|
72
50
|
### Current scope
|
|
73
51
|
|
|
74
|
-
|
|
75
|
-
|
|
52
|
+
Named local user/bot sessions, text and attachments, message deletion, human-readable output,
|
|
53
|
+
and optional JSON. A full-screen interface is not available.
|
|
54
|
+
|
|
55
|
+
## Sessions, bots and deletion
|
|
56
|
+
|
|
57
|
+
```console
|
|
58
|
+
tcli config
|
|
59
|
+
tcli --session work login
|
|
60
|
+
tcli --session assistant login --bot
|
|
61
|
+
tcli sessions --json
|
|
62
|
+
tcli --session work delete me 123 124 --json
|
|
63
|
+
tcli --session assistant send @example_channel "Status update"
|
|
64
|
+
tcli --session assistant watch @example_channel --edits --json
|
|
65
|
+
```
|
|
66
|
+
|
|
67
|
+
Examples are placeholders; do not execute sends or deletes without explicit authorization.
|
|
68
|
+
`--session NAME` can precede or follow the command. Names contain 1-32 lowercase ASCII
|
|
69
|
+
letters/digits, underscores or hyphens, starting with a letter/digit; Windows device names
|
|
70
|
+
are rejected. `default` keeps the existing `account.session`. Other sessions live under
|
|
71
|
+
`sessions/NAME/account.session` in the same local data directory. API configuration is shared;
|
|
72
|
+
`config` updates it for all sessions. `sessions` lists local file presence offline, not account
|
|
73
|
+
identity or authorization. `doctor --connect` shows the selected account type. `logout` revokes
|
|
74
|
+
only the selected session. Use different session names for different accounts, and avoid
|
|
75
|
+
concurrent processes on the same session. Choosing a new name does not copy existing authorization.
|
|
76
|
+
|
|
77
|
+
`login --bot` reads a token via hidden input or `TG_BOT_TOKEN`, only during login. It does not
|
|
78
|
+
store the token in config or accept it as a command-line argument. Existing authorized sessions
|
|
79
|
+
are reused; login never switches accounts in place. A different account type requires another
|
|
80
|
+
session name. Tokens and session files grant account access; never commit or share them.
|
|
81
|
+
|
|
82
|
+
| Operation | Bot session |
|
|
83
|
+
| --- | --- |
|
|
84
|
+
| Send text/files/albums, forward, edit outgoing messages | Supported, subject to Telegram access and posting permissions |
|
|
85
|
+
| Delete specific IDs | Supported within Telegram permissions; deleting others' messages may require admin rights |
|
|
86
|
+
| `read --id`, `thread`, single `download` including `--resume`, `info` | Supported for accessible known messages/chats; Telegram may reject requests |
|
|
87
|
+
| `watch`, `watch --edits` | Live MTProto events only; no history polling or replay guarantee after downtime |
|
|
88
|
+
| `chats`, history reads/search/export, `pinned`, `topics`, `scheduled`, `send --schedule`, album/batch download | Rejected with `bot_unsupported` in this CLI |
|
|
89
|
+
| Chat selectors | Known numeric ID or `@username`; titles and `me` are rejected |
|
|
90
|
+
|
|
91
|
+
A bot has no Saved Messages and cannot initiate private conversations with arbitrary users:
|
|
92
|
+
the user must first contact it or add it to a group. Groups/channels must grant the necessary
|
|
93
|
+
rights. Group privacy mode affects incoming updates. A numeric peer must already be known to
|
|
94
|
+
the selected session, usually from an update; a raw ID alone does not supply an access hash.
|
|
95
|
+
This uses Telethon/MTProto, not the HTTP Bot API; HTTP Bot API file-size limits are not CLI limits.
|
|
96
|
+
See [Telegram's bot FAQ](https://core.telegram.org/bots/faq),
|
|
97
|
+
[history restriction](https://core.telegram.org/method/messages.getHistory), and
|
|
98
|
+
[known-message retrieval](https://core.telegram.org/method/messages.getMessages).
|
|
99
|
+
|
|
100
|
+
`delete CHAT ID [ID ...]` deletes for everyone (`revoke=True`), without an extra prompt.
|
|
101
|
+
All requested messages are fetched and checked against the selected chat before any deletion;
|
|
102
|
+
a missing ID or a different chat aborts the operation. Duplicate IDs are removed. This check
|
|
103
|
+
is necessary because [Telethon does not validate the chat for deletion](https://docs.telethon.dev/en/stable/modules/client.html#telethon.client.messages.MessageMethods.delete_messages).
|
|
104
|
+
JSON success is `{ok:true,requested_ids:[...]}`: Telegram accepted the request, but does not
|
|
105
|
+
provide per-ID proof of deletion. Telegram determines permissions and message restrictions.
|
|
106
|
+
Large sets may use several server requests and partially succeed before a failure; an uncertain
|
|
107
|
+
network result is not proof that nothing was deleted. Deletion cannot be undone. Scheduled
|
|
108
|
+
messages still use `scheduled --cancel`, not `delete`.
|
|
76
109
|
|
|
77
110
|
## Extended history and automation
|
|
78
111
|
|
|
@@ -268,6 +301,10 @@ tcli login
|
|
|
268
301
|
It does not connect to Telegram. Run it again to replace credentials; invalid input leaves existing settings intact.
|
|
269
302
|
|
|
270
303
|
`login` asks for your international phone number, Telegram login code, and 2FA password if enabled.
|
|
304
|
+
The CLI displays the delivery method chosen by Telegram. If Telegram sends an in-app code,
|
|
305
|
+
open the service chat named **Telegram** on an already signed-in device.
|
|
306
|
+
If the code does not arrive, run `tcli login --qr` in a terminal and scan the QR code in the
|
|
307
|
+
Telegram mobile app under **Settings → Devices → Link Desktop Device**.
|
|
271
308
|
Code and password input is hidden. The session is saved for later commands.
|
|
272
309
|
|
|
273
310
|
### 3. Read and send
|
|
@@ -331,7 +368,9 @@ the CLI displays metadata. Deletion and inline media playback are not supported.
|
|
|
331
368
|
| Command | Purpose |
|
|
332
369
|
| --- | --- |
|
|
333
370
|
| `tcli config` | Save or replace API credentials |
|
|
334
|
-
| `tcli login` | Sign in
|
|
371
|
+
| `tcli login` | Sign in by phone or with `--qr`; use `--bot` for a bot |
|
|
372
|
+
| `tcli sessions --json` | List local named session files offline |
|
|
373
|
+
| `tcli delete CHAT ID [ID ...]` | Delete the selected messages for everyone |
|
|
335
374
|
| `tcli chats --limit 100` | List up to 100 chats; default: 50 |
|
|
336
375
|
| `tcli read "Chat" --limit 20` | Read recent messages; default: 20 |
|
|
337
376
|
| `tcli send "Chat" "Text"` | Send one plain-text message |
|
|
@@ -483,12 +522,39 @@ Upload/download progress is enabled automatically when stderr is a terminal. `--
|
|
|
483
522
|
it when redirected; `--no-progress` disables it. These flags apply to attachment sends and downloads.
|
|
484
523
|
Progress includes transferred/total bytes, percentage, and average bytes per second; album upload
|
|
485
524
|
progress is weighted by local file sizes. Updates are throttled to twice per second, plus completion.
|
|
525
|
+
Human output includes a bar such as `[##########----------] 50.0%`. In a terminal it redraws
|
|
526
|
+
in place; redirected output uses separate lines. Unknown sizes have an empty bar without a percentage.
|
|
486
527
|
With `--json`, stderr receives JSONL events with `event="transfer_progress"`, `operation`, `file`,
|
|
487
528
|
`transferred_bytes`, `total_bytes`, `percent` (null for unknown/zero size), and `bytes_per_second`.
|
|
488
529
|
Errors are still JSON objects on stderr; distinguish them from progress by `ok=false`.
|
|
489
530
|
Stdout contains only the final result. Progress measures transfer work, not confirmed delivery;
|
|
490
531
|
cached uploads may produce no progress events.
|
|
491
532
|
|
|
533
|
+
### Performance
|
|
534
|
+
|
|
535
|
+
Install the optional native encryption accelerator from a source checkout:
|
|
536
|
+
|
|
537
|
+
```console
|
|
538
|
+
python -m pip install -e ".[fast]"
|
|
539
|
+
python scripts/benchmark_crypto.py
|
|
540
|
+
```
|
|
541
|
+
|
|
542
|
+
Telethon automatically uses `cryptg` when installed, reducing encryption/decryption CPU work
|
|
543
|
+
without changing message handling. The offline benchmark compares the existing fallback with
|
|
544
|
+
cryptg on synthetic data and checks identical ciphertext and successful decryption; its speedup
|
|
545
|
+
is for AES only, not end-to-end Telegram throughput. The base installation remains usable without it.
|
|
546
|
+
See [Telethon's transfer FAQ](https://docs.telethon.dev/en/stable/quick-references/faq.html#file-download-is-slow-or-sending-files-takes-too-long).
|
|
547
|
+
|
|
548
|
+
For faster workflows, forward existing Telegram attachments instead of downloading and uploading
|
|
549
|
+
them again, use `--jsonl` for large history reads, and apply server-side date/sender/media filters
|
|
550
|
+
before filename matching. Keep filename scan bounds as small as the task allows. Disable progress
|
|
551
|
+
with `--no-progress` when measuring transfer speed. Avoid concurrent CLI processes on one session.
|
|
552
|
+
For local attachments larger than 512 KiB, `send --attach` keeps up to four 512 KiB blocks
|
|
553
|
+
in flight over one Telegram connection. This also applies to individual files in an album.
|
|
554
|
+
Progress counts acknowledged bytes, and the CLI submits the message after all its blocks are saved.
|
|
555
|
+
Resumable downloads already use Telethon's maximum default request size (512 KiB).
|
|
556
|
+
Plain text has no byte-transfer callback: the CLI reports the confirmed message ID after sending.
|
|
557
|
+
|
|
492
558
|
### Text formatting
|
|
493
559
|
|
|
494
560
|
```console
|
|
@@ -655,7 +721,8 @@ Increase `--limit` if your chat is not in the first page.
|
|
|
655
721
|
**Telegram asks you to wait?** Wait for the reported FloodWait period.
|
|
656
722
|
After a connection failure, check recent history before retrying a send to avoid duplicates.
|
|
657
723
|
|
|
658
|
-
**Can I use a bot?**
|
|
724
|
+
**Can I use a bot?** Yes: use a separate `--session NAME` and `login --bot`. See the capabilities
|
|
725
|
+
and restrictions under [Sessions, bots and deletion](#sessions-bots-and-deletion).
|
|
659
726
|
|
|
660
727
|
**Can I still run the Python file?** Yes: `python tg.py ...` from the project root
|
|
661
728
|
with dependencies installed uses the same commands.
|