is a tool for exporting Telegram group chats into static websites, preserving the chat history like mailing list archives.
Project description
tg-archive is a tool for exporting Telegram group chats into static websites, preserving chat history like mailing list archives.
Preview
The @fossunited Telegram group archive.
How it works
tg-archive uses the Telethon Telegram API client to periodically sync messages from a group to a local SQLite database (file), downloading only new messages since the last sync. It then generates a static archive website of messages to be published anywhere.
Features
- Periodically sync Telegram group messages to a local DB.
- Download user avatars locally.
- Download and embed media (files, documents, photos).
- Renders poll results.
- Use emoji alternatives in place of stickers.
- Single file Jinja HTML template for generating the static site.
- Year / Month / Day indexes with deep linking across pages.
- "In reply to" on replies with links to parent messages across pages.
- RSS / Atom feed of recent messages.
Install
- Get Telegram API credentials. Normal user account API and not the Bot API.
- If this page produces an alert stating only "ERROR", disconnect from any proxy/vpn and try again in a different browser.
- Install with
pip3 install tg-archive
(tested with Python 3.8.6).
Usage
tg-archive --new --path=mysite
(creates a new site.cd
into mysite and editconfig.yaml
).tg-archive --sync
(syncs data intodata.sqlite
). Note: First time connection will prompt for your phone number + a Telegram auth code sent to the app. On successful auth, asession.session
file is created. DO NOT SHARE this session file publicly as it contains the API autorization for your account.tg-archive --build
(builds the static site into thesite
directory, which can be published)
Customization
Edit the generated template.html
and static assets in the ./static
directory to customize the site.
Note
- The sync can be stopped (Ctrl+C) any time to be resumed later.
- Setup a cron job to periodically sync messages and re-publish the archive.
- Downloading large media files and long message history from large groups continuously may run into Telegram API's rate limits. Watch the debug output.
Licensed under the MIT license.
Project details
Release history Release notifications | RSS feed
Download files
Download the file for your platform. If you're not sure which to choose, learn more about installing packages.
Source Distribution
File details
Details for the file tg-archive-1.2.2.tar.gz
.
File metadata
- Download URL: tg-archive-1.2.2.tar.gz
- Upload date:
- Size: 29.3 kB
- Tags: Source
- Uploaded using Trusted Publishing? No
- Uploaded via: twine/5.1.1 CPython/3.12.6
File hashes
Algorithm | Hash digest | |
---|---|---|
SHA256 | 74d93f03ee7655a7e12e80cc6f4d2e33916d2e62027521b9be4b7f142dc9d878 |
|
MD5 | 54684c8807ef739f925dd5b4c248442c |
|
BLAKE2b-256 | 60bbe0c755add848c659f1764834c193ca0379738acde61fd1d0e71dc3614050 |