Skip to content

Commit

Permalink
Merge branch 'main' of github.com:alexander-akhmetov/python-telegram
Browse files Browse the repository at this point in the history
  • Loading branch information
gasaichandesu committed Jun 24, 2024
2 parents 592b98d + f6655c4 commit c8d0472
Show file tree
Hide file tree
Showing 39 changed files with 718 additions and 669 deletions.
12 changes: 0 additions & 12 deletions .github/dependabot.yml
Original file line number Diff line number Diff line change
Expand Up @@ -10,18 +10,6 @@ updates:
assignees:
- alexander-akhmetov
ignore:
- dependency-name: pylint
versions:
- 2.7.0
- 2.7.3
- 2.7.4
- 2.8.1
- dependency-name: black
versions:
- 21.4b0
- dependency-name: flake8
versions:
- 3.9.0
- dependency-name: ipdb
versions:
- 0.13.5
Expand Down
2 changes: 1 addition & 1 deletion .github/workflows/tests.yml
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,7 @@ jobs:
strategy:
max-parallel: 4
matrix:
python-version: ["3.8", "3.9", "3.10", "3.11"]
python-version: ["3.9", "3.10", "3.11", "3.12"]

steps:
- uses: actions/checkout@v4
Expand Down
1 change: 1 addition & 0 deletions .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -9,3 +9,4 @@ MANIFEST
*.pyc
.DS_Store
.vscode
telegram/_version.py
13 changes: 13 additions & 0 deletions .readthedocs.yaml
Original file line number Diff line number Diff line change
@@ -0,0 +1,13 @@
version: 2

build:
os: ubuntu-22.04
tools:
python: "3.12"

sphinx:
configuration: docs/source/conf.py

python:
install:
- requirements: docs/requirements.txt
20 changes: 9 additions & 11 deletions CONTRIBUTING.md
Original file line number Diff line number Diff line change
Expand Up @@ -2,42 +2,40 @@

Pull requests are welcome!

Feel free to open an issue if you found a bug, have new ideas, suggestions or found a mistake
in [documentation](https://python-telegram.readthedocs.io/en/latest/).
Feel free to open an issue if you find a bug, have new ideas, suggestions,
or spot a mistake in the [documentation](https://python-telegram.readthedocs.io/en/latest/).

## Reporting bugs

We use [GitHub
Issues](https://github.com/alexander-akhmetov/python-telegram/issues) to track
bugs. If you found a bug, please, open a new issue.
bugs. If you find a bug, please open a new issue.

Try to include steps to reproduce and detailed description of the bug and maybe
some sample code.
Try to include steps to reproduce the bug, a detailed description, and some sample code if possible.

## Pull request process

1. Fork the repository and create a new branch from `master`.
2. Make your changes and do not forget about new tests :)
2. Make your changes and don't forget to add new tests :)
3. Ensure the tests pass with your changes.
4. Create a new PR!

## Coding style

The project uses [black](https://github.com/psf/black) as a autoformatter tool
and checker and a few linters.
The project uses [ruff](https://docs.astral.sh/ruff/) as an autoformatter and linter.

## Tests

To run tests you have to install [tox](https://tox.readthedocs.io/en/latest/).
To run tests you need to install [tox](https://tox.readthedocs.io/en/latest/).

Run tests:

```shell
tox
```

Run a specific test using python 3.11:
Run a specific test using python 3.12:

```shell
tox -e py311 -- -k test_add_message_handler
tox -e py312 -- -k test_add_message_handler
```
2 changes: 1 addition & 1 deletion Dockerfile
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
FROM python:3.10.0-bullseye
FROM python:3.12.4-slim-bullseye

RUN python3 -m pip install python-telegram

Expand Down
27 changes: 19 additions & 8 deletions Makefile
Original file line number Diff line number Diff line change
@@ -1,26 +1,37 @@
docker-build:
.PHONY: docker/build
docker/build:
docker build -f Dockerfile . -t akhmetov/python-telegram

docker-send-message:
.PHONY: docker/send-message
docker/send-message:
docker run -i -t \
-v /tmp/docker-python-telegram/:/tmp/ \
akhmetov/python-telegram \
python3 /app/examples/send_message.py $(API_ID) $(API_HASH) $(PHONE) $(CHAT_ID) $(TEXT)

docker-echo-bot:
.PHONY: docker/echo-bot
docker/echo-bot:
docker run -i -t \
-v /tmp/docker-python-telegram/:/tmp/ \
akhmetov/python-telegram \
python3 /app/examples/echo_bot.py $(API_ID) $(API_HASH) $(PHONE)

docker-get-instant-view:
.PHONY: docker/get-instant-view
docker/get-instant-view:
docker run -i -t \
-v /tmp/docker-python-telegram/:/tmp/ \
akhmetov/python-telegram \
python3 /app/examples/echo_bot.py $(API_ID) $(API_HASH) $(PHONE)


release-pypi:
test -n "$(VERSION)"
python setup.py sdist
twine upload dist/python-telegram-$(VERSION).tar.gz
.PHONY: clean
clean:
rm -rf dist

.PHONY: build-pypi
build-pypi: clean
python3 -m build

.PHONY: release-pypi
release-pypi:build-pypi
twine upload dist/*
26 changes: 17 additions & 9 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -14,14 +14,21 @@ It helps you build your own Telegram clients.

## Installation

This library requires Python 3.8+ and Linux or MacOS. Windows is not supported.
This library requires Python 3.9+ and Linux or MacOS. Windows is not supported.

```shell
pip install python-telegram
```

See [documentation](http://python-telegram.readthedocs.io/en/latest/#installation) for more details.

### tdlib

`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.
The precompiled library may not work on some systems, it is dynamically linked and requires specific versions of additional libraries.

```shell

### Docker

This library has a [docker image](https://hub.docker.com/r/akhmetov/python-telegram/):
Expand All @@ -33,9 +40,9 @@ docker run -i -t --rm \
python3 /app/examples/send_message.py $(API_ID) $(API_HASH) $(PHONE) $(CHAT_ID) $(TEXT)
```

## How to use
## How to use the library

Have a look at the [tutorial](http://python-telegram.readthedocs.io/en/latest/tutorial.html) :)
Check out the [tutorial](http://python-telegram.readthedocs.io/en/latest/tutorial.html) for more details.

Basic example:

Expand All @@ -52,19 +59,20 @@ tg = Telegram(
)
tg.login()
# if this is the first run, library needs to preload all chats
# otherwise the message will not be sent
# If this is the first run, the library needs to preload all chats.
# Otherwise, the message will not be sent.
result = tg.get_chats()
result.wait()
chat_id: int
result = tg.send_message(chat_id, Spoiler('Hello world!'))
# `tdlib` is asynchronous, so `python-telegram` always returns you an `AsyncResult` object.
# `tdlib` is asynchronous, so `python-telegram` always returns an `AsyncResult` object.
# You can receive a result with the `wait` method of this object.
result.wait()
print(result.update)
tg.stop() # you must call `stop` at the end of the script
tg.stop() # You must call `stop` at the end of the script.
```

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):
Expand All @@ -73,11 +81,11 @@ You can also use `call_method` to call any [tdlib method](https://core.telegram.
tg.call_method('getUser', params={'user_id': user_id})
```

More examples you can find in the [/examples/ directory](/examples/).
More examples can be found in the [/examples/ directory](/examples/).

---

More information in the [documentation](http://python-telegram.readthedocs.io).
More information is available in the [documentation](http://python-telegram.readthedocs.io).

## Development

Expand Down
1 change: 1 addition & 0 deletions docs/requirements.txt
Original file line number Diff line number Diff line change
@@ -1,3 +1,4 @@
sphinx
sphinx-autobuild
autodoc
sphinx-immaterial
5 changes: 4 additions & 1 deletion docs/source/changelog.rst
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,10 @@ Changelog

[unreleased]

- Python 3.7 is no longer supported.
[0.19.0] 2024-06-23

- Python versions 3.7 and 3.8 are no longer supported.
- tdlib 1.8.31.

[0.18.0] - 2023-03-13

Expand Down
Loading

0 comments on commit c8d0472

Please sign in to comment.