python-telegram 0.18.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.18.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.18.0/python_telegram.egg-info/PKG-INFO → python_telegram-0.19.0/README.md +28 -23
- {python-telegram-0.18.0 → python_telegram-0.19.0}/docs/source/changelog.rst +7 -0
- {python-telegram-0.18.0 → python_telegram-0.19.0}/docs/source/conf.py +49 -44
- {python-telegram-0.18.0 → python_telegram-0.19.0}/docs/source/index.rst +8 -8
- {python-telegram-0.18.0 → python_telegram-0.19.0}/docs/source/proxy.rst +1 -1
- {python-telegram-0.18.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.18.0 → python_telegram-0.19.0}/python_telegram.egg-info/SOURCES.txt +29 -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.18.0 → python_telegram-0.19.0}/telegram/__init__.py +1 -1
- python_telegram-0.19.0/telegram/_version.py +16 -0
- {python-telegram-0.18.0 → python_telegram-0.19.0}/telegram/client.py +148 -152
- {python-telegram-0.18.0 → python_telegram-0.19.0}/telegram/lib/darwin/libtdjson.dylib +0 -0
- {python-telegram-0.18.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.18.0 → python_telegram-0.19.0}/telegram/tdjson.py +13 -14
- {python-telegram-0.18.0 → python_telegram-0.19.0}/telegram/text.py +18 -18
- {python-telegram-0.18.0 → python_telegram-0.19.0}/telegram/utils.py +9 -9
- {python-telegram-0.18.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.18.0/CONTRIBUTING.md +0 -44
- python-telegram-0.18.0/PKG-INFO +0 -87
- python-telegram-0.18.0/README.md +0 -77
- python-telegram-0.18.0/pyproject.toml +0 -8
- python-telegram-0.18.0/python_telegram.egg-info/requires.txt +0 -1
- python-telegram-0.18.0/setup.cfg +0 -10
- python-telegram-0.18.0/setup.py +0 -40
- {python-telegram-0.18.0 → python_telegram-0.19.0}/LICENSE +0 -0
- {python-telegram-0.18.0 → python_telegram-0.19.0}/docs/Makefile +0 -0
- {python-telegram-0.18.0 → python_telegram-0.19.0}/docs/requirements.txt +0 -0
- {python-telegram-0.18.0 → python_telegram-0.19.0}/docs/source/_templates/about.html +0 -0
- {python-telegram-0.18.0 → python_telegram-0.19.0}/docs/source/_templates/navigation.html +0 -0
- {python-telegram-0.18.0 → python_telegram-0.19.0}/docs/source/modules.rst +0 -0
- {python-telegram-0.18.0 → python_telegram-0.19.0}/docs/source/non_blocking_login.rst +0 -0
- {python-telegram-0.18.0 → python_telegram-0.19.0}/docs/source/tdlib.rst +0 -0
- {python-telegram-0.18.0 → python_telegram-0.19.0}/docs/source/telegram.rst +0 -0
- {python-telegram-0.18.0 → python_telegram-0.19.0}/python_telegram.egg-info/dependency_links.txt +0 -0
- {python-telegram-0.18.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,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).
|
|
@@ -1,13 +1,3 @@
|
|
|
1
|
-
Metadata-Version: 2.1
|
|
2
|
-
Name: python-telegram
|
|
3
|
-
Version: 0.18.0
|
|
4
|
-
Summary: Python library to help you build your own Telegram clients
|
|
5
|
-
Home-page: https://github.com/alexander-akhmetov/python-telegram
|
|
6
|
-
Author: Alexander Akhmetov
|
|
7
|
-
Author-email: me@aleks.sh
|
|
8
|
-
Description-Content-Type: text/markdown
|
|
9
|
-
License-File: LICENSE
|
|
10
|
-
|
|
11
1
|
# python-telegram
|
|
12
2
|
|
|
13
3
|
[](https://github.com/alexander-akhmetov/python-telegram/actions)
|
|
@@ -18,13 +8,13 @@ License-File: LICENSE
|
|
|
18
8
|
Python API for the [tdlib](https://github.com/tdlib/td) library.
|
|
19
9
|
It helps you build your own Telegram clients.
|
|
20
10
|
|
|
21
|
-
|
|
22
|
-
|
|
23
|
-
|
|
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)
|
|
24
14
|
|
|
25
15
|
## Installation
|
|
26
16
|
|
|
27
|
-
This library requires Python 3.
|
|
17
|
+
This library requires Python 3.9+ and Linux or MacOS. Windows is not supported.
|
|
28
18
|
|
|
29
19
|
```shell
|
|
30
20
|
pip install python-telegram
|
|
@@ -32,6 +22,13 @@ pip install python-telegram
|
|
|
32
22
|
|
|
33
23
|
See [documentation](http://python-telegram.readthedocs.io/en/latest/#installation) for more details.
|
|
34
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
|
+
|
|
35
32
|
### Docker
|
|
36
33
|
|
|
37
34
|
This library has a [docker image](https://hub.docker.com/r/akhmetov/python-telegram/):
|
|
@@ -43,11 +40,12 @@ docker run -i -t --rm \
|
|
|
43
40
|
python3 /app/examples/send_message.py $(API_ID) $(API_HASH) $(PHONE) $(CHAT_ID) $(TEXT)
|
|
44
41
|
```
|
|
45
42
|
|
|
46
|
-
## How to use
|
|
43
|
+
## How to use the library
|
|
47
44
|
|
|
48
|
-
|
|
45
|
+
Check out the [tutorial](http://python-telegram.readthedocs.io/en/latest/tutorial.html) for more details.
|
|
49
46
|
|
|
50
47
|
Basic example:
|
|
48
|
+
|
|
51
49
|
```python
|
|
52
50
|
from telegram.client import Telegram
|
|
53
51
|
from telegram.text import Spoiler
|
|
@@ -61,26 +59,33 @@ tg = Telegram(
|
|
|
61
59
|
)
|
|
62
60
|
tg.login()
|
|
63
61
|
|
|
64
|
-
#
|
|
65
|
-
#
|
|
62
|
+
# If this is the first run, the library needs to preload all chats.
|
|
63
|
+
# Otherwise, the message will not be sent.
|
|
66
64
|
result = tg.get_chats()
|
|
67
65
|
result.wait()
|
|
68
66
|
|
|
69
67
|
chat_id: int
|
|
70
68
|
result = tg.send_message(chat_id, Spoiler('Hello world!'))
|
|
71
|
-
|
|
69
|
+
|
|
70
|
+
# `tdlib` is asynchronous, so `python-telegram` always returns an `AsyncResult` object.
|
|
72
71
|
# You can receive a result with the `wait` method of this object.
|
|
73
72
|
result.wait()
|
|
74
73
|
print(result.update)
|
|
75
74
|
|
|
76
|
-
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})
|
|
77
82
|
```
|
|
78
83
|
|
|
79
|
-
More examples
|
|
84
|
+
More examples can be found in the [/examples/ directory](/examples/).
|
|
80
85
|
|
|
81
|
-
|
|
86
|
+
---
|
|
82
87
|
|
|
83
|
-
More information in the [documentation](http://python-telegram.readthedocs.io).
|
|
88
|
+
More information is available in the [documentation](http://python-telegram.readthedocs.io).
|
|
84
89
|
|
|
85
90
|
## Development
|
|
86
91
|
|
|
@@ -14,21 +14,22 @@
|
|
|
14
14
|
#
|
|
15
15
|
import os
|
|
16
16
|
import sys
|
|
17
|
-
|
|
17
|
+
|
|
18
|
+
sys.path.insert(0, os.path.abspath("../.."))
|
|
18
19
|
|
|
19
20
|
|
|
20
21
|
# -- Project information -----------------------------------------------------
|
|
21
22
|
|
|
22
|
-
project =
|
|
23
|
-
copyright =
|
|
24
|
-
author =
|
|
23
|
+
project = "python-telegram"
|
|
24
|
+
copyright = "2018, Alexander Akhmetov"
|
|
25
|
+
author = "Alexander Akhmetov"
|
|
25
26
|
|
|
26
27
|
html_show_sourcelink = False
|
|
27
28
|
|
|
28
29
|
# The short X.Y version
|
|
29
|
-
version =
|
|
30
|
+
version = ""
|
|
30
31
|
# The full version, including alpha/beta/rc tags
|
|
31
|
-
release =
|
|
32
|
+
release = ""
|
|
32
33
|
|
|
33
34
|
|
|
34
35
|
# -- General configuration ---------------------------------------------------
|
|
@@ -41,20 +42,20 @@ release = ''
|
|
|
41
42
|
# extensions coming with Sphinx (named 'sphinx.ext.*') or your custom
|
|
42
43
|
# ones.
|
|
43
44
|
extensions = [
|
|
44
|
-
|
|
45
|
+
"sphinx.ext.autodoc",
|
|
45
46
|
]
|
|
46
47
|
|
|
47
48
|
# Add any paths that contain templates here, relative to this directory.
|
|
48
|
-
templates_path = [
|
|
49
|
+
templates_path = ["_templates"]
|
|
49
50
|
|
|
50
51
|
# The suffix(es) of source filenames.
|
|
51
52
|
# You can specify multiple suffix as a list of string:
|
|
52
53
|
#
|
|
53
54
|
# source_suffix = ['.rst', '.md']
|
|
54
|
-
source_suffix =
|
|
55
|
+
source_suffix = ".rst"
|
|
55
56
|
|
|
56
57
|
# The master toctree document.
|
|
57
|
-
master_doc =
|
|
58
|
+
master_doc = "index"
|
|
58
59
|
|
|
59
60
|
# The language for content autogenerated by Sphinx. Refer to documentation
|
|
60
61
|
# for a list of supported languages.
|
|
@@ -69,7 +70,7 @@ language = None
|
|
|
69
70
|
exclude_patterns = []
|
|
70
71
|
|
|
71
72
|
# The name of the Pygments (syntax highlighting) style to use.
|
|
72
|
-
pygments_style =
|
|
73
|
+
pygments_style = "sphinx"
|
|
73
74
|
|
|
74
75
|
|
|
75
76
|
# -- Options for HTML output -------------------------------------------------
|
|
@@ -77,32 +78,32 @@ pygments_style = 'sphinx'
|
|
|
77
78
|
# The theme to use for HTML and HTML Help pages. See the documentation for
|
|
78
79
|
# a list of builtin themes.
|
|
79
80
|
#
|
|
80
|
-
html_theme =
|
|
81
|
+
html_theme = "alabaster"
|
|
81
82
|
|
|
82
83
|
# Theme options are theme-specific and customize the look and feel of a theme
|
|
83
84
|
# further. For a list of options available for each theme, see the
|
|
84
85
|
# documentation.
|
|
85
86
|
#
|
|
86
87
|
html_theme_options = {
|
|
87
|
-
|
|
88
|
-
|
|
89
|
-
|
|
90
|
-
|
|
91
|
-
|
|
92
|
-
|
|
93
|
-
|
|
94
|
-
|
|
95
|
-
|
|
96
|
-
|
|
97
|
-
|
|
98
|
-
|
|
99
|
-
}
|
|
88
|
+
"logo_name": "123",
|
|
89
|
+
"github_user": "alexander-akhmetov",
|
|
90
|
+
"github_repo": "python-telegram",
|
|
91
|
+
"github_button": True,
|
|
92
|
+
"github_type": "star",
|
|
93
|
+
"extra_nav_links": {
|
|
94
|
+
"Main page": "/",
|
|
95
|
+
"1": "",
|
|
96
|
+
"GitHub": "https://github.com/alexander-akhmetov/python-telegram",
|
|
97
|
+
"DockerHub": "https://hub.docker.com/r/akhmetov/python-telegram/",
|
|
98
|
+
"PyPi": "https://pypi.org/project/python-telegram/",
|
|
99
|
+
"2": "",
|
|
100
|
+
},
|
|
100
101
|
}
|
|
101
102
|
|
|
102
103
|
# Add any paths that contain custom static files (such as style sheets) here,
|
|
103
104
|
# relative to this directory. They are copied after the builtin static files,
|
|
104
105
|
# so a file named "default.css" will overwrite the builtin "default.css".
|
|
105
|
-
html_static_path = [
|
|
106
|
+
html_static_path = ["_static"]
|
|
106
107
|
|
|
107
108
|
# Custom sidebar templates, must be a dictionary that maps document names
|
|
108
109
|
# to template names.
|
|
@@ -113,19 +114,18 @@ html_static_path = ['_static']
|
|
|
113
114
|
# 'searchbox.html']``.
|
|
114
115
|
#
|
|
115
116
|
html_sidebars = {
|
|
116
|
-
|
|
117
|
-
|
|
118
|
-
|
|
119
|
-
|
|
117
|
+
"**": [
|
|
118
|
+
"about.html",
|
|
119
|
+
"navigation.html",
|
|
120
|
+
"searchbox.html",
|
|
120
121
|
]
|
|
121
122
|
}
|
|
122
123
|
|
|
123
124
|
|
|
124
|
-
|
|
125
125
|
# -- Options for HTMLHelp output ---------------------------------------------
|
|
126
126
|
|
|
127
127
|
# Output file base name for HTML help builder.
|
|
128
|
-
htmlhelp_basename =
|
|
128
|
+
htmlhelp_basename = "python-telegramdoc"
|
|
129
129
|
|
|
130
130
|
|
|
131
131
|
# -- Options for LaTeX output ------------------------------------------------
|
|
@@ -134,15 +134,12 @@ latex_elements = {
|
|
|
134
134
|
# The paper size ('letterpaper' or 'a4paper').
|
|
135
135
|
#
|
|
136
136
|
# 'papersize': 'letterpaper',
|
|
137
|
-
|
|
138
137
|
# The font size ('10pt', '11pt' or '12pt').
|
|
139
138
|
#
|
|
140
139
|
# 'pointsize': '10pt',
|
|
141
|
-
|
|
142
140
|
# Additional stuff for the LaTeX preamble.
|
|
143
141
|
#
|
|
144
142
|
# 'preamble': '',
|
|
145
|
-
|
|
146
143
|
# Latex figure (float) alignment
|
|
147
144
|
#
|
|
148
145
|
# 'figure_align': 'htbp',
|
|
@@ -152,8 +149,13 @@ latex_elements = {
|
|
|
152
149
|
# (source start file, target name, title,
|
|
153
150
|
# author, documentclass [howto, manual, or own class]).
|
|
154
151
|
latex_documents = [
|
|
155
|
-
(
|
|
156
|
-
|
|
152
|
+
(
|
|
153
|
+
master_doc,
|
|
154
|
+
"python-telegram.tex",
|
|
155
|
+
"python-telegram Documentation",
|
|
156
|
+
"Alexander Akhmetov",
|
|
157
|
+
"manual",
|
|
158
|
+
),
|
|
157
159
|
]
|
|
158
160
|
|
|
159
161
|
|
|
@@ -161,10 +163,7 @@ latex_documents = [
|
|
|
161
163
|
|
|
162
164
|
# One entry per manual page. List of tuples
|
|
163
165
|
# (source start file, name, description, authors, manual section).
|
|
164
|
-
man_pages = [
|
|
165
|
-
(master_doc, 'python-telegram', 'python-telegram Documentation',
|
|
166
|
-
[author], 1)
|
|
167
|
-
]
|
|
166
|
+
man_pages = [(master_doc, "python-telegram", "python-telegram Documentation", [author], 1)]
|
|
168
167
|
|
|
169
168
|
|
|
170
169
|
# -- Options for Texinfo output ----------------------------------------------
|
|
@@ -173,9 +172,15 @@ man_pages = [
|
|
|
173
172
|
# (source start file, target name, title, author,
|
|
174
173
|
# dir menu entry, description, category)
|
|
175
174
|
texinfo_documents = [
|
|
176
|
-
(
|
|
177
|
-
|
|
178
|
-
|
|
175
|
+
(
|
|
176
|
+
master_doc,
|
|
177
|
+
"python-telegram",
|
|
178
|
+
"python-telegram Documentation",
|
|
179
|
+
author,
|
|
180
|
+
"python-telegram",
|
|
181
|
+
"One line description of project.",
|
|
182
|
+
"Miscellaneous",
|
|
183
|
+
),
|
|
179
184
|
]
|
|
180
185
|
|
|
181
186
|
|