ExportRobot is a Telegram bot designed to save your messages into a single HTML file. This file preserves the formatting, sender information, attachments, and other message essentials, allowing you to view your messages fully offline at any time, anywhere.
- 🌐 Offline Access: View saved messages offline without an internet connection.
- 🔍 Compressed Output: Utilizes gzip compression for message data, reducing file size.
- 📁 Single File Convenience: All messages and attachments are encapsulated in one HTML file for easy sharing and management.
- 📝 Complete Message Preservation: Retains formatting, sender info, and attachments.
- 📎 Attachment Inclusion: Includes various media attachments within the HTML file.
- 🤖 User-Friendly Interface: Simple commands to interact with the bot.
- ✏️ Customizable Export: Specify a filename for your saved messages.
- 📊 Progress Updates: Provides status updates during the export process.
- 💾 Local and Remote Saving Options: Save files locally or send them via Telegram.
- 👤 Profile Pictures Inclusion: Fetches and includes user profile pictures.
-
Saving Messages: How to save messages using the ExportRobot bot:
demo_saving.mp4
-
Viewing Saved HTML File: The saved HTML file in action, demonstrating offline viewing with full message preservation:
demo_browser.mp4
-
Clone the repository:
git clone https://github.com/Qbject/exportrobot.git cd exportrobot
-
Set up a virtual environment:
python -m venv venv source venv/bin/activate # On Windows use `venv\Scripts\activate`
-
Install the required packages:
pip install -r requirements.txt
-
Create a
.env
file in the project root and add your Telegram bot token:BOT_TOKEN=your-telegram-bot-token
To get your Telegram bot token, follow these steps:
- Open Telegram and search for the BotFather.
- Start a chat with BotFather and send the command
/start
. - Send the command
/newbot
to create a new bot. - Follow the instructions to name your bot and create a unique username for it.
- After you have successfully created your bot, BotFather will provide you with a message containing your bot token. This token will look something like
123456:ABC-DEF1234ghIkl-zyx57W2v1u123ew11
.
-
Environment Variables:
- Add your Telegram bot token to the
.env
file:BOT_TOKEN=your-telegram-bot-token
- Add your Telegram bot token to the
-
Command Line Parameters:
-
--local / -l
: Local Mode for Personal Use - Specify a local directory to save the exported HTML files. This switches the bot to an entirely different mode suitable for personal use, bypassing Telegram for saving files.--local /path/to/directory
-
--max-msgs-to-save / -m
: Set the maximum number of messages that can be saved in a single HTML file.--max-msgs-to-save 100
-
--max-attachment-size / -a
: Set the maximum allowed size (in MB) for a single attachment.--max-attachment-size 10
-
-
Running the Bot:
python src/export_robot.py
-
Interacting with the Bot:
- Start the Bot:
/start
- Forward Messages:
- Forward messages you want to save to the bot.
- Save Messages:
/save
- Optionally, specify a filename:
/export my_messages
- Optionally, specify a filename:
- Start the Bot:
-
Bot Operation:
- The bot will gather the messages and attachments, embed them in the HTML template, and save or send the resulting file.
exportrobot
├── .env
├── .gitignore
├── requirements.txt
│
├── html_template
│ ├── compile_template.py
│ ├── initial_template.tgmsg.html
│ ├── lottie.js
│ ├── main.css
│ ├── template.tgmsg.html
│ ├── tgmsg.js
│
├── src
│ ├── export_robot.py
│ ├── template.tgmsg.html
│ ├── tgbot_err.txt
│ ├── tgbot_log.txt
- .env: Environment variables file.
- .gitignore: Specifies files to ignore in the repository.
- requirements.txt: Lists the dependencies required to run the project.
- html_template: Contains the HTML template and supporting files for generating the saved message files.
- Template Generation: Develop the template in the
html_template
folder. The initial template (initial_template.tgmsg.html
) should be compiled usingcompile_template.py
and then copied astemplate.tgmsg.html
for the bot to use at runtime.
- Template Generation: Develop the template in the
- src: Contains the main bot script (
export_robot.py
) and related files. - venv: Virtual environment directory (not tracked by Git).
This project is licensed under the MIT License.