π Installation and Configuration
π System Requirementsβ
Core Componentsβ
Component | Version | Notes |
---|---|---|
.NET Runtime | 8.0+ | Required for running the bot |
MySQL Server | 8.0+ | Required for data storage |
yt-dlp | 2024.04.09+ | Must be placed in the project root alongside the executable |
gallery-dl | 2024.04.09+ | Must be near (in the project root) the executable file. Downloaded separately (not included in the release) |
Supported OSβ
- Linux (x64): I used Linux Mint and CachyOS for development and use. Therefore, similar distributions should also work, the main thing is to have the basic components on your system
- Windows 10/11 (x64) - manual build required and additional verification
- macOS (x64/ARM) - not verified
π Quick Start for Linuxβ
Before you start working with the project, you need to install the necessary tools. Run the following commands if you don't have them already:
For Debian/Ubuntu:β
# Install .NET 8
wget https://packages.microsoft.com/config/ubuntu/22.04/packages-microsoft-prod.deb
sudo dpkg -i packages-microsoft-prod.deb
sudo apt update && sudo apt install -y dotnet-sdk-8.0 git mysql-server libicu-dev
# Clone and configure
git clone https://github.com/ZenonEl/TelegramMediaRelayBot. git
cd TelegramMediaRelayBot
# Download the gallery-dl binary (if you want to use it)
wget https://github.com/mikf/gallery-dl/releases/latest/download/gallery-dl.bin -O gallery-dl.bin
chmod +x gallery-dl
# Run
dotnet run --project TelegramMediaRelayBot.csproj
For Arch Linux:β
# Install dependencies
sudo pacman -S dotnet-sdk git mariadb icu
# Clone and customize
git clone https://github.com/ZenonEl/TelegramMediaRelayBot. git
cd TelegramMediaRelayBot
# Download the gallery-dl binary (if you want to use it)
wget https://github.com/mikf/gallery-dl/releases/latest/download/gallery-dl.bin -O gallery-dl.bin
chmod +x gallery-dl
# Run
dotnet run --project TelegramMediaRelayBot.csproj
For Fedora/RHEL:β
# Install . NET 8
sudo rpm -Uvh https://packages.microsoft.com/config/rhel/8/packages-microsoft-prod.rpm
sudo dnf install -y dotnet-sdk-8.0 git mysql-server libicu
# Clone and configure
git clone https://github.com/ZenonEl/TelegramMediaRelayBot.git
cd TelegramMediaRelayBot
# Download the gallery-dl binary (if you want to use it)
wget https://github.com/mikf/gallery-dl/releases/latest/download/gallery-dl.bin -O gallery-dl.bin
chmod +x gallery-dl
# Run
dotnet run --project TelegramMediaRelayBot.csproj
1.1 Running via Executableβ
- Download the latest release.
- Extract the archive to a convenient location.
- Create the
appsettings.json
file:- Use the example configuration from
appsettings.json.example
.
- Use the example configuration from
- Download gallery-dl:
wget https://github.com/mikf/gallery-dl/releases/latest/download/gallery-dl.bin -O gallery-dl.bin
chmod +x gallery-dl - Run the executable:
Ensure all other setup steps are completed before running.
./TelegramMediaRelayBot
2. Configuring MySQL/MariaDBβ
2.1 Creating a Database and Userβ
Run the following commands in MySQL/MariaDB to create a database and user:
-- Create the database
CREATE DATABASE TelegramMediaRelayBot;
-- Create the user and set the password
CREATE USER 'media_bot'@'localhost' IDENTIFIED BY 'StrongPassword123!';
-- Grant privileges to the user for the database
GRANT ALL PRIVILEGES ON TelegramMediaRelayBot.* TO 'media_bot'@'localhost';
-- Apply changes
FLUSH PRIVILEGES;
2.2 Configuration Setupβ
After configuring MySQL/MariaDB, update the appsettings.json
configuration file. Make sure that the following parameters match your MySQL/MariaDB configuration:
{
"AppSettings": {
"SqlConnectionString": "Server=localhost;Database=TelegramMediaRelayBot;User ID=media_bot;Password=StrongPassword123!;",
"DatabaseName": "TelegramMediaRelayBot"
}
}
- Server: MySQL server address (usually
localhost
if MySQL is installed on the same server or PC). - Database: Database name (in this case,
TelegramMediaRelayBot
). - User ID: Username (in this case,
media_bot
). - Password: User password (in this case,
StrongPassword123!
).
3. Working with Configurationβ
cp appsettings.json.example \
appsettings.json
# Edit the config
nano ./appsettings.json
Example configuration:
- If you don't need Tor or other proxy, leave "Proxy" empty (""") and write false in Tor.Enabled
- Apart from the values in the "AppSettings" block, you don't need to change anything else.
- The token for "TelegramBotToken" can only be obtained from the official Telegram bot BotFather.
- For the "AccessPolicy" block, refer to the dedicated guide.
{
"AppSettings": {
"TelegramBotToken": "1234:abcd",
"SqlConnectionString": "Server=localhost;Database=TelegramMediaRelayBot;User ID=media_bot;Password=StrongPassword123!;",
"DatabaseName": "TelegramMediaRelayBot",
"Language": "en-US",
"Proxy": "socks5://127.0.0.1:9050",
"UserUnMuteCheckInterval": 20,
"UseGalleryDl": true
},
"Tor": {
"Enabled": true,
"TorControlPassword": "Password",
"TorSocksHost": "127.0.0.1",
"TorSocksPort": 9050,
"TorControlPort": 9051,
"TorChangingChainInterval": 5
},
"MessageDelaySettings": {
"VideoGetDelay": 1000,
"ContactSendDelay": 1000
},
"ConsoleOutputSettings": {
"LogLevel": "Information",
"ShowVideoDownloadProgress": false,
"ShowVideoUploadProgress": false
},
"AccessPolicy": {
"Enabled": true,
"NewUsersPolicy": {
"Enabled": true,
"ShowAccessDeniedMessage": false,
"AllowNewUsers": true,
"AllowRules": {
"AllowAll": false,
"WhitelistedReferrerIds": [],
"BlacklistedReferrerIds": []
}
}
}
}