The project is maintained with poetry. To run the bot populate your environment variables (consult the .env section), run a database (potentially, locally, for development) and run the bot with
poetry run python soundboard_tg_botTo build distributions of this project run
poetry buildYou can also build a container image from Dockerfile. Note, that building an image requires building a binary distribution first.
/start:
Adds user to the database. Responses "_Hi there! There is a list of my functions:
- /add_sound <sound_name>. Use it in order to add a new sound into my storage. This sound will be available by this name later on. ➕
- /list_sounds. Use it to view the list of sounds you added earlier that are currently available. 📌
- /delete_sound <sound_name>. I suppose it's pretty clear what this command does 🧐
- (inline) @myBotName <sound_name>. Use this command from any chat you want and choose your <sound_name>. I will send a voice message that contains your .mp3 file assosiated with this name. 🔊_"
/list_sounds:
Prints the list of sounds that were added by user and are currently available.
Responses "Your sounds are:\n📌<sound_name_1>\n📌<sound_name_2> etc..."
If there are not any sounds, responds "There are not any sounds in your
collection! Feel free to add ones by using command /add_sound <sound_name>"
/add_sound <sound_name>:
Waits for user to send a message with .mp3 file attached.
Adds this file to storage system and assosiates it with <sound_name>.
This sound will be available by this name. Following commands with the same
<sound_name> will be ignored. If need to rewrite sound, use the /delete_sound command.
If there is no <sound_name>, responses "Please tell me how to name a sound you want to attach! Tell me /add_sound <sound_name> ❌🤔" and does nothing else.
If there is already a file attached to <sound_name>, responses "I already have a sound with that name! Please come up with something else! ❌😒"
If everything is OK, responses "Got it! Now please send a message with .mp3 file attached...".
Handling the next message:
If there is no file attached, responses "Seems like there is no .mp3 file attached!_ ❌🧐" and does nothing else.
If there are more than one file attached, responses "Seems like there are too many files! ❌🤓" and does nothing else.
If summary amount of disk space allocated for this user exceeds 100mb, responses "Your disk space limit is reached! Try deleting some unused sounds first! ❌😢" and does nothing else.
If everything is OK, responses "Good job! Your sound has been successfully added! Try sending it to somebody using @MyBotName inline command! ✅😎".
If there were no file since last execution of this command for this user and the current one is OK, responses "Good job! Your sound has been successfully added! Previous attempts are forgotten! 🟨✅".
/delete_sound <sound_name>:
Deletes .mp3 file assosiated with entered name from storage.
If there is no file assosiated with entered name, responses "Didn't find a file assosiated with entered name "<sound_name>" in my storage! ❌😲" and does nothing else.
If everything is OK, responses "This sound has been successfully deleted! ✅👾".
@MyBotName <sound_name> (inline bot's function):
Sends voice message containing a file assosiated with <sound_name>.
If there is no file assosiated with entered name, responses "Didn't finda file
assosiated with entered name "<sound_name>" in my storage! ❌😲" and does
nothing else.
BOT_NAME=
BOT_TOKEN=<bot api token>
DB_HOST=<host with postgresql>
DB_NAME=<database name>
DB_USER=<name database user>
DB_PASS=<password database user>sudo apt install ffmpeg
sudo apt install fprobe
To start developing the bot, first run the postgres-in-docker instance.
./scripts/start_database.shAlso, go to BotFather on Telegram and set up a test bot (don't forget to turn on
inline mode). Set the token in your environment. The rest of the defaults for the
database you are running are already in the root .env file. After you verify
that your database started successfully, run the bot with python3 bot.py
(assuming you have all the necessary depenencies installed).