Installation Guide
Prerequisites
Installation
-
Install telegram-bot-boilerplate manually or via installation master.
-
Build the solution:
dotnet build
-
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
-
Create a bot in @BotFather and obtain the bot token.
-
Clone repository to the place you want:
git clone https://github.com/tsziming/TelegramBotBoilerplate.git
-
Run “Scripts/setup.py” file and follow the instructions:
python Scripts/setup.py
Manual Installation
-
Create a bot in @BotFather and obtain the bot token.
-
Clone repository to the place you want:
git clone https://github.com/tsziming/TelegramBotBoilerplate.git
-
Open cmd / your IDE with cmd in the project folder.
-
Add your bot token from the first paragraph to dotnet user-secrets:
dotnet user-secrets set BotToken "YOUR_TOKEN"
-
Create the solution:
dotnet new solution --name "YOUR_SOLUTION_NAME"
-
Add all projects to the solution:
dotnet solution add "Source"
dotnet solution add "Tests"
-
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" } }
-
Install Entity Framework Core Tool for dotnet:
dotnet tool install --global dotnet-ef
-
Create database migration:
dotnet ef migrations add InitialCreate --project Source
-
Update database:
dotnet ef database update --project Source