Easy-to-use asynchronous TDLib wrapper for Telegram bots.
Project description
Pytdbot
![Downloads](https://pypi-camo.freetls.fastly.net/40089995ccd2052e326e2f981a9f20b932370d42/68747470733a2f2f7374617469632e706570792e746563682f706572736f6e616c697a65642d62616467652f70797464626f743f706572696f643d6d6f6e746826756e6974733d6e6f6e65266c6566745f636f6c6f723d677265792672696768745f636f6c6f723d627269676874677265656e266c6566745f746578743d446f776e6c6f616473)
Easy, Sample and powerful TDLib-based client.
Requirements
Installation
pip install pytdbot
From github (dev version)
pip install git+https://github.com/pytdbot/client.git
Examples
Basic example:
from pytdbot import Client, utils
from pytdbot.types import Update
client = Client(
api_id=0,
api_hash="API_HASH",
database_encryption_key="1234echobot$",
token="1088394097:AAQX2DnWiw4ihwiJUhIHOGog8gGOI", # Your bot token or phone number if you want to login as user.
files_directory="BotDB", # path where to store session and files.
lib_path="/path/to/libtdjson.so" # Path to TDjson shared library.
)
@client.on_updateNewMessage()
async def print_message(c: Client, message: Update):
print(message)
@client.on_updateNewMessage()
async def simple_message(c: Client, message: Update):
if message.is_private:
await message.reply_text('Hi! i am simple bot')
if message.is_self and message.text: # Works only for userbots.
if message.text == "!id":
await message.edit_text(
"\\- Current chat ID: {}\n\\- {} ID: {}".format(
utils.code(str(message.chat_id)),
utils.bold(c.me["first_name"]),
utils.code(str(message.from_id)),
),
parse_mode="markdownv2",
)
# 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
Pytdbot-0.8.1.dev0.tar.gz
(12.9 MB
view hashes)