Easy-to-use asynchronous TDLib wrapper for Python.
Project description
Pytdbot

Pytdbot (Python TDLib) is an asynchronous TDLib 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
- 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, TDLib types/functions and much more
Requirements
Installation
For better performance, it's recommended to install orjson or ujson.
You can install Pytdbot using pip:
pip install pytdbot
To install the development version from Github, use the following command:
pip install git+https://github.com/pytdbot/client.git
Examples
Basic example:
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 folder.
Thanks to
-
You for viewing or using this project.
-
@levlam for maintaining TDLib and for the help to create Pytdbot.
License
MIT License
Project details
Release history Release notifications | RSS feed
Download files
Download the file for your platform. If you're not sure which to choose, learn more about installing packages.
Source Distribution
File details
Details for the file pytdbot-0.9.0.dev5.tar.gz
.
File metadata
- Download URL: pytdbot-0.9.0.dev5.tar.gz
- Upload date:
- Size: 426.7 kB
- Tags: Source
- Uploaded using Trusted Publishing? Yes
- Uploaded via: twine/6.0.1 CPython/3.12.8
File hashes
Algorithm | Hash digest | |
---|---|---|
SHA256 |
1e9c88e92971ce0e3c744f7847c98814147b9df6388bfc9b23ef6a3c2e2f3422
|
|
MD5 |
9c12a6173d6fe7b6e10dff5e59161f86
|
|
BLAKE2b-256 |
772df4666e815a81f1600123d4a61c8c746e7bc8ca409bf79949f50cca30ee18
|
Provenance
The following attestation bundles were made for pytdbot-0.9.0.dev5.tar.gz
:
Publisher:
publish-to-pypi.yml
on pytdbot/client
-
Statement:
-
Statement type:
https://in-toto.io/Statement/v1
-
Predicate type:
https://docs.pypi.org/attestations/publish/v1
-
Subject name:
pytdbot-0.9.0.dev5.tar.gz
-
Subject digest:
1e9c88e92971ce0e3c744f7847c98814147b9df6388bfc9b23ef6a3c2e2f3422
- Sigstore transparency entry: 155386045
- Sigstore integration time:
-
Permalink:
pytdbot/client@96d6bccb68e9305d4d2844dba084f2bf774baa3b
-
Branch / Tag:
refs/heads/main
- Owner: https://github.com/pytdbot
-
Access:
public
-
Token Issuer:
https://token.actions.githubusercontent.com
-
Runner Environment:
github-hosted
-
Publication workflow:
publish-to-pypi.yml@96d6bccb68e9305d4d2844dba084f2bf774baa3b
-
Trigger Event:
push
-
Statement type: