Skip to content

alex1ozr/TelegramBot

Repository files navigation

Telegram Bot Sample

A monolithic .NET application that demonstrates how to build a Telegram bot using the Telegram.BotAPI library.

Tech stack

Bot features

Commands

  • /start - Start the bot, register the user, and show the list of available commands.
  • /help - Show the list of available commands.
  • /stats - Show the statistics of the bot usage for the last 24 hours. Available only for users with the Admin role.
  • /weather - Get the weather forecast for the specified city. This command uses the inline keyboard to select the city.
  • /set_language - Set the language for the bot. This command uses the inline keyboard to select the language (Auto / English / Russian).
  • /privacy - Show the privacy policy of the bot. The policy is GDPR compliant and includes information about the data that is collected and how it is used.
  • /donate - Show information about how to donate Telegram Stars to the bot. This command uses the inline keyboard to select the donation amount. All donations will be refunded back to the user automatically.

Prerequisites

Main

Running API

In order to run the Host, you need to have a Telegram bot token.

  • Create a new bot using the BotFather and get the token.
  • Set the Telegram:BotToken value in the Host's appsettings.json file.

Startup project

Recommended way to run the application (Telegram bot host service) using .NET Aspire.

The PostgreSQL database will be started in a Docker container and the connection string will be set automatically.

Runs the application (Telegram bot host service) as a standalone .NET application.

Make sure to have a PostgreSQL database running and the connection string is set in the appsettings.json file.

Implementation details

A detailed description of the implementation can be found in the Implementation.md file, including

  • Architecture
  • Database schema migration
  • Analytics and Metrics
  • Code Style
  • Tests
  • and more.

About

Telegram bot sample

Resources

License

Stars

Watchers

Forks

Languages