python-telegram 0.17.0__tar.gz → 0.19.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.
- python_telegram-0.19.0/.dockerignore +8 -0
- python_telegram-0.19.0/.editorconfig +23 -0
- python_telegram-0.19.0/.github/dependabot.yml +23 -0
- python_telegram-0.19.0/.github/stale.yml +19 -0
- python_telegram-0.19.0/.github/workflows/codeql-analysis.yml +39 -0
- python_telegram-0.19.0/.github/workflows/tests.yml +27 -0
- python_telegram-0.19.0/.gitignore +12 -0
- python_telegram-0.19.0/CONTRIBUTING.md +41 -0
- python_telegram-0.19.0/Dockerfile +5 -0
- python_telegram-0.19.0/LICENSE +21 -0
- {python-telegram-0.17.0 → python_telegram-0.19.0}/MANIFEST.in +2 -0
- python_telegram-0.19.0/Makefile +37 -0
- python_telegram-0.19.0/PKG-INFO +118 -0
- {python-telegram-0.17.0 → python_telegram-0.19.0}/README.md +28 -13
- {python-telegram-0.17.0 → python_telegram-0.19.0}/docs/source/changelog.rst +11 -0
- {python-telegram-0.17.0 → python_telegram-0.19.0}/docs/source/conf.py +49 -44
- {python-telegram-0.17.0 → python_telegram-0.19.0}/docs/source/index.rst +8 -8
- {python-telegram-0.17.0 → python_telegram-0.19.0}/docs/source/proxy.rst +1 -1
- {python-telegram-0.17.0 → python_telegram-0.19.0}/docs/source/tutorial.rst +16 -15
- python_telegram-0.19.0/examples/bot_login.py +28 -0
- python_telegram-0.19.0/examples/chat_stats.py +90 -0
- python_telegram-0.19.0/examples/clear_group_messages.py +132 -0
- python_telegram-0.19.0/examples/echo_bot.py +47 -0
- python_telegram-0.19.0/examples/get_instant_view.py +48 -0
- python_telegram-0.19.0/examples/get_me.py +37 -0
- python_telegram-0.19.0/examples/get_me_non_blocking_login.py +50 -0
- python_telegram-0.19.0/examples/send_message.py +81 -0
- python_telegram-0.19.0/examples/utils.py +50 -0
- python_telegram-0.19.0/pylintrc +106 -0
- python_telegram-0.19.0/pyproject.toml +52 -0
- python_telegram-0.19.0/python_telegram.egg-info/PKG-INFO +118 -0
- {python-telegram-0.17.0 → python_telegram-0.19.0}/python_telegram.egg-info/SOURCES.txt +30 -3
- python_telegram-0.19.0/python_telegram.egg-info/not-zip-safe +1 -0
- python_telegram-0.19.0/python_telegram.egg-info/requires.txt +1 -0
- python_telegram-0.19.0/setup.cfg +4 -0
- {python-telegram-0.17.0 → python_telegram-0.19.0}/telegram/__init__.py +1 -1
- python_telegram-0.19.0/telegram/_version.py +16 -0
- {python-telegram-0.17.0 → python_telegram-0.19.0}/telegram/client.py +158 -159
- {python-telegram-0.17.0 → python_telegram-0.19.0}/telegram/lib/darwin/libtdjson.dylib +0 -0
- {python-telegram-0.17.0 → python_telegram-0.19.0}/telegram/lib/linux/libtdjson.so +0 -0
- python_telegram-0.19.0/telegram/py.typed +0 -0
- {python-telegram-0.17.0 → python_telegram-0.19.0}/telegram/tdjson.py +13 -14
- {python-telegram-0.17.0 → python_telegram-0.19.0}/telegram/text.py +18 -18
- {python-telegram-0.17.0 → python_telegram-0.19.0}/telegram/utils.py +9 -9
- {python-telegram-0.17.0 → python_telegram-0.19.0}/telegram/worker.py +2 -2
- python_telegram-0.19.0/tests/__init__.py +0 -0
- python_telegram-0.19.0/tests/requirements.txt +5 -0
- python_telegram-0.19.0/tests/test_tdjson.py +44 -0
- python_telegram-0.19.0/tests/test_telegram_methods.py +480 -0
- python_telegram-0.19.0/tests/test_utils.py +111 -0
- python_telegram-0.19.0/tox.ini +38 -0
- python-telegram-0.17.0/CONTRIBUTING.md +0 -44
- python-telegram-0.17.0/PKG-INFO +0 -88
- python-telegram-0.17.0/pyproject.toml +0 -8
- python-telegram-0.17.0/python_telegram.egg-info/PKG-INFO +0 -88
- python-telegram-0.17.0/python_telegram.egg-info/requires.txt +0 -1
- python-telegram-0.17.0/setup.cfg +0 -10
- python-telegram-0.17.0/setup.py +0 -40
- {python-telegram-0.17.0 → python_telegram-0.19.0}/docs/Makefile +0 -0
- {python-telegram-0.17.0 → python_telegram-0.19.0}/docs/requirements.txt +0 -0
- {python-telegram-0.17.0 → python_telegram-0.19.0}/docs/source/_templates/about.html +0 -0
- {python-telegram-0.17.0 → python_telegram-0.19.0}/docs/source/_templates/navigation.html +0 -0
- {python-telegram-0.17.0 → python_telegram-0.19.0}/docs/source/modules.rst +0 -0
- {python-telegram-0.17.0 → python_telegram-0.19.0}/docs/source/non_blocking_login.rst +0 -0
- {python-telegram-0.17.0 → python_telegram-0.19.0}/docs/source/tdlib.rst +0 -0
- {python-telegram-0.17.0 → python_telegram-0.19.0}/docs/source/telegram.rst +0 -0
- {python-telegram-0.17.0 → python_telegram-0.19.0}/python_telegram.egg-info/dependency_links.txt +0 -0
- {python-telegram-0.17.0 → python_telegram-0.19.0}/python_telegram.egg-info/top_level.txt +0 -0
|
@@ -0,0 +1,23 @@
|
|
|
1
|
+
# EditorConfig is awesome: http://EditorConfig.org
|
|
2
|
+
|
|
3
|
+
# top-most EditorConfig file
|
|
4
|
+
root = true
|
|
5
|
+
|
|
6
|
+
# Unix-style newlines with a newline ending every file
|
|
7
|
+
[*]
|
|
8
|
+
end_of_line = lf
|
|
9
|
+
insert_final_newline = true
|
|
10
|
+
|
|
11
|
+
[*.py]
|
|
12
|
+
charset = utf-8
|
|
13
|
+
indent_style = space
|
|
14
|
+
indent_size = 4
|
|
15
|
+
line_length=80
|
|
16
|
+
multi_line_output=3
|
|
17
|
+
include_trailing_comma=True
|
|
18
|
+
length_sort=1
|
|
19
|
+
|
|
20
|
+
|
|
21
|
+
# Tab indentation (no size specified)
|
|
22
|
+
[Makefile]
|
|
23
|
+
indent_style = tab
|
|
@@ -0,0 +1,23 @@
|
|
|
1
|
+
version: 2
|
|
2
|
+
updates:
|
|
3
|
+
- package-ecosystem: pip
|
|
4
|
+
directory: /
|
|
5
|
+
schedule:
|
|
6
|
+
interval: daily
|
|
7
|
+
open-pull-requests-limit: 10
|
|
8
|
+
reviewers:
|
|
9
|
+
- alexander-akhmetov
|
|
10
|
+
assignees:
|
|
11
|
+
- alexander-akhmetov
|
|
12
|
+
ignore:
|
|
13
|
+
- dependency-name: ipdb
|
|
14
|
+
versions:
|
|
15
|
+
- 0.13.5
|
|
16
|
+
- 0.13.6
|
|
17
|
+
- dependency-name: mypy
|
|
18
|
+
versions:
|
|
19
|
+
- '0.812'
|
|
20
|
+
- package-ecosystem: github-actions
|
|
21
|
+
directory: /
|
|
22
|
+
schedule:
|
|
23
|
+
interval: daily
|
|
@@ -0,0 +1,19 @@
|
|
|
1
|
+
daysUntilStale: 180
|
|
2
|
+
daysUntilClose: 30
|
|
3
|
+
exemptLabels:
|
|
4
|
+
- pinned
|
|
5
|
+
- security
|
|
6
|
+
- bug
|
|
7
|
+
- dependencies
|
|
8
|
+
- help wanted
|
|
9
|
+
- good first issue
|
|
10
|
+
- enhancement
|
|
11
|
+
|
|
12
|
+
staleLabel: stale
|
|
13
|
+
|
|
14
|
+
markComment: >
|
|
15
|
+
This issue has been automatically marked as stale because it has not had
|
|
16
|
+
recent activity. It will be closed if no further activity occurs. Thank you
|
|
17
|
+
for your contributions.
|
|
18
|
+
|
|
19
|
+
closeComment: false
|
|
@@ -0,0 +1,39 @@
|
|
|
1
|
+
name: "CodeQL"
|
|
2
|
+
|
|
3
|
+
on:
|
|
4
|
+
push:
|
|
5
|
+
branches: [ master ]
|
|
6
|
+
pull_request:
|
|
7
|
+
# The branches below must be a subset of the branches above
|
|
8
|
+
branches: [ master ]
|
|
9
|
+
schedule:
|
|
10
|
+
- cron: '33 11 * * 1'
|
|
11
|
+
|
|
12
|
+
jobs:
|
|
13
|
+
analyze:
|
|
14
|
+
name: Analyze
|
|
15
|
+
runs-on: ubuntu-latest
|
|
16
|
+
permissions:
|
|
17
|
+
actions: read
|
|
18
|
+
contents: read
|
|
19
|
+
security-events: write
|
|
20
|
+
|
|
21
|
+
strategy:
|
|
22
|
+
fail-fast: false
|
|
23
|
+
matrix:
|
|
24
|
+
language: [ 'python' ]
|
|
25
|
+
|
|
26
|
+
steps:
|
|
27
|
+
- name: Checkout repository
|
|
28
|
+
uses: actions/checkout@v4
|
|
29
|
+
|
|
30
|
+
- name: Initialize CodeQL
|
|
31
|
+
uses: github/codeql-action/init@v3
|
|
32
|
+
with:
|
|
33
|
+
languages: ${{ matrix.language }}
|
|
34
|
+
|
|
35
|
+
- name: Autobuild
|
|
36
|
+
uses: github/codeql-action/autobuild@v3
|
|
37
|
+
|
|
38
|
+
- name: Perform CodeQL Analysis
|
|
39
|
+
uses: github/codeql-action/analyze@v3
|
|
@@ -0,0 +1,27 @@
|
|
|
1
|
+
name: python-telegram tests
|
|
2
|
+
|
|
3
|
+
on: [push, pull_request]
|
|
4
|
+
|
|
5
|
+
jobs:
|
|
6
|
+
tests:
|
|
7
|
+
runs-on: ubuntu-latest
|
|
8
|
+
strategy:
|
|
9
|
+
max-parallel: 4
|
|
10
|
+
matrix:
|
|
11
|
+
python-version: ["3.9", "3.10", "3.11", "3.12"]
|
|
12
|
+
|
|
13
|
+
steps:
|
|
14
|
+
- uses: actions/checkout@v4
|
|
15
|
+
|
|
16
|
+
- name: Set up python ${{ matrix.python-version }}
|
|
17
|
+
uses: actions/setup-python@v5.1.0
|
|
18
|
+
with:
|
|
19
|
+
python-version: ${{ matrix.python-version }}
|
|
20
|
+
|
|
21
|
+
- name: Install dependencies
|
|
22
|
+
run: |
|
|
23
|
+
python -m pip install --upgrade pip
|
|
24
|
+
pip install tox tox-gh-actions
|
|
25
|
+
|
|
26
|
+
- name: Tests
|
|
27
|
+
run: tox
|
|
@@ -0,0 +1,41 @@
|
|
|
1
|
+
# Contributing
|
|
2
|
+
|
|
3
|
+
Pull requests are welcome!
|
|
4
|
+
|
|
5
|
+
Feel free to open an issue if you find a bug, have new ideas, suggestions,
|
|
6
|
+
or spot a mistake in the [documentation](https://python-telegram.readthedocs.io/en/latest/).
|
|
7
|
+
|
|
8
|
+
## Reporting bugs
|
|
9
|
+
|
|
10
|
+
We use [GitHub
|
|
11
|
+
Issues](https://github.com/alexander-akhmetov/python-telegram/issues) to track
|
|
12
|
+
bugs. If you find a bug, please open a new issue.
|
|
13
|
+
|
|
14
|
+
Try to include steps to reproduce the bug, a detailed description, and some sample code if possible.
|
|
15
|
+
|
|
16
|
+
## Pull request process
|
|
17
|
+
|
|
18
|
+
1. Fork the repository and create a new branch from `master`.
|
|
19
|
+
2. Make your changes and don't forget to add new tests :)
|
|
20
|
+
3. Ensure the tests pass with your changes.
|
|
21
|
+
4. Create a new PR!
|
|
22
|
+
|
|
23
|
+
## Coding style
|
|
24
|
+
|
|
25
|
+
The project uses [ruff](https://docs.astral.sh/ruff/) as an autoformatter and linter.
|
|
26
|
+
|
|
27
|
+
## Tests
|
|
28
|
+
|
|
29
|
+
To run tests you need to install [tox](https://tox.readthedocs.io/en/latest/).
|
|
30
|
+
|
|
31
|
+
Run tests:
|
|
32
|
+
|
|
33
|
+
```shell
|
|
34
|
+
tox
|
|
35
|
+
```
|
|
36
|
+
|
|
37
|
+
Run a specific test using python 3.12:
|
|
38
|
+
|
|
39
|
+
```shell
|
|
40
|
+
tox -e py312 -- -k test_add_message_handler
|
|
41
|
+
```
|
|
@@ -0,0 +1,21 @@
|
|
|
1
|
+
MIT License
|
|
2
|
+
|
|
3
|
+
Copyright (c) 2018 Alexander Akhmetov
|
|
4
|
+
|
|
5
|
+
Permission is hereby granted, free of charge, to any person obtaining a copy
|
|
6
|
+
of this software and associated documentation files (the "Software"), to deal
|
|
7
|
+
in the Software without restriction, including without limitation the rights
|
|
8
|
+
to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
|
|
9
|
+
copies of the Software, and to permit persons to whom the Software is
|
|
10
|
+
furnished to do so, subject to the following conditions:
|
|
11
|
+
|
|
12
|
+
The above copyright notice and this permission notice shall be included in all
|
|
13
|
+
copies or substantial portions of the Software.
|
|
14
|
+
|
|
15
|
+
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
|
|
16
|
+
IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
|
|
17
|
+
FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
|
|
18
|
+
AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
|
|
19
|
+
LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
|
|
20
|
+
OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
|
|
21
|
+
SOFTWARE.
|
|
@@ -0,0 +1,37 @@
|
|
|
1
|
+
.PHONY: docker/build
|
|
2
|
+
docker/build:
|
|
3
|
+
docker build -f Dockerfile . -t akhmetov/python-telegram
|
|
4
|
+
|
|
5
|
+
.PHONY: docker/send-message
|
|
6
|
+
docker/send-message:
|
|
7
|
+
docker run -i -t \
|
|
8
|
+
-v /tmp/docker-python-telegram/:/tmp/ \
|
|
9
|
+
akhmetov/python-telegram \
|
|
10
|
+
python3 /app/examples/send_message.py $(API_ID) $(API_HASH) $(PHONE) $(CHAT_ID) $(TEXT)
|
|
11
|
+
|
|
12
|
+
.PHONY: docker/echo-bot
|
|
13
|
+
docker/echo-bot:
|
|
14
|
+
docker run -i -t \
|
|
15
|
+
-v /tmp/docker-python-telegram/:/tmp/ \
|
|
16
|
+
akhmetov/python-telegram \
|
|
17
|
+
python3 /app/examples/echo_bot.py $(API_ID) $(API_HASH) $(PHONE)
|
|
18
|
+
|
|
19
|
+
.PHONY: docker/get-instant-view
|
|
20
|
+
docker/get-instant-view:
|
|
21
|
+
docker run -i -t \
|
|
22
|
+
-v /tmp/docker-python-telegram/:/tmp/ \
|
|
23
|
+
akhmetov/python-telegram \
|
|
24
|
+
python3 /app/examples/echo_bot.py $(API_ID) $(API_HASH) $(PHONE)
|
|
25
|
+
|
|
26
|
+
|
|
27
|
+
.PHONY: clean
|
|
28
|
+
clean:
|
|
29
|
+
rm -rf dist
|
|
30
|
+
|
|
31
|
+
.PHONY: build-pypi
|
|
32
|
+
build-pypi: clean
|
|
33
|
+
python3 -m build
|
|
34
|
+
|
|
35
|
+
.PHONY: release-pypi
|
|
36
|
+
release-pypi:build-pypi
|
|
37
|
+
twine upload dist/*
|
|
@@ -0,0 +1,118 @@
|
|
|
1
|
+
Metadata-Version: 2.1
|
|
2
|
+
Name: python-telegram
|
|
3
|
+
Version: 0.19.0
|
|
4
|
+
Summary: Python library to help you build your own Telegram clients
|
|
5
|
+
Author-email: Alexander Akhmetov <me@alx.cx>
|
|
6
|
+
License: MIT
|
|
7
|
+
Project-URL: Source, https://github.com/alexander-akhmetov/python-telegram
|
|
8
|
+
Project-URL: Documentation, https://python-telegram.readthedocs.io/en/latest/
|
|
9
|
+
Project-URL: Tutorial, https://python-telegram.readthedocs.io/en/latest/tutorial.html
|
|
10
|
+
Project-URL: Changelog, https://python-telegram.readthedocs.io/en/latest/changelog.html
|
|
11
|
+
Keywords: telegram,client,api,tdlib,tdjson,td
|
|
12
|
+
Classifier: Intended Audience :: Developers
|
|
13
|
+
Classifier: License :: OSI Approved :: MIT License
|
|
14
|
+
Classifier: Operating System :: MacOS :: MacOS X
|
|
15
|
+
Classifier: Operating System :: POSIX :: Linux
|
|
16
|
+
Classifier: Programming Language :: Python :: 3.9
|
|
17
|
+
Classifier: Programming Language :: Python :: 3.10
|
|
18
|
+
Classifier: Programming Language :: Python :: 3.11
|
|
19
|
+
Classifier: Programming Language :: Python :: 3.12
|
|
20
|
+
Classifier: Programming Language :: Python :: 3 :: Only
|
|
21
|
+
Classifier: Topic :: Software Development :: Libraries :: Python Modules
|
|
22
|
+
Requires-Python: >=3.9
|
|
23
|
+
Description-Content-Type: text/markdown
|
|
24
|
+
License-File: LICENSE
|
|
25
|
+
Requires-Dist: telegram-text==0.2.0
|
|
26
|
+
|
|
27
|
+
# python-telegram
|
|
28
|
+
|
|
29
|
+
[](https://github.com/alexander-akhmetov/python-telegram/actions)
|
|
30
|
+
[](https://pypi.python.org/pypi/python-telegram)
|
|
31
|
+
[](https://hub.docker.com/r/akhmetov/python-telegram/)
|
|
32
|
+

|
|
33
|
+
|
|
34
|
+
Python API for the [tdlib](https://github.com/tdlib/td) library.
|
|
35
|
+
It helps you build your own Telegram clients.
|
|
36
|
+
|
|
37
|
+
- [Changelog](https://python-telegram.readthedocs.io/en/latest/changelog.html)
|
|
38
|
+
- [Documentation](http://python-telegram.readthedocs.io)
|
|
39
|
+
- [Tutorial](http://python-telegram.readthedocs.io/en/latest/tutorial.html)
|
|
40
|
+
|
|
41
|
+
## Installation
|
|
42
|
+
|
|
43
|
+
This library requires Python 3.9+ and Linux or MacOS. Windows is not supported.
|
|
44
|
+
|
|
45
|
+
```shell
|
|
46
|
+
pip install python-telegram
|
|
47
|
+
```
|
|
48
|
+
|
|
49
|
+
See [documentation](http://python-telegram.readthedocs.io/en/latest/#installation) for more details.
|
|
50
|
+
|
|
51
|
+
### tdlib
|
|
52
|
+
|
|
53
|
+
`python-telegram` comes with a precompiled `tdlib` library for Linux and MacOS. But it is highly recommended to [compile](https://tdlib.github.io/td/build.html) it yourself.
|
|
54
|
+
The precompiled library may not work on some systems, it is dynamically linked and requires specific versions of additional libraries.
|
|
55
|
+
|
|
56
|
+
```shell
|
|
57
|
+
|
|
58
|
+
### Docker
|
|
59
|
+
|
|
60
|
+
This library has a [docker image](https://hub.docker.com/r/akhmetov/python-telegram/):
|
|
61
|
+
|
|
62
|
+
```sh
|
|
63
|
+
docker run -i -t --rm \
|
|
64
|
+
-v /tmp/docker-python-telegram/:/tmp/ \
|
|
65
|
+
akhmetov/python-telegram \
|
|
66
|
+
python3 /app/examples/send_message.py $(API_ID) $(API_HASH) $(PHONE) $(CHAT_ID) $(TEXT)
|
|
67
|
+
```
|
|
68
|
+
|
|
69
|
+
## How to use the library
|
|
70
|
+
|
|
71
|
+
Check out the [tutorial](http://python-telegram.readthedocs.io/en/latest/tutorial.html) for more details.
|
|
72
|
+
|
|
73
|
+
Basic example:
|
|
74
|
+
|
|
75
|
+
```python
|
|
76
|
+
from telegram.client import Telegram
|
|
77
|
+
from telegram.text import Spoiler
|
|
78
|
+
|
|
79
|
+
tg = Telegram(
|
|
80
|
+
api_id='api_id',
|
|
81
|
+
api_hash='api_hash',
|
|
82
|
+
phone='+31611111111', # you can pass 'bot_token' instead
|
|
83
|
+
database_encryption_key='changekey123',
|
|
84
|
+
files_directory='/tmp/.tdlib_files/',
|
|
85
|
+
)
|
|
86
|
+
tg.login()
|
|
87
|
+
|
|
88
|
+
# If this is the first run, the library needs to preload all chats.
|
|
89
|
+
# Otherwise, the message will not be sent.
|
|
90
|
+
result = tg.get_chats()
|
|
91
|
+
result.wait()
|
|
92
|
+
|
|
93
|
+
chat_id: int
|
|
94
|
+
result = tg.send_message(chat_id, Spoiler('Hello world!'))
|
|
95
|
+
|
|
96
|
+
# `tdlib` is asynchronous, so `python-telegram` always returns an `AsyncResult` object.
|
|
97
|
+
# You can receive a result with the `wait` method of this object.
|
|
98
|
+
result.wait()
|
|
99
|
+
print(result.update)
|
|
100
|
+
|
|
101
|
+
tg.stop() # You must call `stop` at the end of the script.
|
|
102
|
+
```
|
|
103
|
+
|
|
104
|
+
You can also use `call_method` to call any [tdlib method](https://core.telegram.org/tdlib/docs/classtd_1_1td__api_1_1_function.html):
|
|
105
|
+
|
|
106
|
+
``` python
|
|
107
|
+
tg.call_method('getUser', params={'user_id': user_id})
|
|
108
|
+
```
|
|
109
|
+
|
|
110
|
+
More examples can be found in the [/examples/ directory](/examples/).
|
|
111
|
+
|
|
112
|
+
---
|
|
113
|
+
|
|
114
|
+
More information is available in the [documentation](http://python-telegram.readthedocs.io).
|
|
115
|
+
|
|
116
|
+
## Development
|
|
117
|
+
|
|
118
|
+
See [CONTRIBUTING.md](/CONTRIBUTING.md).
|
|
@@ -8,13 +8,13 @@
|
|
|
8
8
|
Python API for the [tdlib](https://github.com/tdlib/td) library.
|
|
9
9
|
It helps you build your own Telegram clients.
|
|
10
10
|
|
|
11
|
-
|
|
12
|
-
|
|
13
|
-
|
|
11
|
+
- [Changelog](https://python-telegram.readthedocs.io/en/latest/changelog.html)
|
|
12
|
+
- [Documentation](http://python-telegram.readthedocs.io)
|
|
13
|
+
- [Tutorial](http://python-telegram.readthedocs.io/en/latest/tutorial.html)
|
|
14
14
|
|
|
15
15
|
## Installation
|
|
16
16
|
|
|
17
|
-
This library requires Python 3.
|
|
17
|
+
This library requires Python 3.9+ and Linux or MacOS. Windows is not supported.
|
|
18
18
|
|
|
19
19
|
```shell
|
|
20
20
|
pip install python-telegram
|
|
@@ -22,6 +22,13 @@ pip install python-telegram
|
|
|
22
22
|
|
|
23
23
|
See [documentation](http://python-telegram.readthedocs.io/en/latest/#installation) for more details.
|
|
24
24
|
|
|
25
|
+
### tdlib
|
|
26
|
+
|
|
27
|
+
`python-telegram` comes with a precompiled `tdlib` library for Linux and MacOS. But it is highly recommended to [compile](https://tdlib.github.io/td/build.html) it yourself.
|
|
28
|
+
The precompiled library may not work on some systems, it is dynamically linked and requires specific versions of additional libraries.
|
|
29
|
+
|
|
30
|
+
```shell
|
|
31
|
+
|
|
25
32
|
### Docker
|
|
26
33
|
|
|
27
34
|
This library has a [docker image](https://hub.docker.com/r/akhmetov/python-telegram/):
|
|
@@ -33,11 +40,12 @@ docker run -i -t --rm \
|
|
|
33
40
|
python3 /app/examples/send_message.py $(API_ID) $(API_HASH) $(PHONE) $(CHAT_ID) $(TEXT)
|
|
34
41
|
```
|
|
35
42
|
|
|
36
|
-
## How to use
|
|
43
|
+
## How to use the library
|
|
37
44
|
|
|
38
|
-
|
|
45
|
+
Check out the [tutorial](http://python-telegram.readthedocs.io/en/latest/tutorial.html) for more details.
|
|
39
46
|
|
|
40
47
|
Basic example:
|
|
48
|
+
|
|
41
49
|
```python
|
|
42
50
|
from telegram.client import Telegram
|
|
43
51
|
from telegram.text import Spoiler
|
|
@@ -51,26 +59,33 @@ tg = Telegram(
|
|
|
51
59
|
)
|
|
52
60
|
tg.login()
|
|
53
61
|
|
|
54
|
-
#
|
|
55
|
-
#
|
|
62
|
+
# If this is the first run, the library needs to preload all chats.
|
|
63
|
+
# Otherwise, the message will not be sent.
|
|
56
64
|
result = tg.get_chats()
|
|
57
65
|
result.wait()
|
|
58
66
|
|
|
59
67
|
chat_id: int
|
|
60
68
|
result = tg.send_message(chat_id, Spoiler('Hello world!'))
|
|
61
|
-
|
|
69
|
+
|
|
70
|
+
# `tdlib` is asynchronous, so `python-telegram` always returns an `AsyncResult` object.
|
|
62
71
|
# You can receive a result with the `wait` method of this object.
|
|
63
72
|
result.wait()
|
|
64
73
|
print(result.update)
|
|
65
74
|
|
|
66
|
-
tg.stop() #
|
|
75
|
+
tg.stop() # You must call `stop` at the end of the script.
|
|
76
|
+
```
|
|
77
|
+
|
|
78
|
+
You can also use `call_method` to call any [tdlib method](https://core.telegram.org/tdlib/docs/classtd_1_1td__api_1_1_function.html):
|
|
79
|
+
|
|
80
|
+
``` python
|
|
81
|
+
tg.call_method('getUser', params={'user_id': user_id})
|
|
67
82
|
```
|
|
68
83
|
|
|
69
|
-
More examples
|
|
84
|
+
More examples can be found in the [/examples/ directory](/examples/).
|
|
70
85
|
|
|
71
|
-
|
|
86
|
+
---
|
|
72
87
|
|
|
73
|
-
More information in the [documentation](http://python-telegram.readthedocs.io).
|
|
88
|
+
More information is available in the [documentation](http://python-telegram.readthedocs.io).
|
|
74
89
|
|
|
75
90
|
## Development
|
|
76
91
|
|
|
@@ -2,6 +2,17 @@
|
|
|
2
2
|
Changelog
|
|
3
3
|
=========
|
|
4
4
|
|
|
5
|
+
[unreleased]
|
|
6
|
+
|
|
7
|
+
[0.19.0] 2024-06-23
|
|
8
|
+
|
|
9
|
+
- Python versions 3.7 and 3.8 are no longer supported.
|
|
10
|
+
- tdlib 1.8.31.
|
|
11
|
+
|
|
12
|
+
[0.18.0] - 2023-03-13
|
|
13
|
+
|
|
14
|
+
- Added support for tdlib > 1.8.5. (thanks to @JleMyP)
|
|
15
|
+
|
|
5
16
|
[0.17.0] - 2023-01-25
|
|
6
17
|
|
|
7
18
|
- Added ``import_contacts`` method. (thanks to @vlad-lf)
|