Skip to content

Telegram Bot ​

Chevereto Telegram Bot is a free and open source Telegram bot that uploads the photos, images and videos you send it to your Chevereto website. It replies with the links to the upload, ready to copy as Markdown, BBCode or HTML.

You run the bot yourself, on any computer or server that can run Docker or Python 3.10 or newer.

Create the Telegram bot ​

  • In Telegram, open a chat with @BotFather and send /newbot
  • Pick a name and a username for your bot
  • Copy the bot token that BotFather gives you

Get the bot ​

You need Git. Download the bot:

sh
git clone https://github.com/AutisticShark/Chevereto-Telegram-Bot.git
cd Chevereto-Telegram-Bot

Add Chevereto to the bot ​

You need your API key and the address of your Chevereto website.

Create a file named .env in the Chevereto-Telegram-Bot folder with the following content, and edit it to match your Telegram bot and Chevereto website:

sh
BOT_ACCESS_TOKEN=your-telegram-bot-token
BOT_ADMIN_USER_IDS=
BOT_ALLOWED_USER_IDS=
HOST_IMAGE_HOST=https://mysite.com
HOST_IMAGE_HOST_API_KEY=your-api-key
HOST_ALBUM_ID=

Replace each value with your own. Don't add comments or spaces after the values.

TIP

Your website address must not end with a slash or /api/1/upload, the bot adds the upload path for you.

These settings are optional:

SettingDescription
BOT_ADMIN_USER_IDSTelegram user IDs that can use the admin commands, separated by commas
BOT_ALLOWED_USER_IDSTelegram user IDs that can use the bot, separated by commas
HOST_ALBUM_IDID of the album where uploads go
HOST_CATEGORY_IDNumeric ID of the category for the uploads
HOST_EXPIRATIONDelete uploads after a time, for example PT5M (5 minutes) or P1D (1 day)
HOST_NSFW1 to flag uploads as not safe for work
HOST_ENABLE_VIDEOfalse to refuse video uploads

TIP

The album ID is the last part of the album URL, after the dot. For https://mysite.com/album/telegram.AbCd the album ID is AbCd.

WARNING

The bot uploads with your API key for anyone who finds it in Telegram. Set BOT_ALLOWED_USER_IDS to keep it to yourself and the people you trust.

Start the bot ​

With Docker, run:

sh
docker compose up -d

Without Docker, install the bot in a Python virtual environment and run it:

sh
python3 -m venv venv
source venv/bin/activate
pip install -r requirements.txt
python bot.py

On Windows, run .\venv\Scripts\activate instead of source venv/bin/activate.

The bot prints Starting bot in POLLING mode... when it's ready. Keep it running for the bot to stay online.

TIP

On Linux, the repository includes chevereto-bot.service to run the bot as a systemd service. Edit the folder paths in that file to match yours.

Find your Telegram user ID ​

Open a chat with your bot and send /whoami. The bot replies with your Telegram User ID.

Add it to BOT_ALLOWED_USER_IDS and BOT_ADMIN_USER_IDS in the .env file, then restart the bot.

Upload files ​

Send a photo or a file to the bot in a private chat. The bot uploads it and replies with:

  • The viewer and direct links
  • The embed codes in Markdown, BBCode and HTML
  • Viewer, Direct and Delete buttons

The text you add as caption becomes the title of the upload.

TIP

Telegram compresses photos. To upload the original file, send it as a file (📎 > File). Videos and GIFs must always be sent as a file.

Uploads can be up to 20 MB, which is the limit for files that Telegram bots can download.

Commands ​

CommandDescription
/startShow the welcome message and the commands
/helpShow the upload limits, formats and the active album
/login <key>Upload to your own account with your API key
/logoutStop using your own API key
/whoamiShow your Telegram user ID and your session
/albumShow the album where your uploads go
/album <id>Upload to another album
/album clearGo back to the default album

/login lets other people that can use the bot upload to their own account on your website. The bot deletes the message with the API key from the chat. The /album commands need /login first, except for admins. Logins and album changes last until the bot restarts.

Admins also have /uptime, /storage_status and /system_status to check the computer that runs the bot.

Need help? ​

Refer to the Chevereto Telegram Bot repository for help about the bot.

Released under the Apache-2.0 License.