# 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:

1. **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.
2. **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.
3. **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:

```javascript
const MultiBot = require('multibot-telegram');

// Configuration object for MultiBot
const config = {
    type: 'multi', // System type, can be 'one' or 'multi'
    bots: [
        { id: 1, token: 'your_bot_token_1', main: true },
        { id: 2, token: 'your_bot_token_2', main: false }
    ],
    options: {
        commands: [
            { command: 'start', description: 'Start command' },
            { command: 'help', description: 'Help command' }
        ]
    }
};

// Create an instance of MultiBot
const multiBot = new MultiBot(config);
```

#### Documentation

For detailed documentation on each method and property of the `MultiBot` class, refer to the API docuation sectionsow.


---

# Agent Instructions: Querying This Documentation

If you need additional information that is not directly available in this page, you can query the documentation dynamically by asking a question.

Perform an HTTP GET request on the current page URL with the `ask` query parameter:

```
GET https://fozan.gitbook.io/multibot-telegram/introduction.md?ask=<question>
```

The question should be specific, self-contained, and written in natural language.
The response will contain a direct answer to the question and relevant excerpts and sources from the documentation.

Use this mechanism when the answer is not explicitly present in the current page, you need clarification or additional context, or you want to retrieve related documentation sections.
