Skip to main content

A simple Python TDLib wrapper

Project description

Python Wrapper TDLib

Description

A simple Python TDLib Wrapper (pywtdlib) that makes you easy to create new Python Telegram clients.

Installation

  1. By pip3
pip3 install pywtdlib

Setup

This project depends on TDLib. TDLib is the official cross-platform library for building Telegram clients written in C++.

Example:

This wrapper is so easy to use, for example the following code prints every new message that is received in your Telegram account.

from os import environ
from pywtdlib.client import Client
from pywtdlib.enum import Update
import logging

# (optional) set some logging to see what is happening under the hood
logging.basicConfig(
    filename="app.log",
    filemode="a",
    level=logging.INFO,
    format="%(asctime)s [%(filename)s:%(lineno)d]|%(levelname)s|%(message)s",
)

# 1. instantiate the telegram client (put your API_ID and API_HASH from https://my.telegram.org/apps)
tg = Client(api_id=environ["API_ID"], api_hash=environ["API_HASH"])

# 2. define an update handler (every time an update is received, it will execute it)
# this will print in console every new message received
def print_messages(event):
    if event["@type"] == Update.NEW_MESSAGE:
        print(event)


# 3. add the update handler
tg.set_update_handler(print_messages)

# 4. start the client (press CTRL + C to stop)
tg.start()

Libraries

In the lib/ folder are located the binaries for Windows and Linux. If you need other binaries or you want to build by your own, go to the TDLib build page.

Logs

Support for basic logging

Issues

If you detect a bug or you have a suggestion, open a ticket with the corresponding template.

Project details


Download files

Download the file for your platform. If you're not sure which to choose, learn more about installing packages.

Source Distribution

pywtdlib-0.2.0.tar.gz (65.4 MB view details)

Uploaded Source

Built Distribution

pywtdlib-0.2.0-py3-none-any.whl (65.7 MB view details)

Uploaded Python 3

File details

Details for the file pywtdlib-0.2.0.tar.gz.

File metadata

  • Download URL: pywtdlib-0.2.0.tar.gz
  • Upload date:
  • Size: 65.4 MB
  • Tags: Source
  • Uploaded using Trusted Publishing? No
  • Uploaded via: twine/4.0.2 CPython/3.9.16

File hashes

Hashes for pywtdlib-0.2.0.tar.gz
Algorithm Hash digest
SHA256 45994aae3796cf53041aa01e4d250d8d6b7131530b7f4581bcb4e48a4087ccfd
MD5 345af374ced7b81a7b6bf453da5b1734
BLAKE2b-256 524aed83ca316ca0481df69a4a56699fbdf22fcc42b527852dd519e210e11d34

See more details on using hashes here.

File details

Details for the file pywtdlib-0.2.0-py3-none-any.whl.

File metadata

  • Download URL: pywtdlib-0.2.0-py3-none-any.whl
  • Upload date:
  • Size: 65.7 MB
  • Tags: Python 3
  • Uploaded using Trusted Publishing? No
  • Uploaded via: twine/4.0.2 CPython/3.9.16

File hashes

Hashes for pywtdlib-0.2.0-py3-none-any.whl
Algorithm Hash digest
SHA256 48df5e90c6ebcf3634a54a3eac2ebf872c896f0002abb589bc15fd56c20973f1
MD5 b48037048d37d73054574071f8dfdbc3
BLAKE2b-256 e535ff7049362f64f59dfe8d3a9815a139839de269ba2648ed9e227d6dfc67d3

See more details on using hashes here.

Supported by

AWS Cloud computing and Security Sponsor Datadog Monitoring Fastly CDN Google Download Analytics Pingdom Monitoring Sentry Error logging StatusPage Status page