telethon-cli 0.1.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.
Files changed (30) hide show
  1. telethon_cli-0.1.0/PKG-INFO +199 -0
  2. telethon_cli-0.1.0/README.md +172 -0
  3. telethon_cli-0.1.0/pyproject.toml +47 -0
  4. telethon_cli-0.1.0/setup.cfg +4 -0
  5. telethon_cli-0.1.0/src/telethon_cli/__init__.py +3 -0
  6. telethon_cli-0.1.0/src/telethon_cli/__main__.py +5 -0
  7. telethon_cli-0.1.0/src/telethon_cli/app.py +320 -0
  8. telethon_cli-0.1.0/src/telethon_cli/command_matrix.py +106 -0
  9. telethon_cli-0.1.0/src/telethon_cli/config.py +195 -0
  10. telethon_cli-0.1.0/src/telethon_cli/errors.py +2 -0
  11. telethon_cli-0.1.0/src/telethon_cli/live_smoke.py +465 -0
  12. telethon_cli-0.1.0/src/telethon_cli/registry.py +119 -0
  13. telethon_cli-0.1.0/src/telethon_cli/resolver.py +39 -0
  14. telethon_cli-0.1.0/src/telethon_cli/runtime.py +280 -0
  15. telethon_cli-0.1.0/src/telethon_cli/serialization.py +141 -0
  16. telethon_cli-0.1.0/src/telethon_cli/settings.py +81 -0
  17. telethon_cli-0.1.0/src/telethon_cli.egg-info/PKG-INFO +199 -0
  18. telethon_cli-0.1.0/src/telethon_cli.egg-info/SOURCES.txt +28 -0
  19. telethon_cli-0.1.0/src/telethon_cli.egg-info/dependency_links.txt +1 -0
  20. telethon_cli-0.1.0/src/telethon_cli.egg-info/entry_points.txt +2 -0
  21. telethon_cli-0.1.0/src/telethon_cli.egg-info/requires.txt +1 -0
  22. telethon_cli-0.1.0/src/telethon_cli.egg-info/top_level.txt +1 -0
  23. telethon_cli-0.1.0/tests/test_app.py +37 -0
  24. telethon_cli-0.1.0/tests/test_command_matrix.py +115 -0
  25. telethon_cli-0.1.0/tests/test_config.py +307 -0
  26. telethon_cli-0.1.0/tests/test_registry.py +46 -0
  27. telethon_cli-0.1.0/tests/test_resolver.py +10 -0
  28. telethon_cli-0.1.0/tests/test_runtime.py +327 -0
  29. telethon_cli-0.1.0/tests/test_serialization.py +11 -0
  30. telethon_cli-0.1.0/tests/test_settings.py +91 -0
@@ -0,0 +1,199 @@
1
+ Metadata-Version: 2.4
2
+ Name: telethon-cli
3
+ Version: 0.1.0
4
+ Summary: Command-line interface for Telethon and Telethon internals
5
+ Author: Axisrow
6
+ License-Expression: MIT
7
+ Project-URL: Homepage, https://github.com/axisrow/telethon-cli
8
+ Project-URL: Repository, https://github.com/axisrow/telethon-cli
9
+ Project-URL: Issues, https://github.com/axisrow/telethon-cli/issues
10
+ Keywords: telegram,telethon,cli,api,automation
11
+ Classifier: Development Status :: 3 - Alpha
12
+ Classifier: Environment :: Console
13
+ Classifier: Intended Audience :: Developers
14
+ Classifier: Operating System :: OS Independent
15
+ Classifier: Programming Language :: Python :: 3
16
+ Classifier: Programming Language :: Python :: 3.8
17
+ Classifier: Programming Language :: Python :: 3.9
18
+ Classifier: Programming Language :: Python :: 3.10
19
+ Classifier: Programming Language :: Python :: 3.11
20
+ Classifier: Programming Language :: Python :: 3.12
21
+ Classifier: Topic :: Communications :: Chat
22
+ Classifier: Topic :: Software Development :: Libraries :: Python Modules
23
+ Classifier: Topic :: Utilities
24
+ Requires-Python: >=3.8
25
+ Description-Content-Type: text/markdown
26
+ Requires-Dist: Telethon>=1
27
+
28
+ # telethon-cli
29
+
30
+ `telethon-cli` is a separate installable package that exposes:
31
+
32
+ - a stable command tree for the public `TelegramClient` API;
33
+ - a generic dispatcher for internal `telethon` and `telethon_generator` callables;
34
+ - env-first client configuration through `TELETHON_API_ID` and `TELETHON_API_HASH`,
35
+ with optional session overrides.
36
+
37
+ ## Installation
38
+
39
+ Install from PyPI:
40
+
41
+ ```bash
42
+ python -m pip install telethon-cli
43
+ ```
44
+
45
+ For local development, install the package in editable mode:
46
+
47
+ ```bash
48
+ python -m pip install -e .
49
+ ```
50
+
51
+ Set the required Telethon credentials before running commands. You can export
52
+ them directly in the shell:
53
+
54
+ ```bash
55
+ export TELETHON_API_ID=...
56
+ export TELETHON_API_HASH=...
57
+ ```
58
+
59
+ You can also keep them in a `.env` file in the current working directory or at
60
+ the project root:
61
+
62
+ ```dotenv
63
+ TELETHON_API_ID=...
64
+ TELETHON_API_HASH=...
65
+ ```
66
+
67
+ On first login, `telethon-cli` can create and store a Telethon session in the
68
+ project automatically. You can create it explicitly:
69
+
70
+ ```bash
71
+ telethon-cli login
72
+ ```
73
+
74
+ Typical first-run flow:
75
+
76
+ ```bash
77
+ python -m pip install -e .
78
+ telethon-cli login
79
+ telethon-cli users get-me --output json
80
+ ```
81
+
82
+ To remove the saved session and force a fresh login next time:
83
+
84
+ ```bash
85
+ telethon-cli logout
86
+ ```
87
+
88
+ Or just run the first command in an interactive terminal and let the CLI ask for
89
+ your phone number, login code, and Telegram 2FA password when needed:
90
+
91
+ ```bash
92
+ telethon-cli users get-me --output json
93
+ ```
94
+
95
+ By default the session is stored in `.telethon-cli/session` under the project
96
+ root. You can override it explicitly:
97
+
98
+ ```bash
99
+ telethon-cli users get-me --session /path/to/session --output json
100
+ telethon-cli users get-me --env-file /path/to/telethon.env --output json
101
+ ```
102
+
103
+ `telethon-cli` reads the current process environment and also loads `.env`
104
+ automatically when present. If the same Telethon setting is defined both in the
105
+ environment and in `.env`, and the values differ, the command exits with an
106
+ error instead of silently choosing one. CLI flags such as `--api-id`,
107
+ `--api-hash`, `--session`, and `--2fa-password` still override both.
108
+
109
+ In non-interactive environments, automatic login is not possible. In that case,
110
+ create the session in advance with `telethon-cli login` and reuse it later.
111
+
112
+ Smoke-test the installation:
113
+
114
+ ```bash
115
+ telethon-cli --help
116
+ python -m telethon_cli registry public --output json
117
+ telethon-cli users get-me --output json
118
+ ```
119
+
120
+ Dangerous features are gated behind project-wide developer mode. Enable it once
121
+ from settings and explicitly confirm the warning before using `call`,
122
+ `registry project`, `$ref`, or `$call` payload helpers:
123
+
124
+ ```bash
125
+ telethon-cli settings developer-mode --enable --accept-dangerous-features
126
+ ```
127
+
128
+ Examples:
129
+
130
+ ```bash
131
+ telethon-cli users get-me --output json
132
+ telethon-cli messages send-message --entity me --message "hello"
133
+ telethon-cli call telethon.utils.parse_phone --args-json '["+1 234 567"]'
134
+ telethon-cli call telethon.tl.functions.help.GetConfigRequest --client-invoke --output json
135
+ telethon-cli settings show --output json
136
+ ```
137
+
138
+ ## Release Process
139
+
140
+ Build and validate release artifacts locally before uploading:
141
+
142
+ ```bash
143
+ rm -rf dist build src/*.egg-info
144
+ python -m pip install --upgrade build twine
145
+ python -m build
146
+ python -m twine check dist/*
147
+ ```
148
+
149
+ Optional local smoke-test from the built wheel:
150
+
151
+ ```bash
152
+ python -m pip install --force-reinstall dist/*.whl
153
+ telethon-cli --help
154
+ python -m telethon_cli registry public --output json
155
+ ```
156
+
157
+ Upload to TestPyPI first:
158
+
159
+ ```bash
160
+ python -m twine upload --repository testpypi dist/*
161
+ ```
162
+
163
+ Verify installation from TestPyPI:
164
+
165
+ ```bash
166
+ python -m pip install --index-url https://test.pypi.org/simple/ --extra-index-url https://pypi.org/simple telethon-cli
167
+ telethon-cli --help
168
+ python -m telethon_cli registry public --output json
169
+ ```
170
+
171
+ Then upload the same artifacts to PyPI:
172
+
173
+ ```bash
174
+ python -m twine upload dist/*
175
+ ```
176
+
177
+ When `twine` prompts for credentials, use username `__token__` and your
178
+ `pypi-...` API token as the password. Keep PyPI tokens out of the repository
179
+ and provide them through the environment or `twine` prompt.
180
+
181
+ For every subsequent release, bump `version` in `pyproject.toml` before
182
+ building. PyPI rejects uploads for versions that already exist.
183
+
184
+ You can also keep PyPI credentials in the project-local `.env` file, because
185
+ `.env` is gitignored in this repository. The release helper script reads `.env`
186
+ automatically and publishes with `twine`:
187
+
188
+ ```dotenv
189
+ TWINE_USERNAME=__token__
190
+ TEST_PYPI_TOKEN=pypi-...
191
+ PYPI_TOKEN=pypi-...
192
+ ```
193
+
194
+ ```bash
195
+ chmod +x scripts/release_pypi.sh
196
+ ./scripts/release_pypi.sh testpypi
197
+ ./scripts/release_pypi.sh pypi
198
+ ./scripts/release_pypi.sh all
199
+ ```
@@ -0,0 +1,172 @@
1
+ # telethon-cli
2
+
3
+ `telethon-cli` is a separate installable package that exposes:
4
+
5
+ - a stable command tree for the public `TelegramClient` API;
6
+ - a generic dispatcher for internal `telethon` and `telethon_generator` callables;
7
+ - env-first client configuration through `TELETHON_API_ID` and `TELETHON_API_HASH`,
8
+ with optional session overrides.
9
+
10
+ ## Installation
11
+
12
+ Install from PyPI:
13
+
14
+ ```bash
15
+ python -m pip install telethon-cli
16
+ ```
17
+
18
+ For local development, install the package in editable mode:
19
+
20
+ ```bash
21
+ python -m pip install -e .
22
+ ```
23
+
24
+ Set the required Telethon credentials before running commands. You can export
25
+ them directly in the shell:
26
+
27
+ ```bash
28
+ export TELETHON_API_ID=...
29
+ export TELETHON_API_HASH=...
30
+ ```
31
+
32
+ You can also keep them in a `.env` file in the current working directory or at
33
+ the project root:
34
+
35
+ ```dotenv
36
+ TELETHON_API_ID=...
37
+ TELETHON_API_HASH=...
38
+ ```
39
+
40
+ On first login, `telethon-cli` can create and store a Telethon session in the
41
+ project automatically. You can create it explicitly:
42
+
43
+ ```bash
44
+ telethon-cli login
45
+ ```
46
+
47
+ Typical first-run flow:
48
+
49
+ ```bash
50
+ python -m pip install -e .
51
+ telethon-cli login
52
+ telethon-cli users get-me --output json
53
+ ```
54
+
55
+ To remove the saved session and force a fresh login next time:
56
+
57
+ ```bash
58
+ telethon-cli logout
59
+ ```
60
+
61
+ Or just run the first command in an interactive terminal and let the CLI ask for
62
+ your phone number, login code, and Telegram 2FA password when needed:
63
+
64
+ ```bash
65
+ telethon-cli users get-me --output json
66
+ ```
67
+
68
+ By default the session is stored in `.telethon-cli/session` under the project
69
+ root. You can override it explicitly:
70
+
71
+ ```bash
72
+ telethon-cli users get-me --session /path/to/session --output json
73
+ telethon-cli users get-me --env-file /path/to/telethon.env --output json
74
+ ```
75
+
76
+ `telethon-cli` reads the current process environment and also loads `.env`
77
+ automatically when present. If the same Telethon setting is defined both in the
78
+ environment and in `.env`, and the values differ, the command exits with an
79
+ error instead of silently choosing one. CLI flags such as `--api-id`,
80
+ `--api-hash`, `--session`, and `--2fa-password` still override both.
81
+
82
+ In non-interactive environments, automatic login is not possible. In that case,
83
+ create the session in advance with `telethon-cli login` and reuse it later.
84
+
85
+ Smoke-test the installation:
86
+
87
+ ```bash
88
+ telethon-cli --help
89
+ python -m telethon_cli registry public --output json
90
+ telethon-cli users get-me --output json
91
+ ```
92
+
93
+ Dangerous features are gated behind project-wide developer mode. Enable it once
94
+ from settings and explicitly confirm the warning before using `call`,
95
+ `registry project`, `$ref`, or `$call` payload helpers:
96
+
97
+ ```bash
98
+ telethon-cli settings developer-mode --enable --accept-dangerous-features
99
+ ```
100
+
101
+ Examples:
102
+
103
+ ```bash
104
+ telethon-cli users get-me --output json
105
+ telethon-cli messages send-message --entity me --message "hello"
106
+ telethon-cli call telethon.utils.parse_phone --args-json '["+1 234 567"]'
107
+ telethon-cli call telethon.tl.functions.help.GetConfigRequest --client-invoke --output json
108
+ telethon-cli settings show --output json
109
+ ```
110
+
111
+ ## Release Process
112
+
113
+ Build and validate release artifacts locally before uploading:
114
+
115
+ ```bash
116
+ rm -rf dist build src/*.egg-info
117
+ python -m pip install --upgrade build twine
118
+ python -m build
119
+ python -m twine check dist/*
120
+ ```
121
+
122
+ Optional local smoke-test from the built wheel:
123
+
124
+ ```bash
125
+ python -m pip install --force-reinstall dist/*.whl
126
+ telethon-cli --help
127
+ python -m telethon_cli registry public --output json
128
+ ```
129
+
130
+ Upload to TestPyPI first:
131
+
132
+ ```bash
133
+ python -m twine upload --repository testpypi dist/*
134
+ ```
135
+
136
+ Verify installation from TestPyPI:
137
+
138
+ ```bash
139
+ python -m pip install --index-url https://test.pypi.org/simple/ --extra-index-url https://pypi.org/simple telethon-cli
140
+ telethon-cli --help
141
+ python -m telethon_cli registry public --output json
142
+ ```
143
+
144
+ Then upload the same artifacts to PyPI:
145
+
146
+ ```bash
147
+ python -m twine upload dist/*
148
+ ```
149
+
150
+ When `twine` prompts for credentials, use username `__token__` and your
151
+ `pypi-...` API token as the password. Keep PyPI tokens out of the repository
152
+ and provide them through the environment or `twine` prompt.
153
+
154
+ For every subsequent release, bump `version` in `pyproject.toml` before
155
+ building. PyPI rejects uploads for versions that already exist.
156
+
157
+ You can also keep PyPI credentials in the project-local `.env` file, because
158
+ `.env` is gitignored in this repository. The release helper script reads `.env`
159
+ automatically and publishes with `twine`:
160
+
161
+ ```dotenv
162
+ TWINE_USERNAME=__token__
163
+ TEST_PYPI_TOKEN=pypi-...
164
+ PYPI_TOKEN=pypi-...
165
+ ```
166
+
167
+ ```bash
168
+ chmod +x scripts/release_pypi.sh
169
+ ./scripts/release_pypi.sh testpypi
170
+ ./scripts/release_pypi.sh pypi
171
+ ./scripts/release_pypi.sh all
172
+ ```
@@ -0,0 +1,47 @@
1
+ [build-system]
2
+ requires = ["setuptools>=68", "wheel"]
3
+ build-backend = "setuptools.build_meta"
4
+
5
+ [project]
6
+ name = "telethon-cli"
7
+ version = "0.1.0"
8
+ description = "Command-line interface for Telethon and Telethon internals"
9
+ readme = "README.md"
10
+ requires-python = ">=3.8"
11
+ license = "MIT"
12
+ authors = [
13
+ {name = "Axisrow"}
14
+ ]
15
+ keywords = ["telegram", "telethon", "cli", "api", "automation"]
16
+ classifiers = [
17
+ "Development Status :: 3 - Alpha",
18
+ "Environment :: Console",
19
+ "Intended Audience :: Developers",
20
+ "Operating System :: OS Independent",
21
+ "Programming Language :: Python :: 3",
22
+ "Programming Language :: Python :: 3.8",
23
+ "Programming Language :: Python :: 3.9",
24
+ "Programming Language :: Python :: 3.10",
25
+ "Programming Language :: Python :: 3.11",
26
+ "Programming Language :: Python :: 3.12",
27
+ "Topic :: Communications :: Chat",
28
+ "Topic :: Software Development :: Libraries :: Python Modules",
29
+ "Topic :: Utilities",
30
+ ]
31
+ dependencies = [
32
+ "Telethon>=1"
33
+ ]
34
+
35
+ [project.urls]
36
+ Homepage = "https://github.com/axisrow/telethon-cli"
37
+ Repository = "https://github.com/axisrow/telethon-cli"
38
+ Issues = "https://github.com/axisrow/telethon-cli/issues"
39
+
40
+ [project.scripts]
41
+ telethon-cli = "telethon_cli.app:main"
42
+
43
+ [tool.setuptools]
44
+ package-dir = {"" = "src"}
45
+
46
+ [tool.setuptools.packages.find]
47
+ where = ["src"]
@@ -0,0 +1,4 @@
1
+ [egg_info]
2
+ tag_build =
3
+ tag_date = 0
4
+
@@ -0,0 +1,3 @@
1
+ from .app import main
2
+
3
+ __all__ = ["main"]
@@ -0,0 +1,5 @@
1
+ from .app import main
2
+
3
+
4
+ if __name__ == "__main__":
5
+ raise SystemExit(main())