Skip to content

Latest commit

 

History

History
82 lines (52 loc) · 2.72 KB

README.md

File metadata and controls

82 lines (52 loc) · 2.72 KB

telegram-partner-bot

// Credit to github.com/nbmsacha for initial implementation.

Table of Contents

  1. Introduction
  2. Environment Setup
  3. Running the Application
  4. Missing Elements

Missing Elements

  • Error Handling
  • Logging
  • Unit Tests
  • Documentation
  • Deployment Guide
  • Security Measures

Introduction

Environment Setup

.env.example

Use the .env.example placeholders as a guide.

  1. Copy the Template: Duplicate the .env.example file and rename it to .env.

  2. Fill in the Values: See comments. Warning: Setting the API_ID and API_HASH allows the bot to access your Telegram account and perform actions on your behalf. Ensure these values are kept secure.

  3. Secure the File: Ensure that the .env file is added to your .gitignore to prevent it from being committed to version control.

Where to Obtain API_ID and API_HASH: You can obtain these values by creating a new application on the Telegram API Development Tools page. Follow the instructions to register your application and receive your API_ID and API_HASH.

Running the Application

  1. Install Dependencies: Ensure you have Node.js installed, then run the following command to install the necessary packages:

    npm install
  2. Start the Bot: The application will automatically generate a session string if it is not present in the .env file. Ensure your .env file is correctly configured with your API_ID and API_HASH. You can start the bot using:

    node src/index.js

    The bot will connect to Telegram and start listening for commands.

  3. Using the Bot: The bot can handle commands sent to it. For example, you can use the /set command to update configuration values dynamically. The bot will respond with confirmation messages.

  4. Running the Server: If your application includes a server component, you can start it using:

    node src/bot/server.js

    The server will listen for incoming requests and process them accordingly.

Testing

To run the tests, use the following command:

npm test

This will execute the test suite located in src/tests/test_main.js, which includes tests for the Telegram client initialization and authentication.

API Endpoints

POST /createGroup

  • Description: Creates a new Telegram group.
  • Parameters:
    • name: Name of the group.
    • type: Type of the group.
  • Response:
    • link: Invite link to the group.