Music Tool Bot is the ultimate bot for managing your music files effortlessly! 🎵✨. Check it out here: @MusicToolBot
Currently, supports 6 languages: English and Persian, Russian, Spanish, French, Arabic. (Add more if you want)
- Python 3.8 or higher (Preferably)
ffmpegvenv- Optionally you can install
pm2(globally) which is a Node.js module to manage processes. Sincepm2can also manage Python processes, I use it to run the bot in production. No Node.js/JavaScript knowledge is required. Just installpm2and run convenient script runners usingmake. If you want to run the bot using other process managers, that's fine.
-
Register for a Telegram Bot:
Register a new bot at Bot Father and get a bot token. -
Clone this repo:
Rungit clone https://github.com/amirhoseinsalimi/music-tool-bot.git music-tool-bot && cd music-tool-bot -
Install Poetry (if not installed):
Follow Poetry’s official installation guide. -
Install dependencies:
Runpoetry install.
This will also create a virtual environment for the project. Run commands inside this virtual environment with:poetry run <command> -
Setup environment variables:
Runcp .env.example .env. Then put your credentials there:Field Type Description OWNER_USER_ID intThe user ID of the owner of the bot. This user has more privileges. BOT_NAME strThe name of the bot BOT_USERNAME strThe username of the bot. This username is sent as signature in captions. BOT_TOKEN strThe bot token you grabbed from @BotFather DB_NAME strDatabase name. Read the next step for more information. DEBUGGER booleanAttaches a PyCharm's debugger on port 5400BTC_WALLET_ADDRESS strBTC wallet address to receive donations. ETH_WALLET_ADDRESS strETH wallet address to receive donations. TRX_WALLET_ADDRESS strTRX wallet address to receive donations. USDT_TRC20_WALLET_ADDRESS strUSDT (TRC20) wallet address to receive donations. USDT_ERC20_WALLET_ADDRESS strUSDT (ERC20) wallet address to receive donations. SHIBA_BEP20_WALLET_ADDRESS strSHIBA (BEP20) wallet address to receive donations. SHIBA_ERC20_WALLET_ADDRESS strSHIBA (ERC20) wallet address to receive donations. DOGE_WALLET_ADDRESS strDOGE wallet address to receive donations. ZARIN_LINK_ADDRESS strZarinLink address to receive donations. -
Set up the database:
This bot persists the IDs of users and admins in a SQLite database. So you need to create a database followed by running migrations:
make db-migrate.
Then run seeds to populate theadminstable with an owner-level access:
make db-seed. -
Run the bot
a. Start the botmake start
b. Restart the botmake restart
See below for all possible commands:
Command make <cmd> |
Description |
|---|---|
dev |
Start the bot for development with hot reload thanks to jurigged |
start |
Start the bot for production using pm2 module. Creates a process called music-tool-bot |
restart |
Restarts the bot process with the name music-tool-bot |
stop |
Stops the bot process with the name music-tool-bot |
db:migrate |
Run migrations |
db:refresh |
Rollback all migration and re-run them (Use with caution) |
db:status |
Print the status of migrations |
db:seed |
Run seeds to create a user with owner privileges |
test |
Run tests (Not implemented yet) |
t |
Alias for test command |
You can also run the bot in Docker, without installing Python, Poetry, or ffmpeg on your machine.
-
Clone the repo
git clone https://github.com/amirhoseinsalimi/music-tool-bot.git music-tool-bot cd music-tool-bot -
Prepare your environment file
cp .env.example .envFill in your bot credentials as explained above. -
Run database migrations
docker compose -f docker-compose.yaml -f docker-compose.dev.yaml run --rm bot make db-migrate docker compose -f docker-compose.yaml -f docker-compose.dev.yaml run --rm bot make db-seed
-
Start the bot (development mode with hot reload)
docker compose -f docker-compose.yaml -f docker-compose.dev.yaml upThe SQLite database will appear in your local
./data/directory. -
Start the bot (production mode)
docker compose -f docker-compose.yaml -f docker-compose.prod.yaml up -d
In the beginning, I had written this bot in JavaScript, but due to a lack of quality packages, it was full of bugs. Then
I decided to learn Python and thought: Why not re-write @MusicToolBot in Python? And then I began to revive the
project.
This tiny bot is my first practical Python project. I tried to learn Python along with coding, so I could better wrap my head around the syntax and the built-in functionality of the language. However, as a novice Python developer, I know this bot can be written in a more smart way with better code structure. So, if you know Python, I would really appreciate any help to make this kid better. My main concern is the application structure, but please feel free to create PRs, open discussions and make small fixes (like typos). In addition, I have some plans and features for this bot, you can find them on the issue board. Also, I'd be very appreciated if you can translate the bot to your language.