Skip to content

This is a Telegram bot designed to shorten URLs using the TinyURL service.

Notifications You must be signed in to change notification settings

7GitGuru/TinyUrlrobot

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

7 Commits
 
 
 
 

Repository files navigation

The bot is built using the aiogram library for interacting with the Telegram Bot API. It also utilizes the pyshorteners library to shorten URLs.

  1. Commands:

    • /start: This command initiates the conversation with the bot and provides a brief introduction.
    • /help: Displays instructions on how to use the bot.
  2. Message Handlers:

    • Direct Message Handler: If a user sends a URL directly to the bot, it replies with the shortened URL.
    • Inline Handler: Users can use the bot inline in any chat by typing @tinyURLrobot followed by a URL. The bot will provide the shortened URL as an inline query result.
  3. URL Handling: The bot accepts URLs of any type, whether they start with "http:https://", "https://", or even without a prefix. It automatically appends "http:https://" if missing before shortening the URL.

Overall, this bot provides a convenient way to shorten URLs within Telegram, offering both direct message support, mention mode, and inline query functionality for seamless integration into any chat.


To run this project, you'll need to follow these steps:

  1. Set up a Telegram Bot:

    • Talk to the BotFather on Telegram to create a new bot and obtain the API token.
    • Copy the API token into the token variable in the link_shortener.py file.
  2. Install Required Libraries:

    pip install aiogram
    pip install pyshorteners
    
  3. Run the Bot:

    python link_shortener.py
    

DEMO