/demo-pytdlib

Python bindings and client for TDLib

Primary LanguagePythonGNU General Public License v3.0GPL-3.0

demo-pytdlib

pyTDLib - python bindings for TDLib (Telegram Database Library) JSON API: https://github.com/tdlib/td

Installation

You first need to install

then

python3 setup.py

Example:

from pytdlib import Client
from pytdlib.api.types import updateNewMessage, messageText

bot = Client()

bot.start(login=True)

def updt_hndlr(update):
    if isinstance(update, updateNewMessage):
        msg = update.message
        if isinstance(msg.content, messageText):
            text = msg.content.text.text

            if text == "ping":
                bot.send_message(msg.chat_id, "*PING*", reply_to_message_id=msg.id, parse_mode="md", action=True)

bot.set_update_handler(updt_hndlr)
#bot.idle()