Skip to content

High-performance Go server built to scale Telegram bots.

License

Notifications You must be signed in to change notification settings

pytdbot/tdlib-server

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

7 Commits
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 

Repository files navigation

TDLib Server

TDLib Server is a high-performance Go server built to scale Telegram bots using TDLib and RabbitMQ.

Table of Contents

Features

  • Easy to Use: Simple setup and configuration for quick integration.
  • High Performance: Optimized for scaling high-loaded Telegram bots.
  • Go-Powered: Built with Go for concurrency and speed.
  • RabbitMQ Integration: Seamless integration with RabbitMQ for efficient asynchronous message handling.

Usage

Here’s an example of how you can use Pytdbot to interact with TDLib Server:

import asyncio
import logging
from pytdbot import Client
from pytdbot.types import Message

logging.basicConfig(
    level=logging.INFO,
    format="[%(levelname)s][%(filename)s:%(lineno)d][%(funcName)s] %(message)s",
)

client = Client(
    token="508903:AAGyYP5y63ihh_7KFX9aNiaHfajAmcAA",
    rabbitmq_url="amqp://username:[email protected]:5672/",  # RabbitMQ URL
)


@client.on_message()
async def say_hello(c: Client, message: Message):
    msg = await message.reply_text("Hey there! I'm cooking up a surprise... 🍳👨‍🍳")

    async with message.action("choose_sticker"):
        await asyncio.sleep(5)

        await msg.edit_text("Boo! 👻 Just kidding.")

client.run()

Installation

Follow these steps to set up and build TDLib Server on your system.

Requirements

Once TDLib and RabbitMQ are installed, you're ready to build TDLib Server:

  • Clone the repository

    git clone https://github.com/pytdbot/tdlib-server
    cd tdlib-server
  • Build TDLib Server

    • If TDLib is not installed system-wide (a.k.a /usr/local):

      TDLIB_DIR="/path/to/tdlib" make build

      Ensure you adjust the paths to match your installation directories. By default TDLib install files at td/tdlib

    • If TDLib is installed system-wide (recommended), just do:

      make build
    • Optionally, you can install tdlib-server system-wide:

      make install
  • Run the server:

    tdlib-server --config config.ini

Configuration

All configuration options can be found in config.ini.

You can also view the available cli options by running:

tdlib-server --help

Acknowledgments

  • Thank you for taking the time to view or use this project.

  • Special thanks to @levlam for maintaining TDLib and for his support in creating TDLib Server.

License

This project is licensed under the MIT License.