SportMatchBot is a C# Telegram bot that helps you track friendly sports tournaments. It supports multiple sports and languages, logs match results, shows standings and top scorers, and lets you undo the last entry.
SportMatchBot lets users register match results via Telegram commands, view up-to-date standings and top scorers, and manage matches in a conversational flow. It’s built using the Telegram.Bot library and follows a modular architecture with handlers, services, and models.
-
User Interaction & Commands
- /start – Show a localized welcome message.
- /help – Display a list of available commands and basic instructions.
- /match – Begin registering a new match:
- Select sport.
- Select Team 1 and Team 2.
- Enter scores for each team.
- (Optional) Select scorers if enabled.
- Confirm or cancel the match.
- /info – View current standings and top scorers for a selected sport.
- /undo – Remove the most recently registered match in this chat.
- Language selection – Choose your preferred language (supported: en, it, fr, de, es).
-
Localization
All user-facing text is stored in per-language JSON files (e.g.en.json) inData/LocalizationFilesand loaded at runtime. -
Team Configuration
You must upload a validteams.jsonfile intoData/teams.json. You can follow the structure provided inData/teamsExample.jsonas an example to define teams, players, and scorer settings. -
State Management
Transient match state (current stage, selected teams, scores, scorers) is managed in memory per chat via a thread-safe service. -
Match Logging & Standings
Completed matches are saved inData/matches.json. Standings (points, goal differences, games played) and top scorers are computed on demand.
C:.
│ appsettings.json
│ Program.cs
│ SportMatchBot.csproj
│
├───bin
│ └───Debug
├───Data
│ │ matches.json
│ │ teams.json
│ │ teamsExample.json
│ │
│ └───LocalizationFiles
│ de.json
│ en.json
│ es.json
│ fr.json
│ it.json
│
├───Enums
│ MatchStage.cs
│
├───Handlers
│ BotUpdateHandler.cs
│
├───Models
│ MatchState.cs
│ Team.cs
│
└───Services
LocalizationService.cs
LoggerService.cs
MatchLogService.cs
StateService.cs
TeamService.cs
-
Prerequisites
- .NET 9 SDK or later.
- A Telegram Bot token (create via @BotFather).
-
Clone & Restore
git clone https://your-repo-url/SportMatchBot.git cd SportMatchBot dotnet restore -
Configure
- Open
appsettings.jsonand set yourBotTokenandLanguage(en,it,fr,de,es). - Place your
teams.jsoninData/teams.json(seeteamsExample.jsonfor format). - Ensure your chosen language file is in
Data/LocalizationFiles.
- Open
-
Run the Bot
dotnet run
-
Interact
In Telegram, send/startthen/helpto see available commands.
-
Add a new sport:
SportMatchBot dynamically retrieves available sports, teams, and players from yourteams.json. To add a new sport, simply create at least one team entry using that sport inData/teams.json. -
Add or update teams/players:
To create a new team or modify players for an existing team, edit theteams.jsonfile inDatafollowing the example inteamsExample.json. -
Add a new language:
- Copy
Data/LocalizationFiles/en.jsontoData/LocalizationFiles/{lang}.json. - Translate the values.
- Update
appsettings.jsonwith"Language": "{lang}".
- Copy