Skip to content

Telegram bot designed to provide weather data to users

License

Notifications You must be signed in to change notification settings

shishnk/weather-bot-api

Repository files navigation

License GitHub Actions Workflow Status Coveralls Website

WeatherBotApi

Overview

WeatherBotApi is an educational project aimed at learning microservices development on the .NET platform and improving skills in ASP.NET, RabbitMQ, Entity Framework, PostgreSQL, Mapster, Redis, Docker, and xUnit.

Description

WeatherBot is a Telegram bot designed to provide weather data to users. The project is implemented using a microservices architecture, consisting of three services:

  1. TelegramApi: A service responsible for handling user requests via the Telegram bot.
  2. DatabaseService: A service responsible for database operations, including storing and retrieving user data and their requests.
  3. WeatherService: A service responsible for fetching weather information from an external source.

Weather API

The wttr.in is used to provide weather, which is a console-oriented weather forecast service that supports various information representation methods like terminal-oriented ANSI-sequences for console HTTP clients (curl, httpie, or wget), HTML for web browsers, or PNG for graphical viewers.

Architecture

The following diagram illustrates the interaction between different services in the project:

flowchart TD;
    A[Telegram API] -->|Sends requests| B((RabbitMQ));
    B -->|Sends requests| D[Database Service];
    D -->|Retrieves data| B;
    B -->|Forwards requests| C[Weather Service];
    C -->|Retrieves weather data| B;

Loading

Technology Stack

  • ASP.NET
  • RabbitMQ (MassTransit can be used, but it provides a high-level API)
  • Entity Framework
  • PostgreSQL
  • Mapster
  • Docker
  • Redis
  • xUnit

Installation and Running

  1. Clone the repository:
    git clone https://github.com/shishnk/weather-bot-api.git
  2. Build Docker containers:
    git cd weather-bot-api
    docker-compose build
  3. Run containers:
    docker-compose up

Configuration

Before running the project, ensure you have configured the necessary environment variables:

  1. Telegram Bot Configuration:

    • Create a new bot via BotFather on Telegram.
    • Obtain the token for accessing the bot's API.
  2. Update the existing .env file:

    • Open file in the root directory of your project.
    • Add or update the following line in the .env file with your Telegram bot token:
      TELEGRAM_BOT_TOKEN=YOUR_TELEGRAM_BOT_TOKEN
      
    • Replace YOUR_TELEGRAM_BOT_TOKEN with your actual Telegram bot token obtained from BotFather.

Once you have updated the existing .env file with your Telegram bot token, you are ready to run the project.

Contribution and Feedback

If you have suggestions for improving the project or found a bug, please open an issue or submit a pull request. We welcome your contributions!

License

The project is licensed under the MIT license. For more information, see the LICENSE.