Coder Social home page Coder Social logo

sync-client's Introduction

Pytdbot Version TDLib version Downloads

Pytdbot (Python TDLib) is an asynchronous TDLib wrapper for Telegram users/bots written in Python.

Features

  • Easy, Fast and Powerful
  • Fully asynchronous
  • Decorator based update handler
  • Bound methods
  • Supports userbots, Plugins, Filters, TDLib functions and much more.

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 LogStreamFile, 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 TDLib files
    lib_path="/path/to/libtdjson.so" # Path to TDjson shared library
    td_log=LogStreamFile("tdlib.log"),  # Set TDLib log file path
    td_verbosity=2,  # TDLib verbosity level
)


@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

sync-client's People

Contributors

aymenjd avatar github-actions[bot] avatar

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    ๐Ÿ–– Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. ๐Ÿ“Š๐Ÿ“ˆ๐ŸŽ‰

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google โค๏ธ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.