
**tg-archive** is a tool for exporting Telegram group chats into static websites, preserving chat history like mailing list archives.
## Preview
The [@fossunited](https://tg.fossunited.org) Telegram group archive.

## How it works
tg-archive uses the [Telethon](https://github.com/LonamiWebs/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](https://my.telegram.org/auth?to=apps). 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
1. `tg-archive --new --path=mysite` (creates a new site. `cd` into mysite and edit `config.yaml`).
1. `tg-archive --sync` (syncs data into `data.sqlite`).
Note: First time connection will prompt for your phone number + a Telegram auth code sent to the app. On successful auth, a `session.session` file is created. DO NOT SHARE this session file publicly as it contains the API autorization for your account.
1. `tg-archive --build` (builds the static site into the `site` 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.
Raw data
{
"_id": null,
"home_page": "https://github.com/knadh/tg-archive",
"name": "tg-archive",
"maintainer": null,
"docs_url": null,
"requires_python": null,
"maintainer_email": null,
"keywords": null,
"author": "Kailash Nadh",
"author_email": "kailash@nadh.in",
"download_url": "https://files.pythonhosted.org/packages/60/bb/e0c755add848c659f1764834c193ca0379738acde61fd1d0e71dc3614050/tg-archive-1.2.2.tar.gz",
"platform": null,
"description": "\n\n\n\n**tg-archive** is a tool for exporting Telegram group chats into static websites, preserving chat history like mailing list archives.\n\n\n## Preview\nThe [@fossunited](https://tg.fossunited.org) Telegram group archive.\n\n\n\n\n## How it works\ntg-archive uses the [Telethon](https://github.com/LonamiWebs/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.\n\n## Features\n- Periodically sync Telegram group messages to a local DB.\n- Download user avatars locally.\n- Download and embed media (files, documents, photos).\n- Renders poll results.\n- Use emoji alternatives in place of stickers.\n- Single file Jinja HTML template for generating the static site.\n- Year / Month / Day indexes with deep linking across pages.\n- \"In reply to\" on replies with links to parent messages across pages.\n- RSS / Atom feed of recent messages.\n\n## Install\n- Get [Telegram API credentials](https://my.telegram.org/auth?to=apps). Normal user account API and not the Bot API.\n - If this page produces an alert stating only \"ERROR\", disconnect from any proxy/vpn and try again in a different browser.\n- Install with `pip3 install tg-archive` (tested with Python 3.8.6).\n\n### Usage\n\n1. `tg-archive --new --path=mysite` (creates a new site. `cd` into mysite and edit `config.yaml`).\n1. `tg-archive --sync` (syncs data into `data.sqlite`).\n Note: First time connection will prompt for your phone number + a Telegram auth code sent to the app. On successful auth, a `session.session` file is created. DO NOT SHARE this session file publicly as it contains the API autorization for your account.\n1. `tg-archive --build` (builds the static site into the `site` directory, which can be published)\n\n### Customization\nEdit the generated `template.html` and static assets in the `./static` directory to customize the site.\n\n### Note\n- The sync can be stopped (Ctrl+C) any time to be resumed later.\n- Setup a cron job to periodically sync messages and re-publish the archive.\n- Downloading large media files and long message history from large groups continuously may run into Telegram API's rate limits. Watch the debug output.\n\nLicensed under the MIT license.\n",
"bugtrack_url": null,
"license": "MIT License",
"summary": "is a tool for exporting Telegram group chats into static websites, preserving the chat history like mailing list archives.",
"version": "1.2.2",
"project_urls": {
"Download": "https://github.com/knadh/tg-archive",
"Homepage": "https://github.com/knadh/tg-archive"
},
"split_keywords": [],
"urls": [
{
"comment_text": "",
"digests": {
"blake2b_256": "60bbe0c755add848c659f1764834c193ca0379738acde61fd1d0e71dc3614050",
"md5": "54684c8807ef739f925dd5b4c248442c",
"sha256": "74d93f03ee7655a7e12e80cc6f4d2e33916d2e62027521b9be4b7f142dc9d878"
},
"downloads": -1,
"filename": "tg-archive-1.2.2.tar.gz",
"has_sig": false,
"md5_digest": "54684c8807ef739f925dd5b4c248442c",
"packagetype": "sdist",
"python_version": "source",
"requires_python": null,
"size": 29273,
"upload_time": "2024-10-25T07:56:12",
"upload_time_iso_8601": "2024-10-25T07:56:12.918418Z",
"url": "https://files.pythonhosted.org/packages/60/bb/e0c755add848c659f1764834c193ca0379738acde61fd1d0e71dc3614050/tg-archive-1.2.2.tar.gz",
"yanked": false,
"yanked_reason": null
}
],
"upload_time": "2024-10-25 07:56:12",
"github": true,
"gitlab": false,
"bitbucket": false,
"codeberg": false,
"github_user": "knadh",
"github_project": "tg-archive",
"travis_ci": false,
"coveralls": false,
"github_actions": false,
"requirements": [
{
"name": "telethon",
"specs": [
[
"==",
"1.29.3"
]
]
},
{
"name": "jinja2",
"specs": [
[
">=",
"2.11.3"
]
]
},
{
"name": "PyYAML",
"specs": [
[
">=",
"5.4.1"
]
]
},
{
"name": "cryptg",
"specs": [
[
"==",
"0.2.post2"
]
]
},
{
"name": "Pillow",
"specs": [
[
">=",
"8.3.2"
]
]
},
{
"name": "feedgen",
"specs": [
[
">=",
"0.9.0"
]
]
},
{
"name": "python-magic",
"specs": [
[
">=",
"0.4.24"
]
]
},
{
"name": "pytz",
"specs": [
[
">=",
"2020.5"
]
]
}
],
"lcname": "tg-archive"
}