python-telegram


Namepython-telegram JSON
Version 0.19.0 PyPI version JSON
download
home_pageNone
SummaryPython library to help you build your own Telegram clients
upload_time2024-06-23 16:30:05
maintainerNone
docs_urlNone
authorNone
requires_python>=3.9
licenseMIT
keywords telegram client api tdlib tdjson td
VCS
bugtrack_url
requirements No requirements were recorded.
Travis-CI No Travis.
coveralls test coverage No coveralls.
            # python-telegram

[![Build Status](https://github.com/alexander-akhmetov/python-telegram/workflows/python-telegram%20tests/badge.svg)](https://github.com/alexander-akhmetov/python-telegram/actions)
[![PyPI](https://img.shields.io/pypi/v/python-telegram.svg)](https://pypi.python.org/pypi/python-telegram)
[![DockerHub](https://img.shields.io/docker/automated/akhmetov/python-telegram.svg)](https://hub.docker.com/r/akhmetov/python-telegram/)
![Read the Docs (version)](https://img.shields.io/readthedocs/pip/stable.svg)

Python API for the [tdlib](https://github.com/tdlib/td) library.
It helps you build your own Telegram clients.

- [Changelog](https://python-telegram.readthedocs.io/en/latest/changelog.html)
- [Documentation](http://python-telegram.readthedocs.io)
- [Tutorial](http://python-telegram.readthedocs.io/en/latest/tutorial.html)

## Installation

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/):

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

## How to use the library

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

Basic example:

```python
from telegram.client import Telegram
from telegram.text import Spoiler

tg = Telegram(
    api_id='api_id',
    api_hash='api_hash',
    phone='+31611111111',  # you can pass 'bot_token' instead
    database_encryption_key='changekey123',
    files_directory='/tmp/.tdlib_files/',
)
tg.login()

# 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 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.
```

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):

``` python
tg.call_method('getUser',  params={'user_id': user_id})
```

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

---

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

## Development

See [CONTRIBUTING.md](/CONTRIBUTING.md).

            

Raw data

            {
    "_id": null,
    "home_page": null,
    "name": "python-telegram",
    "maintainer": null,
    "docs_url": null,
    "requires_python": ">=3.9",
    "maintainer_email": null,
    "keywords": "telegram, client, api, tdlib, tdjson, td",
    "author": null,
    "author_email": "Alexander Akhmetov <me@alx.cx>",
    "download_url": "https://files.pythonhosted.org/packages/49/76/f102f251f55fa016093f14aa3373c354fef3a2a7cc035dea0d8783c69b4b/python_telegram-0.19.0.tar.gz",
    "platform": null,
    "description": "# python-telegram\n\n[![Build Status](https://github.com/alexander-akhmetov/python-telegram/workflows/python-telegram%20tests/badge.svg)](https://github.com/alexander-akhmetov/python-telegram/actions)\n[![PyPI](https://img.shields.io/pypi/v/python-telegram.svg)](https://pypi.python.org/pypi/python-telegram)\n[![DockerHub](https://img.shields.io/docker/automated/akhmetov/python-telegram.svg)](https://hub.docker.com/r/akhmetov/python-telegram/)\n![Read the Docs (version)](https://img.shields.io/readthedocs/pip/stable.svg)\n\nPython API for the [tdlib](https://github.com/tdlib/td) library.\nIt helps you build your own Telegram clients.\n\n- [Changelog](https://python-telegram.readthedocs.io/en/latest/changelog.html)\n- [Documentation](http://python-telegram.readthedocs.io)\n- [Tutorial](http://python-telegram.readthedocs.io/en/latest/tutorial.html)\n\n## Installation\n\nThis library requires Python 3.9+ and Linux or MacOS. Windows is not supported.\n\n```shell\npip install python-telegram\n```\n\nSee [documentation](http://python-telegram.readthedocs.io/en/latest/#installation) for more details.\n\n### tdlib\n\n`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.\nThe precompiled library may not work on some systems, it is dynamically linked and requires specific versions of additional libraries.\n\n```shell\n\n### Docker\n\nThis library has a [docker image](https://hub.docker.com/r/akhmetov/python-telegram/):\n\n```sh\ndocker run -i -t --rm \\\n            -v /tmp/docker-python-telegram/:/tmp/ \\\n            akhmetov/python-telegram \\\n            python3 /app/examples/send_message.py $(API_ID) $(API_HASH) $(PHONE) $(CHAT_ID) $(TEXT)\n```\n\n## How to use the library\n\nCheck out the [tutorial](http://python-telegram.readthedocs.io/en/latest/tutorial.html) for more details.\n\nBasic example:\n\n```python\nfrom telegram.client import Telegram\nfrom telegram.text import Spoiler\n\ntg = Telegram(\n    api_id='api_id',\n    api_hash='api_hash',\n    phone='+31611111111',  # you can pass 'bot_token' instead\n    database_encryption_key='changekey123',\n    files_directory='/tmp/.tdlib_files/',\n)\ntg.login()\n\n# If this is the first run, the library needs to preload all chats.\n# Otherwise, the message will not be sent.\nresult = tg.get_chats()\nresult.wait()\n\nchat_id: int\nresult = tg.send_message(chat_id, Spoiler('Hello world!'))\n\n# `tdlib` is asynchronous, so `python-telegram` always returns an `AsyncResult` object.\n# You can receive a result with the `wait` method of this object.\nresult.wait()\nprint(result.update)\n\ntg.stop()  # You must call `stop` at the end of the script.\n```\n\nYou can also use `call_method` to call any [tdlib method](https://core.telegram.org/tdlib/docs/classtd_1_1td__api_1_1_function.html):\n\n``` python\ntg.call_method('getUser',  params={'user_id': user_id})\n```\n\nMore examples can be found in the [/examples/ directory](/examples/).\n\n---\n\nMore information is available in the [documentation](http://python-telegram.readthedocs.io).\n\n## Development\n\nSee [CONTRIBUTING.md](/CONTRIBUTING.md).\n",
    "bugtrack_url": null,
    "license": "MIT",
    "summary": "Python library to help you build your own Telegram clients",
    "version": "0.19.0",
    "project_urls": {
        "Changelog": "https://python-telegram.readthedocs.io/en/latest/changelog.html",
        "Documentation": "https://python-telegram.readthedocs.io/en/latest/",
        "Source": "https://github.com/alexander-akhmetov/python-telegram",
        "Tutorial": "https://python-telegram.readthedocs.io/en/latest/tutorial.html"
    },
    "split_keywords": [
        "telegram",
        " client",
        " api",
        " tdlib",
        " tdjson",
        " td"
    ],
    "urls": [
        {
            "comment_text": "",
            "digests": {
                "blake2b_256": "02178995b7d036c9762f90964fc5897ab46458fcfc1ad1dd27fa063f726854b9",
                "md5": "7c129e911cfef2a76c630658487388a8",
                "sha256": "1e1d5e065a000580eeaeb5b608e410651320f5d6c804e8e4e7568b6b614071bc"
            },
            "downloads": -1,
            "filename": "python_telegram-0.19.0-py3-none-any.whl",
            "has_sig": false,
            "md5_digest": "7c129e911cfef2a76c630658487388a8",
            "packagetype": "bdist_wheel",
            "python_version": "py3",
            "requires_python": ">=3.9",
            "size": 20436958,
            "upload_time": "2024-06-23T16:30:00",
            "upload_time_iso_8601": "2024-06-23T16:30:00.344149Z",
            "url": "https://files.pythonhosted.org/packages/02/17/8995b7d036c9762f90964fc5897ab46458fcfc1ad1dd27fa063f726854b9/python_telegram-0.19.0-py3-none-any.whl",
            "yanked": false,
            "yanked_reason": null
        },
        {
            "comment_text": "",
            "digests": {
                "blake2b_256": "4976f102f251f55fa016093f14aa3373c354fef3a2a7cc035dea0d8783c69b4b",
                "md5": "4742d1f7fba52c775bf663e687e0594b",
                "sha256": "7b5b2da3d01d4cf5776c92f91fdd35a0f98976eec2356726b338f59ba01d1373"
            },
            "downloads": -1,
            "filename": "python_telegram-0.19.0.tar.gz",
            "has_sig": false,
            "md5_digest": "4742d1f7fba52c775bf663e687e0594b",
            "packagetype": "sdist",
            "python_version": "source",
            "requires_python": ">=3.9",
            "size": 20313048,
            "upload_time": "2024-06-23T16:30:05",
            "upload_time_iso_8601": "2024-06-23T16:30:05.258736Z",
            "url": "https://files.pythonhosted.org/packages/49/76/f102f251f55fa016093f14aa3373c354fef3a2a7cc035dea0d8783c69b4b/python_telegram-0.19.0.tar.gz",
            "yanked": false,
            "yanked_reason": null
        }
    ],
    "upload_time": "2024-06-23 16:30:05",
    "github": true,
    "gitlab": false,
    "bitbucket": false,
    "codeberg": false,
    "github_user": "alexander-akhmetov",
    "github_project": "python-telegram",
    "travis_ci": false,
    "coveralls": false,
    "github_actions": true,
    "tox": true,
    "lcname": "python-telegram"
}
        
Elapsed time: 0.70123s