/TgStoGifBot

A Telegram Bot can export the sticker that you sent to a .gif file, including a set of sticker.

Primary LanguagePython

📝 System Requirements


Install run-time dependencies. Make sure the path to them present in PATH variable:

  • gifski if you want to convert to GIF
  • ffmpeg if you want to convert to APNG
  • img2webp if you want to convert to WEBP

gifski is the only dependency required to convert to GIF, gif only in this repo, you may skip the rest if you don't want to convert to APNG or WEBP.

  • gifski
    • Ubuntu: Install gifski using the following command in three different ways:
      brew install gifski
      sudo snap install gifski
      cargo install gifski
    • Windows: Download the installer from the gifski website.
    • You may need to install GTk3 runtime for lottie to work properly in windows(reboot required).

🖥️ How to use


0. You may need permission to execute, read, write the script

chmod +777 ./TgStoGif -R

1. Create a bot and Request the API from Telegram

  • Create a bot using BotFather.
    • Copy the bot token and save it for later.
    • here's a guide on how to create a bot.
  • Go to Telegram API and log in.
  • Click on the API development tools link.
  • A Create new application window will appear. Fill in your application details. There is no need to enter any URL, and only the first two fields (App title and Short name) can currently be changed later.
  • Click on Create application at the end.
  • Copy api_id, api_hash, bot_token(from @BotFather) and paste them in the config.json file.

2. Install the required dependencies

  • Install the required dependencies using the following command:
pip install -r requirements.txt

3. Configure the cofing.json file

  • copy the config.json.example file to config.json and fill in the required fields.
{
  "bot_name": "your_bot_name",
  "api_id": "your_api_id",
  "api_hash": "your_api_hash",
  "bot_token": "your_bot_token",
  "proxy": {
    "status": "False", // "True" if you want to use a proxy, "False" if you don't want to use a proxy, and fill in the proxy details below, `without this note`.
    "scheme": "http",
    "hostname": "your_proxy_hostname",
    "port": "your_proxy_port"
  }
}

4. Run the script

  • Run the script using the following command:
python main.py

4. Talk to the bot

  • Send a sticker to the bot, and it will convert it to a gif and send it back to you.
  • Send a StickerSet link to the bot, and it will convert all the stickers in the set to gif and zip it then send it back to you.

For example, you can use the following sticker set link to test the bot:

/sets https://t.me/addstickers/PeopleMemes 256x256x100

256x256x100 is the size of the gif, and the quality, you can change it to any size you want. default is original size and quality 100, if you didn't provide the size and quality.

🖼️ScreenShot


Screenshot Screenshot Screenshot Screenshot

🔗 Related Repositories


  • lottie-converter - Convert Lottie animations to GIF, APNG, and WebP.
  • lottie - Render After Effects animations natively on Web, Android and iOS, and React Native.
  • pyrogram - Telegram MTProto API Client Library and Framework in Pure Python for Users and Bots.
  • gifski - GIF encoder
  • ffmpeg - A complete, cross-platform solution to record, convert and stream audio and video.