Skip to content

Navigation Menu

Sign in
Appearance settings

Search code, repositories, users, issues, pull requests...

Provide feedback

We read every piece of feedback, and take your input very seriously.

Saved searches

Use saved searches to filter your results more quickly

Appearance settings

pytdbot/tdlib-server

Open more actions menu

Repository files navigation

TDLib Server

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

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.
  • NATS Integration: Fast and lightweight messaging with NATS for efficient asynchronous communication.

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",
    nats_url="nats://127.0.0.1:4222",  # NATS server 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.")

asyncio.run(client.run())

Installation

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

Requirements

Once TDLib and NATS 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 installs files at td/tdlib.

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

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

      make install
  • Run NATS Server:

    nats-server -a 127.0.0.1
  • Run TDLib 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.

About

High-performance Go server built to scale Telegram bots.

Resources

Stars

Watchers

Forks

Releases

Used by

Contributors

Languages

Morty Proxy This is a proxified and sanitized view of the page, visit original site.