Skip to content

superXdev/whois-bot

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

7 Commits
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 

Repository files navigation

Telegram Bot Starter

This is a starter project for creating a Telegram bot using the Telegraf library. The project structure is organized as follows:

project-root/
├── src/
│   └── config/
│       └── config.js
│   ├── controllers/
│   ├── model/
│   ├── migrations/
│   ├── utilis/
│   ├── views/
│   ├── handler.js
│   ├── index.js
├── node_modules/
├── package.json
├── package-lock.json
├── .gitignore
└── README.md

Introduction

This project aims to provide a basic foundation for building a Telegram bot using the Telegraf library. Telegraf is a modern and powerful Node.js library for creating bots for Telegram. The project structure has been designed to maintain clean code organization, separation of concerns, and ease of maintenance.

Getting Started

Follow the steps below to set up and run the Telegram bot on your local machine.

  1. Clone the repository:
git clone https://github.com/superXdev/telegram-bot-starter
  1. Install dependencies:
npm install
  1. Copy .env file
cp env .env
  1. Configure the database connection:

Edit the src/config/config.js file and provide the necessary database connection details. This file will handle the database migration and establish the connection with the models.

  1. Run the database migration:
npm run migrate
  1. Start the bot:
npm start

Project Structure

1. src/handler.js

The handler.js file contains the main logic for handling incoming messages and commands from users. This is where you'll define the behavior of the bot based on different events, such as text messages, commands, and more.

2. src/index.js

The index.js file serves as the entry point of the application. It initializes the Telegraf bot and sets up the necessary configurations. You are advised not to modify this file unless necessary.

3. src/controllers/

The controllers folder contains all the logic for the Telegram bot. Each file in this folder corresponds to a specific functionality or feature of the bot. For example, you might have separate files for handling user authentication, data retrieval, or other operations.

4. src/model/

The model folder contains all the Sequelize models for interacting with the database. Each model represents a table in the database and encapsulates the data logic.

5. src/migrations/

The migrations folder contains all the files required for database migration. These files enable you to manage changes to the database schema in a version-controlled manner.

6. src/views/

The views folder contains JavaScript files responsible for displaying output or messages to users in the Telegram bot. Each file may represent a specific view or message format that the bot uses to communicate with users.

7. src/config/config.js

The config.js file is responsible for configuring Sequelize and establishing the database connection. It also handles the migration process to set up the database schema according to the defined models.

Contribution Guidelines

If you want to contribute to this project, please follow these guidelines:

  1. Fork the repository and create a new branch for your feature or bug fix.

  2. Make your changes and write clear, concise, and well-documented code.

  3. Run the tests (if available) and ensure that there are no errors.

  4. Submit a pull request with a detailed explanation of the changes and the problem it solves.

License

This project is licensed under the MIT License. Feel free to use, modify, and distribute the code as per the license terms.

Acknowledgments

We would like to express our gratitude to the Telegraf development team for providing an excellent library for building Telegram bots. Their hard work and dedication have made projects like this possible.

If you have any questions or feedback, please feel free to contact us. Happy bot building!

About

Whois telegram bot

Resources

License

Stars

Watchers

Forks

Releases

No releases published

Packages

No packages published