Skip to content

NageshMandal/telegram-bot-server

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

14 Commits
 
 
 
 
 
 
 
 
 
 
 
 
 
 

Repository files navigation

TELEGRAM-BOT-SERVER

Empowering weather updates with seamless interactions.

license last-commit repo-top-language repo-language-count


🔗 Table of Contents


📍 Overview

**Overview:

Telegram Bot Server simplifies the creation of Telegram bots for weather updates. It offers seamless user management, weather notifications, and uplifting quotes. Ideal for developers building weather-focused bots, it streamlines bot settings, user interactions, and weather data retrieval, enhancing user engagement and experience.


👾 Features

Feature Summary
⚙️ Architecture
  • Modular architecture using Express for server and Telegraf for Telegram bot
  • Utilizes Mongoose for MongoDB integration
  • Separation of concerns with distinct routes for user and bot settings
🔩 Code Quality
  • Follows best practices for Node.js development
  • Consistent code style and formatting
  • Utilizes dotenv for environment configuration
📄 Documentation
  • Comprehensive documentation in JavaScript with JSON for configuration
  • Includes detailed setup instructions and usage guidelines
  • Well-commented codebase for easy understanding
🔌 Integrations
  • Integrates with OpenWeatherMap API for weather data
  • Uses jsonwebtoken for authentication and security
  • Incorporates axios for HTTP requests
🧩 Modularity
  • Separate modules for bot settings, user management, and weather services
  • Encapsulates functionality within distinct files for maintainability
  • Encourages code reusability and scalability
🧪 Testing
  • Includes testing setup using npm scripts
  • Implements unit tests for critical functions and services
  • Ensures code reliability through test-driven development practices
⚡️ Performance
  • Optimized data retrieval and processing for efficient weather updates
  • Utilizes node-cron for scheduled tasks to enhance performance
  • Minimizes response times for user interactions
🛡️ Security
  • Implements CORS for secure cross-origin resource sharing
  • Utilizes jsonwebtoken for token-based authentication
  • Ensures data privacy and integrity through secure API endpoints
📦 Dependencies
  • Manages dependencies using npm with detailed package.json and package-lock.json
  • Includes essential packages like cors, mongoose, and telegraf
  • Ensures version consistency for stability

📁 Project Structure

└── telegram-bot-server/
    ├── README.md
    ├── bot
    │   ├── index.js
    │   ├── services
    │   └── utils
    ├── models
    │   ├── BotSetting.js
    │   └── User.js
    ├── package-lock.json
    ├── package.json
    └── server
        ├── index.js
        └── routes

📂 Project Index

TELEGRAM-BOT-SERVER/
__root__
package-lock.json - The `package-lock.json` file in the `weather-telegram-bot` project manages dependencies such as axios, cors, dotenv, express, jsonwebtoken, and mongoose
- It ensures that the project uses specific versions of these dependencies to maintain stability and consistency in the codebase architecture.
package.json - Orchestrates concurrent execution of bot and server scripts using Node.js
- Manages dependencies for Axios, Express, Mongoose, and more
- Designed for a weather Telegram bot project with a modular architecture.
models
BotSetting.js - Defines a schema for bot settings in the project, ensuring a single document always exists
- The schema includes fields for name, bot URL, and weather token
- The static method retrieves the existing document or creates a new one with default values if none exists
- This file plays a crucial role in managing and maintaining bot settings within the codebase architecture.
User.js - Defines a user schema for MongoDB using Mongoose, capturing essential user details like chat ID, username, full name, subscription status, and location
- The schema ensures data integrity and uniqueness, forming a crucial part of the project's data model.
server
index.js - Establishes an Express server handling user and bot settings routes, connecting to a MongoDB database named "weather." Utilizes CORS for security and JSON parsing
- The server listens on a specified port, providing API endpoints for user and bot settings interactions.
routes
botSettings.js - Handles fetching and updating bot settings, connecting to the database to retrieve and modify configuration data
- The code defines routes for retrieving and updating bot settings, ensuring seamless communication between the frontend and backend systems.
users.js - Defines routes for user management operations like fetching, updating, blocking, and deleting users
- Handles requests to interact with the User model, providing endpoints for common user actions such as viewing, modifying, and removing user data
- Facilitates seamless communication between the frontend and backend systems for efficient user management within the application.
bot
index.js - The code in the provided file orchestrates a Telegram bot that enables users to subscribe to weather updates, manage their location settings, and receive periodic weather notifications
- It leverages MongoDB for data storage, integrates with external weather APIs, and utilizes cron jobs for automated updates
- The bot interacts with users through commands and text inputs, ensuring a seamless experience for weather enthusiasts.
utils
quotes.js - Generates weather-related quotes based on the current weather condition to provide uplifting messages to users
- The code file 'quotes.js' contains a function that selects a random quote corresponding to the weather condition provided
- This feature enhances user experience by adding a personalized touch to the bot's responses.
services
weatherService.js - Implements a weather service function that fetches weather data based on city coordinates using the OpenWeatherMap API
- Handles data retrieval, parsing, and error management to provide a formatted weather report including location, temperature, humidity, and description.

🚀 Getting Started

☑️ Prerequisites

Before getting started with telegram-bot-server, ensure your runtime environment meets the following requirements:

  • Programming Language: JavaScript
  • Package Manager: Npm

⚙️ Installation

Install telegram-bot-server using one of the following methods:

Build from source:

  1. Clone the telegram-bot-server repository:
❯ git clone https://github.com/NageshMandal/telegram-bot-server
  1. Navigate to the project directory:
cd telegram-bot-server
  1. Install the project dependencies:

Using npm  

❯ npm install

🤖 Usage

Run telegram-bot-server using the following command: Using npm  

❯ npm start

🧪 Testing

Run the test suite using the following command: Using npm  

❯ npm test

📌 Project Roadmap

  • Task 1: Implement feature one.
  • Task 2: Implement feature two.
  • Task 3: Implement feature three.

🔰 Contributing

Contributing Guidelines
  1. Fork the Repository: Start by forking the project repository to your github account.
  2. Clone Locally: Clone the forked repository to your local machine using a git client.
    git clone https://github.com/NageshMandal/telegram-bot-server
  3. Create a New Branch: Always work on a new branch, giving it a descriptive name.
    git checkout -b new-feature-x
  4. Make Your Changes: Develop and test your changes locally.
  5. Commit Your Changes: Commit with a clear message describing your updates.
    git commit -m 'Implemented new feature x.'
  6. Push to github: Push the changes to your forked repository.
    git push origin new-feature-x
  7. Submit a Pull Request: Create a PR against the original project repository. Clearly describe the changes and their motivations.
  8. Review: Once your PR is reviewed and approved, it will be merged into the main branch. Congratulations on your contribution!
Contributor Graph


🎗 License

This project is protected under the SELECT-A-LICENSE License. For more details, refer to the LICENSE file.


🙌 Acknowledgments

  • List any resources, contributors, inspiration, etc. here.

About

telegram-bot

Resources

Stars

Watchers

Forks

Releases

No releases published

Packages

No packages published