TelegramBotBoilerplate

Flexible, session-based and documentated console telegram bot boilerplate.

View project on GitHub

Installation Guide

Prerequisites

Installation

  1. Install telegram-bot-boilerplate manually or via installation master.

  2. Build the solution:

     dotnet build
    
  3. Run the application with one of the following variants:

    • via compiled binary file (“Source/bin” subfolders)
    • via Visual Studio (generated *.sln file in root folder)
    • via script (“Scripts/start.py”):
    • via CLI command:
     dotnet run --project Source
    

Using Installation Master

  1. Create a bot in @BotFather and obtain the bot token.

  2. Clone repository to the place you want:

     git clone https://github.com/tsziming/TelegramBotBoilerplate.git
    
  3. Run “Scripts/setup.py” file and follow the instructions:

     python Scripts/setup.py
    

Manual Installation

  1. Create a bot in @BotFather and obtain the bot token.

  2. Clone repository to the place you want:

     git clone https://github.com/tsziming/TelegramBotBoilerplate.git
    
  3. Open cmd / your IDE with cmd in the project folder.

  4. Add your bot token from the first paragraph to dotnet user-secrets:

     dotnet user-secrets set BotToken "YOUR_TOKEN"
    
  5. Create the solution:

     dotnet new solution --name "YOUR_SOLUTION_NAME"
    
  6. Add all projects to the solution:

     dotnet solution add "Source"
    
     dotnet solution add "Tests"
    
  7. Create “appsettings.json” in the source project folder and add the “DefaultConnection” and “Provider” properties:

     {
         "ConnectionStrings": {
             "DefaultConnection": "HERE YOU PUT YOUR DATABASE CONNECTION STRING"
         },
         "Database": {
             "Provider": "CHOOSE A DATABASE PROVIDER (mysql/sqlite/postgresql/mssql)"
         }
     }
    

    Example

     {
         "ConnectionStrings": {
             "DefaultConnection": "Data Source=telegram.db"
         },
         "Database": {
             "Provider": "sqlite"
         }
     }
    
  8. Install Entity Framework Core Tool for dotnet:

     dotnet tool install --global dotnet-ef
    
  9. Create database migration:

     dotnet ef migrations add InitialCreate --project Source
    
  10. Update database:

    dotnet ef database update --project Source