YOURLS Bot

User Guide Supported Python versions Backend: python-telegram-bot Backend: python-telegram-bot Documentation Code Style Black Mentioned in Awesome YOURLS

A Telegram bot that acts as GUI for the YOURLS API. Head here for the user guide.

Clarifications:

This project

  • is not officially associated with YOURLS

  • does not provide a ready to use Telegram Bot. You need to host your own instance.

  • is not designed for large setups. More precisely it does not scale well for a large user base or YOURLS instances with great numbers of shortened URLS.

For details, please see below.

What this project does

YOURLS is an open source URL shortening service. This project allows to deploy a Telegram Bot which can be used to shorten links without having to open the corresponding website. For this to work, you need access to the YOURLS API of your instance.

Setting things up

This project assumes that your YOURLS instance has the following plugins installed:

While only some of the bots functionality relies on those plugins, it is currently not possible to deactivate it.

Moreover, the bot assumes that the YOURLS_UNIQUE_URLS setting is false, i.e. multiple short URLs can link to the same long URL.

Once your YOURLS instance is ready, install the dependencies via pip install -r requirements.txt and fill the bot.ini configuration file:

  • token: your bots token

  • admins_chat_id: your Telegram ID. Used to send error reports

  • client: URL of your YOURLS instance. The /yourls-api.php suffix can be skipped

  • signature: Your signature for the YOURLS API.

  • cache_timeout: For some of the functionality it’s necessary to get all short URLs currently stored on your YOURLS instance. This is done in a cached manner, i.e. the short URLS are retrieved at most every cache_timeout seconds. Defaults to 10 seconds.

That’s it. Run the bot via python main.py. 🤖

Note on backends

For the communication with the YOURLS API, this project uses this fork-branch of the yourls-python library.