Pytdbot


NamePytdbot JSON
Version 0.9.0 PyPI version JSON
download
home_pagehttps://github.com/pytdbot/client
SummaryEasy-to-use asynchronous TDLib wrapper for Python.
upload_time2025-02-12 19:08:42
maintainerNone
docs_urlNone
authorAYMEN Mohammed
requires_python>=3.9
licenseMIT
keywords telegram tdlib bot telegram-client telegram-bot bot-api telegram-bot tdlib-python tdlib-bot
VCS
bugtrack_url
requirements deepdiff aio-pika
Travis-CI No Travis.
coveralls test coverage No coveralls.
            # Pytdbot [![Version](https://img.shields.io/pypi/v/Pytdbot?style=flat&logo=pypi)](https://pypi.org/project/Pytdbot) [![TDLib version](https://img.shields.io/badge/TDLib-v1.8.45-blue?logo=telegram)](https://github.com/tdlib/td) [![Downloads](https://static.pepy.tech/personalized-badge/pytdbot?period=month&units=none&left_color=grey&right_color=brightgreen&left_text=Downloads)](https://pepy.tech/project/pytdbot)

Pytdbot (Python TDLib) is an asynchronous [**TDLib**](https://github.com/tdlib/td) wrapper for **Telegram** users/bots written in **Python**.

### Features

`Pytdbot` offers numerous advantages, including:

- **Easy to Use**: Designed with simplicity in mind, making it accessible for developers
- **Performance**: Fast and powerful, making it ready to fight
- **Asynchronous**: Fully asynchronous that allows for non-blocking requests and improved responsiveness
- **Scalable**: Easily scalable using [TDLib Server](https://github.com/pytdbot/tdlib-server)
- **Well-typed**: Provides clear and well-defined methods and types to enhance developer experience
- **Decorator-Based Updates**: Simplifies the implementation of update handlers through a decorator pattern
- **Bound Methods**: Features types bound methods for improved usability
- **Unlimited Support**: Supports **Plugins**, [**filters**](pytdbot/filters.py#L23), [**TDLib**](https://github.com/tdlib/td) types/functions and much more

### Requirements

- Python 3.9+
- Telegram [API key](https://my.telegram.org/apps)
- [tdjson](https://github.com/AYMENJD/tdjson) or [TDLib](https://github.com/tdlib/td#building)
- [deepdiff](https://github.com/seperman/deepdiff)
- [aio-pika](https://github.com/mosquito/aio-pika)

### Installation

> For better performance, it's recommended to install [orjson](https://github.com/ijl/orjson#install) or [ujson](https://github.com/ultrajson/ultrajson#ultrajson).

You can install Pytdbot with TDLib included using pip:

```bash
pip install pytdbot[tdjson]
```

or without **pre-built** TDLib:

```bash
pip install pytdbot
```

If the install fails, then you need to build TDLib from [source](https://github.com/tdlib/td#building) and pass it to `Client(lib_path="/path/to/libtdjson.so")`.

You could also install the development version using the following command:

```bash
pip install --pre pytdbot
```

### Examples

Basic example:

```python

import asyncio

from pytdbot import Client, types

client = Client(
    token="1088394097:AAQX2DnWiw4ihwiJUhIHOGog8gGOI",  # Your bot token or phone number if you want to login as user
    api_id=0,
    api_hash="API_HASH",
    lib_path="/path/to/libtdjson.so", # Path to TDjson shared library
    files_directory="BotDB",  # Path where to store TDLib files
    database_encryption_key="1234echobot$",
    td_verbosity=2,  # TDLib verbosity level
    td_log=types.LogStreamFile("tdlib.log", 104857600),  # Set TDLib log file path
)


@client.on_updateNewMessage()
async def print_message(c: Client, message: types.UpdateNewMessage):
    print(message)


@client.on_message()
async def say_hello(c: Client, message: types.Message):
    msg = await message.reply_text(f"Hey {await message.mention(parse_mode='html')}! I'm cooking up a surprise... 🍳👨‍🍳", parse_mode="html")

    async with message.action("choose_sticker"):
        await asyncio.sleep(5)

        await msg.edit_text("Boo! 👻 Just kidding.")



# Run the client
client.run()

```

For more examples, check the [examples](https://github.com/pytdbot/client/tree/main/examples) folder.

# Thanks to

- You for viewing or using this project.

- [@levlam](https://github.com/levlam) for maintaining [TDLib](https://github.com/tdlib/td) and for the help to create [Pytdbot](https://github.com/pytdbot/client).

# License

MIT [License](https://github.com/pytdbot/client/blob/main/LICENSE)

            

Raw data

            {
    "_id": null,
    "home_page": "https://github.com/pytdbot/client",
    "name": "Pytdbot",
    "maintainer": null,
    "docs_url": null,
    "requires_python": ">=3.9",
    "maintainer_email": null,
    "keywords": "telegram, tdlib, bot, telegram-client, telegram-bot, bot-api, telegram-bot, tdlib-python, tdlib-bot",
    "author": "AYMEN Mohammed",
    "author_email": "let.me.code.safe@gmail.com",
    "download_url": "https://files.pythonhosted.org/packages/0f/97/08f85e9688e2943a9b9cd2ae37be3bc69c3fa2294cfa74a4ea206048c22a/pytdbot-0.9.0.tar.gz",
    "platform": null,
    "description": "# Pytdbot [![Version](https://img.shields.io/pypi/v/Pytdbot?style=flat&logo=pypi)](https://pypi.org/project/Pytdbot) [![TDLib version](https://img.shields.io/badge/TDLib-v1.8.45-blue?logo=telegram)](https://github.com/tdlib/td) [![Downloads](https://static.pepy.tech/personalized-badge/pytdbot?period=month&units=none&left_color=grey&right_color=brightgreen&left_text=Downloads)](https://pepy.tech/project/pytdbot)\n\nPytdbot (Python TDLib) is an asynchronous [**TDLib**](https://github.com/tdlib/td) wrapper for **Telegram** users/bots written in **Python**.\n\n### Features\n\n`Pytdbot` offers numerous advantages, including:\n\n- **Easy to Use**: Designed with simplicity in mind, making it accessible for developers\n- **Performance**: Fast and powerful, making it ready to fight\n- **Asynchronous**: Fully asynchronous that allows for non-blocking requests and improved responsiveness\n- **Scalable**: Easily scalable using [TDLib Server](https://github.com/pytdbot/tdlib-server)\n- **Well-typed**: Provides clear and well-defined methods and types to enhance developer experience\n- **Decorator-Based Updates**: Simplifies the implementation of update handlers through a decorator pattern\n- **Bound Methods**: Features types bound methods for improved usability\n- **Unlimited Support**: Supports **Plugins**, [**filters**](pytdbot/filters.py#L23), [**TDLib**](https://github.com/tdlib/td) types/functions and much more\n\n### Requirements\n\n- Python 3.9+\n- Telegram [API key](https://my.telegram.org/apps)\n- [tdjson](https://github.com/AYMENJD/tdjson) or [TDLib](https://github.com/tdlib/td#building)\n- [deepdiff](https://github.com/seperman/deepdiff)\n- [aio-pika](https://github.com/mosquito/aio-pika)\n\n### Installation\n\n> For better performance, it's recommended to install [orjson](https://github.com/ijl/orjson#install) or [ujson](https://github.com/ultrajson/ultrajson#ultrajson).\n\nYou can install Pytdbot with TDLib included using pip:\n\n```bash\npip install pytdbot[tdjson]\n```\n\nor without **pre-built** TDLib:\n\n```bash\npip install pytdbot\n```\n\nIf the install fails, then you need to build TDLib from [source](https://github.com/tdlib/td#building) and pass it to `Client(lib_path=\"/path/to/libtdjson.so\")`.\n\nYou could also install the development version using the following command:\n\n```bash\npip install --pre pytdbot\n```\n\n### Examples\n\nBasic example:\n\n```python\n\nimport asyncio\n\nfrom pytdbot import Client, types\n\nclient = Client(\n    token=\"1088394097:AAQX2DnWiw4ihwiJUhIHOGog8gGOI\",  # Your bot token or phone number if you want to login as user\n    api_id=0,\n    api_hash=\"API_HASH\",\n    lib_path=\"/path/to/libtdjson.so\", # Path to TDjson shared library\n    files_directory=\"BotDB\",  # Path where to store TDLib files\n    database_encryption_key=\"1234echobot$\",\n    td_verbosity=2,  # TDLib verbosity level\n    td_log=types.LogStreamFile(\"tdlib.log\", 104857600),  # Set TDLib log file path\n)\n\n\n@client.on_updateNewMessage()\nasync def print_message(c: Client, message: types.UpdateNewMessage):\n    print(message)\n\n\n@client.on_message()\nasync def say_hello(c: Client, message: types.Message):\n    msg = await message.reply_text(f\"Hey {await message.mention(parse_mode='html')}! I'm cooking up a surprise... \ud83c\udf73\ud83d\udc68\u200d\ud83c\udf73\", parse_mode=\"html\")\n\n    async with message.action(\"choose_sticker\"):\n        await asyncio.sleep(5)\n\n        await msg.edit_text(\"Boo! \ud83d\udc7b Just kidding.\")\n\n\n\n# Run the client\nclient.run()\n\n```\n\nFor more examples, check the [examples](https://github.com/pytdbot/client/tree/main/examples) folder.\n\n# Thanks to\n\n- You for viewing or using this project.\n\n- [@levlam](https://github.com/levlam) for maintaining [TDLib](https://github.com/tdlib/td) and for the help to create [Pytdbot](https://github.com/pytdbot/client).\n\n# License\n\nMIT [License](https://github.com/pytdbot/client/blob/main/LICENSE)\n",
    "bugtrack_url": null,
    "license": "MIT",
    "summary": "Easy-to-use asynchronous TDLib wrapper for Python.",
    "version": "0.9.0",
    "project_urls": {
        "Homepage": "https://github.com/pytdbot/client",
        "Source": "https://github.com/pytdbot/client",
        "Tracker": "https://github.com/pytdbot/client/issues"
    },
    "split_keywords": [
        "telegram",
        " tdlib",
        " bot",
        " telegram-client",
        " telegram-bot",
        " bot-api",
        " telegram-bot",
        " tdlib-python",
        " tdlib-bot"
    ],
    "urls": [
        {
            "comment_text": null,
            "digests": {
                "blake2b_256": "0f9708f85e9688e2943a9b9cd2ae37be3bc69c3fa2294cfa74a4ea206048c22a",
                "md5": "a7aaac6056ded4a2dc09cbafad593a4a",
                "sha256": "ddbe2331a5f60c21b0cb0a628e7ee966026ff62ac1278e189cc2c86d8da31ff9"
            },
            "downloads": -1,
            "filename": "pytdbot-0.9.0.tar.gz",
            "has_sig": false,
            "md5_digest": "a7aaac6056ded4a2dc09cbafad593a4a",
            "packagetype": "sdist",
            "python_version": "source",
            "requires_python": ">=3.9",
            "size": 437380,
            "upload_time": "2025-02-12T19:08:42",
            "upload_time_iso_8601": "2025-02-12T19:08:42.885208Z",
            "url": "https://files.pythonhosted.org/packages/0f/97/08f85e9688e2943a9b9cd2ae37be3bc69c3fa2294cfa74a4ea206048c22a/pytdbot-0.9.0.tar.gz",
            "yanked": false,
            "yanked_reason": null
        }
    ],
    "upload_time": "2025-02-12 19:08:42",
    "github": true,
    "gitlab": false,
    "bitbucket": false,
    "codeberg": false,
    "github_user": "pytdbot",
    "github_project": "client",
    "travis_ci": false,
    "coveralls": false,
    "github_actions": true,
    "requirements": [
        {
            "name": "deepdiff",
            "specs": []
        },
        {
            "name": "aio-pika",
            "specs": []
        }
    ],
    "lcname": "pytdbot"
}
        
Elapsed time: 0.46297s