WAYG Music Bot
Inline search for a Navidrome / Subsonic music library.
The bot downloads tracks from Navidrome and uploads them to a private Telegram
storage channel. It saves Telegram file_id values in SQLite and returns
InlineQueryResultCachedAudio results. Telegram never needs to fetch a signed
Navidrome URL directly. The cache is shared by all users of this bot.
Setup
-
Enable inline mode for the bot in BotFather with
/setinline. -
Enable inline feedback in BotFather:
/setinlinefeedback, select the bot, then select100%. This lets uploads start automatically when a result is chosen. -
Create a private storage channel and add the bot as an administrator with permission to post messages.
-
Copy
.env.exampleto.envand set the bot token, Navidrome credentials andCACHE_CHAT_ID(the channel's numeric ID, usually starting with-100). -
Install dependencies and run the bot:
uv sync uv run main.py
Type @your_bot track name in any chat and select a track. A new track first
appears as a loading message; the bot uploads it to the storage channel and replaces
that message with audio. The message also has a "Load audio" button as a fallback
if inline feedback is disabled, and a retry button if the upload fails.
Search itself never uploads tracks. Concurrent requests for the same track share
one upload, with at most two uploads active and twenty queued. Cached tracks can
be sent immediately, without starting a private conversation.
Album covers are downloaded from Navidrome, converted to JPEG thumbnails (up to 320×320 pixels and under 200 kB), and uploaded alongside the audio. If a cover is missing or cannot be downloaded, audio is still sent. Previously cached tracks with cover art are uploaded again on their next selection to add the thumbnail; messages already sent to chats are not changed.
AUDIO_CACHE_PATH defaults to .cache/audio.sqlite3. Preserve that file across
deployments to avoid uploading tracks again. Cache entries are separated by bot,
Navidrome address/account and track metadata. Keep the storage channel private.
Run offline tests with .venv/bin/python -m unittest discover -s tests.