A monolithic .NET application that demonstrates how to build a Telegram bot using the Telegram.BotAPI library.
- .NET 8
- .NET Aspire 9 for running the application
- Entity Framework Core 8
- PostgreSQL
- MediatR
- OpenTelemetry for logs, traces, and metrics
/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 theAdminrole./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.
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:BotTokenvalue in the Host's appsettings.json file.
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.
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.