Introduction
MultiBot Module
Overview
The MultiBot
module provides a framework for managing multiple Telegram bots within a system. This module facilitates the initialization, configuration, and management of Telegram bots, allowing you to work with a single or multiple bots depending on your system's requirements. It includes functionalities for connecting to the Telegram API, validating bot configurations, and retrieving bot instances based on various criteria.
Purpose
The purpose of the MultiBot
module is to:
Initialize Connections: Set up connections for one or multiple Telegram bots based on provided configuration parameters. This involves creating instances of
TelegramBot
and managing their lifecycle.Validate Configurations: Ensure that the bot configurations meet the required criteria, such as having valid tokens, unique IDs, and proper designation of the main bot.
Manage Bots: Provide methods to retrieve bots by their IDs and get the main bot instance from the collection of configured bots.
Features
Flexible Configuration: Supports both single and multi-bot setups, allowing you to configure bots based on the system type (
'one'
or'multi'
).Error Handling: Includes detailed error handling for invalid configurations and connection issues, ensuring robust and predictable behavior.
Bot Management: Offers methods to retrieve bot instances by ID and get the main bot, enabling efficient management of bot operations.
Dependencies
node-telegram-bot-api
: A library for interacting with the Telegram Bot API.global-manager
: A utility for managing global state across the application.
Usage
To use the MultiBot
module, you need to configure it with bot details and options. The module provides methods to initialize bot connections, validate configurations, and manage bot instances.
Here is a basic example of how to use the MultiBot
module:
Documentation
For detailed documentation on each method and property of the MultiBot
class, refer to the API docuation sectionsow.
Last updated