Skip to main content

Telegram Bot to share music with Odesli (former Songlink) service.

Project description

Telegram Odesli Bot

Send a song link in any (supported) music streaming service and get back a message with links in other services.

Add in Telegram: @odesli_bot

It's useful but still work in progress. Some turbulence is expected.

PyPI Azure build status Code coverage Supported versions License: GPL v3 Codestyle: Black

What is it for?

You love to share music with your friends (or be shared with), but you settled in different streaming services? With the help of this bot you can share any song link to the Bot and get all other links back in reply.

Powered by the great Odesli (former Songlink) service.

You can message the bot directly, invite it to group chats or use an inline mode (type @odesli_bot <URL>). In group chats the bot will react only to messages with music streaming links (it will also skip messages marked with special token !skip). You can promote the bot to a group admin and it will remove original message so that the chat remains tidy.

Original message Bot's replay
Original message Bot's reply

Features

  • Inline mode
  • Inline search mode
  • Private chat mode
  • Group chat mode

Supported services

Currently, the following services are supported:

  • Deezer
  • Google Music
  • SoundCloud
  • Yandex Music
  • Spotify
  • YouTube Music
  • YouTube
  • Apple Music
  • Tidal

Note that bot doesn't react to YouTube links in group chats. Reasons are here.

Privacy considerations

The bot have to have access to messages in group chats to operate (that is, it operates with disabled privacy mode). It does not store nor transfer messages anywhere. However, the only way to be completely private is to read through source code in this repository and run your copy of the bot (see section below). Or simply create a special group only for music sharing and where no sensitive information will be posted.

Running your own copy

Prerequisites

You need a Telegram bot token to run your copy of the bot. Don't worry, it can be obtained easily. Follow the instructions to create a new bot (you can set a name and a username to whatever you want). All you need is a string like 110201543:AAHdqTcvCH1vGWJxfSeofSAs0K5PALDsaw - this is your new bot token.

Additionally, disable privacy mode for your bot in a dialog with @BotFather: "Group Privacy" - "Turn off" (that is for the bot to be able to read group messages).

Bot from this repository will looks for TG_ODESLI_BOT_TG_API_TOKEN environment variable on start, thus you must set it either in shell or via .env file:

$ echo "<your_token>" > .env
$ # OR
$ TG_ODESLI_BOT_TG_API_TOKEN=<your_token> <bot_run_command (see below)>

Ones you obtain a Telegram bot token, you can run bot using either Python (3.10 or 3.11) or Docker.

Run PyPI version

Create virtual environment, install tg-odesli-bot package and run the bot with tg-odesli-bot command:

$ python -m venv botenv
$ source botenv/bin/activate
$ pip install tg-odesli-bot
$ TG_ODESLI_BOT_TG_API_TOKEN=<your_token> tg-odesli-bot

Run with Docker

Set TG_ODESLI_BOT_TG_API_TOKEN environment variable and run the image 9dogs/tg-odesli-bot (in order to use the .env file, mount it to /opt/tg-odesli-bot/.env):

$ docker run --rm -it -v /path/to/.env:/opt/tg-odesli-bot/.env 9dogs/tg-odesli-bot
# OR
$ TG_ODESLI_BOT_TG_API_TOKEN=<your_token> docker run -it --rm 9dogs/tg-odesli-bot

Run version from the repository

Clone this repository, install poetry, copy .env file into the project's root directory and run the bot:

$ git clone https://github.com/9dogs/tg-odesli-bot.git && cd tg-odesli-bot
# Install dependencies
$ poetry install
# If you have token in .env file
$ cp /path/to/.env ./
$ poetry run tg-odesli-bot
# If you specify token via shell env var
$ TG_ODESLI_BOT_TG_API_TOKEN=<your_token> poetry run tg-odesli-bot

Contributing

Contributions are welcome via GitHub pull requests. The easiest way to bootstrap development environment is to build builder target of Docker image:

$ git clone https://github.com/9dogs/tg-odesli-bot.git && cd tg-odesli-bot
$ docker build -t 9dogs/tg-odesli-bot:dev --target=builder --build-arg poetry_args= .

Then you can run a shell inside the container:

$ docker run -it --rm -v %cd%:/opt/tg-odesli-bot -v /opt/tg-odesli-bot/.venv 9dogs/tg-odesli-bot:dev bash
(container)$ make lint test

Project details


Download files

Download the file for your platform. If you're not sure which to choose, learn more about installing packages.

Source Distribution

tg_odesli_bot-0.4.1.tar.gz (28.8 kB view details)

Uploaded Source

Built Distribution

If you're not sure about the file name format, learn more about wheel file names.

tg_odesli_bot-0.4.1-py3-none-any.whl (28.0 kB view details)

Uploaded Python 3

File details

Details for the file tg_odesli_bot-0.4.1.tar.gz.

File metadata

  • Download URL: tg_odesli_bot-0.4.1.tar.gz
  • Upload date:
  • Size: 28.8 kB
  • Tags: Source
  • Uploaded using Trusted Publishing? No
  • Uploaded via: poetry/2.2.1 CPython/3.11.14 Linux/6.11.0-1018-azure

File hashes

Hashes for tg_odesli_bot-0.4.1.tar.gz
Algorithm Hash digest
SHA256 db54b0e827cc631bf2f0f42f855b1ef8a893663e0deb6d3a61cc85d443f9fb20
MD5 9bf026848c9925a86576d9351a184fe5
BLAKE2b-256 8066a117f4f61c14810a171b8d8b68dac64c968bb084da87f3a0e52b6f049a41

See more details on using hashes here.

File details

Details for the file tg_odesli_bot-0.4.1-py3-none-any.whl.

File metadata

  • Download URL: tg_odesli_bot-0.4.1-py3-none-any.whl
  • Upload date:
  • Size: 28.0 kB
  • Tags: Python 3
  • Uploaded using Trusted Publishing? No
  • Uploaded via: poetry/2.2.1 CPython/3.11.14 Linux/6.11.0-1018-azure

File hashes

Hashes for tg_odesli_bot-0.4.1-py3-none-any.whl
Algorithm Hash digest
SHA256 c62ff566af9f8186ab7432e272e61f8a795aad305a96a4f0707307473f0c4e10
MD5 a4f98a3aaa2c34a2a7401afc23487dd3
BLAKE2b-256 354b1ae415d88474450e2b627cdfa9a6ab40731558e5338cdaa1542e3631c6cb

See more details on using hashes here.

Supported by

AWS Cloud computing and Security Sponsor Datadog Monitoring Depot Continuous Integration Fastly CDN Google Download Analytics Pingdom Monitoring Sentry Error logging StatusPage Status page