This repository contains the TT2TG project, a system designed to automatically intercept messages (text, video, photo-albums) from a selected TikTok chat and send the corresponding messages to a Telegram chat.
The project consists of two main components:
- A Browser Extension that runs in the background, detects API calls for TikTok messages, and sends the JSONs to a local server.
- A Python Backend that includes:
- A lightweight Flask server to receive and collect the JSONs from the extension.
- A Telegram Bot built with
pyTelegramBotAPIthat, upon command, downloads the videos from the collected JSON usingyt-dlpand sends them to a designated chat.
- The browser extension is loaded into a Chromium-based browser (like Chrome, Edge, etc.).
- When the user in selected TikTok chat, the extension intercepts the underlying API call that contains the messages information.
- The extension constructs the JSON with API data and sends it to the local Flask server.
- The Flask server receives the JSON, checks for duplicates, and saves it to a JSON file queue.
- The user configures the bot by getting a chat ID via the
/startcommand and setting it in a configuration file. - When the user sends the
/sendcommand in the configured chat, the bot reads the URL queue, downloads each item, sends it to the chat, and archives the processed links.
- Python 3.13
- Python libraries from Core:
- You can install the bot's dependency libraries in the "CORE" directory automatically via install_core.bat/.sh file or do it manually via requirements_core.txt
- A Chromium-based web browser (e.g., Google Chrome, Microsoft Edge)
- Clone this repository to your local machine.
- Install the required Python libraries as listed above.
- Create Telegram Bot with @BotFather and get Telegram Bot Token.
- Paste your token into the
TELEGRAM_BOT_TOKENvariable (e.g.,TELEGRAM_BOT_TOKEN = "12345:your_token_here"). - You also need to set the
TARGET_CHAT_ID. Leave it asNonefor now. - Open a terminal in the project's root directory and run the server:
This will start both the Flask URL collector and the Telegram bot.
python main.py runserver
- Open your Telegram client, find your bot, and send it the
/startcommand in the chat where you want to receive files. - The bot will reply with your Chat ID. It will be a number (possibly negative). Copy this ID.
- Stop the server in your terminal (Ctrl+C).
- Go back to
bot/config.pyand paste the copied Chat ID into theTARGET_CHAT_IDvariable (e.g.,TARGET_CHAT_ID = -100123456789). - Save the
config.pyfile.
- Open your Chromium-based browser and navigate to the extensions page (e.g.,
chrome://extensions). - Enable "Developer mode".
- Click "Load unpacked" and select the
extensionfolder from this repository. - The extension will be installed and will start listening for links automatically.
- Start the Backend: If it's not already running, start the server again:
python main.py runserver
- Open a TikTok chat with the desired user. Scroll through the chat to the desired moment, the extension will automatically save messages.
- When you are ready, go back to the target chat in Telegram and send the
/sendcommand. The bot will begin downloading and sending the collected messages.
This project is licensed under the MIT License.