pytdbot.client_manager

class pytdbot.client_manager.ClientManager(clients=None, lib_path=None, verbosity=2, loop=None)[source]

Bases: object

Client manager for Pytdbot

Parameters:
  • clients (List[pytdbot.Client])

  • lib_path (str)

  • verbosity (int)

  • loop (AbstractEventLoop)

__init__(clients=None, lib_path=None, verbosity=2, loop=None)[source]

Manage multiple Pytdbot clients

Example

>>> from pytdbot import ClientManager, Client
>>> clients = [Client(...), Client(...), Client(...)]
>>> client_manager = ClientManager(clients)
>>> await client_manager.start()
Parameters:
  • clients (List[pytdbot.Client], optional) – List of clients to manage

  • lib_path (str, optional) – Path to TDlib library

  • verbosity (int, optional) – Verbosity level of TDlib. Default is 2

  • loop (asyncio.AbstractEventLoop, optional) – Event loop to use

Return type:

None

async add_client(client, start_client=False)[source]

Add a client to the manager

Parameters:
  • client (pytdbot.Client) – Client to add

  • start_client (bool, optional) – Whether to start the client immediately. Default is False

Return type:

None

async close(close_all_clients=False)[source]

Close the Client Manager

Parameters:

close_all_clients (bool, optional) – Whether to close all managed clients. Default is False

Return type:

bool

Returns:

bool

async delete_client(client_id, close_client=False)[source]

Remove a client from the manager

Parameters:
  • client_id (int) – ID of client to remove

  • close_client (bool, optional) – Whether to close the client before removing. Default is False

Return type:

None

send(client_id, request)[source]

Send a request to TDlib

Parameters:
  • client_id (int) – ID of client to send request from

  • request (dict) – Request to send

Return type:

None

async start()[source]

Start the Client Manager

Return type:

None