{"id":18580429,"url":"https://github.com/gumblex/tg-export","last_synced_at":"2025-07-24T08:08:32.654Z","repository":{"id":77872606,"uuid":"44153034","full_name":"gumblex/tg-export","owner":"gumblex","description":"Export Telegram messages.","archived":false,"fork":false,"pushed_at":"2018-11-28T10:36:49.000Z","size":108,"stargazers_count":58,"open_issues_count":4,"forks_count":9,"subscribers_count":3,"default_branch":"master","last_synced_at":"2025-04-10T23:01:55.055Z","etag":null,"topics":["telegram","tg-cli"],"latest_commit_sha":null,"homepage":null,"language":"Python","has_issues":true,"has_wiki":null,"has_pages":null,"mirror_url":null,"source_name":null,"license":"lgpl-3.0","status":null,"scm":"git","pull_requests_enabled":true,"icon_url":"https://github.com/gumblex.png","metadata":{"files":{"readme":"README.md","changelog":null,"contributing":null,"funding":null,"license":"LICENSE","code_of_conduct":null,"threat_model":null,"audit":null,"citation":null,"codeowners":null,"security":null,"support":null,"governance":null,"roadmap":null,"authors":null,"dei":null,"publiccode":null,"codemeta":null}},"created_at":"2015-10-13T05:01:17.000Z","updated_at":"2025-03-28T14:52:38.000Z","dependencies_parsed_at":"2023-03-05T13:45:21.841Z","dependency_job_id":null,"html_url":"https://github.com/gumblex/tg-export","commit_stats":null,"previous_names":[],"tags_count":3,"template":false,"template_full_name":null,"purl":"pkg:github/gumblex/tg-export","repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/gumblex%2Ftg-export","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/gumblex%2Ftg-export/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/gumblex%2Ftg-export/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/gumblex%2Ftg-export/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/gumblex","download_url":"https://codeload.github.com/gumblex/tg-export/tar.gz/refs/heads/master","sbom_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/gumblex%2Ftg-export/sbom","host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":266813301,"owners_count":23988544,"icon_url":"https://github.com/github.png","version":null,"created_at":"2022-05-30T11:31:42.601Z","updated_at":"2022-07-04T15:15:14.044Z","status":"online","status_checked_at":"2025-07-24T02:00:09.469Z","response_time":99,"last_error":null,"robots_txt_status":"success","robots_txt_updated_at":"2025-07-24T06:49:26.215Z","robots_txt_url":"https://github.com/robots.txt","online":true,"can_crawl_api":true,"host_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub","repositories_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories","repository_names_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repository_names","owners_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners"}},"keywords":["telegram","tg-cli"],"created_at":"2024-11-06T23:46:03.191Z","updated_at":"2025-07-24T08:08:32.647Z","avatar_url":"https://github.com/gumblex.png","language":"Python","funding_links":[],"categories":[],"sub_categories":[],"readme":"# tg-export\n\n**Deprecation notice**: Since tg-cli is not maintained and becomes unusable, this project is deprecated. Please use alternatives like [telegram-export](https://github.com/expectocode/telegram-export) instead.\n\nExport Telegram messages, using [telegram-cli](https://github.com/vysheng/tg). [Patched version](https://github.com/gumblex/tg) recommended.\n\nThis version (v3) is compatible with `vysheng/tg/master` AND `vysheng/tg/test`\nbranches.\n\n**Note**: The database format of this version (v3) is not compatible with the old ones.\nTo convert old databases (v1 or v2), run `python3 dbconvert.py [old.db [new.db]]`\n\n## export.py\n\n```\n$ python3 export.py -h\nusage: export.py [-h] [-o OUTPUT] [-d DB] [-f] [-p PEER] [-B] [-t TIMEOUT]\n                 [-l] [-L] [-e TGBIN] [-v]\n\nExport Telegram messages.\n\noptional arguments:\n  -h, --help            show this help message and exit\n  -o OUTPUT, --output OUTPUT\n                        output path\n  -d DB, --db DB        database path\n  -f, --force           force download all messages\n  -p PEER, --peer PEER  only download messages for this peer (format:\n                        channel#id1001234567, or use partial name/title as\n                        shown in tgcli)\n  -B, --batch-only      fetch messages in batch only, don't try to get more\n                        missing messages\n  -t TIMEOUT, --timeout TIMEOUT\n                        tg-cli command timeout\n  -l, --logging         logging mode (keep running)\n  -L, --keep-logging    first export, then keep logging\n  -e TGBIN, --tgbin TGBIN\n                        telegram-cli binary path\n  -v, --verbose         print debug messages\n```\n\n**Lots** of workaround about the unreliability of tg-cli is included (in this script and `tgcli.py`), so the script itself may be unreliable as well.\n\nCommon problems with tg-cli are:\n* Dies arbitrarily.\n* No response in the socket interface.\n* Slow response in the socket interface.\n* Half response in the socket interface, while the another half appears after the timeout.\n* Returns an empty array when actually there are remaining messages.\n\n**Note**: When it's trying to get the remaining messages, the telegram-cli will crash like crazy. That's due to non-existent messages. For a quick fix, use [this fork](https://github.com/gumblex/tg) of tg-cli.\n\nWhich is called NO WARRANTY™.\n\n## logfmt.py\n\nThis script can process database written by `export.py` or [tg-chatdig](https://github.com/gumblex/tg-chatdig), and write out a human-readable format (txt, html, etc.) according to a jinja2 template.\n\n```\nusage: logfmt.py [-h] [-o OUTPUT] [-d DB] [-b BOTDB] [-D BOTDB_DEST] [-u]\n                 [-t TEMPLATE] [-P PEER_PRINT] [-l LIMIT] [-L HARDLIMIT]\n                 [-c CACHEDIR] [-r URLPREFIX]\n                 peer\n\nFormat exported database file into human-readable format.\n\npositional arguments:\n  peer                  export certain peer id or tg-cli-style peer print name\n\noptional arguments:\n  -h, --help            show this help message and exit\n  -o OUTPUT, --output OUTPUT\n                        output path\n  -d DB, --db DB        tg-export database path\n  -b BOTDB, --botdb BOTDB\n                        tg-chatdig bot database path\n  -D BOTDB_DEST, --botdb-dest BOTDB_DEST\n                        tg-chatdig bot logged chat id or tg-cli-style peer\n                        name\n  -u, --botdb-user      use user information in tg-chatdig database first\n  -t TEMPLATE, --template TEMPLATE\n                        export template, can be 'txt'(default), 'html',\n                        'json', or template file name\n  -P PEER_PRINT, --peer-print PEER_PRINT\n                        set print name for the peer\n  -l LIMIT, --limit LIMIT\n                        limit the number of fetched messages and set the\n                        offset\n  -L HARDLIMIT, --hardlimit HARDLIMIT\n                        set a hard limit of the number of messages, must be\n                        used with -l\n  -c CACHEDIR, --cachedir CACHEDIR\n                        the path of media files\n  -r URLPREFIX, --urlprefix URLPREFIX\n                        the url prefix of media files\n```\n\n## tgcli.py\nSimple wrapper for telegram-cli interface.\n\nExample:\n```python\ntgcli = TelegramCliInterface('../tg/bin/telegram-cli')\ndialogs = tgcli.cmd_dialog_list()\n```\n\n### TelegramCliInterface(cmd, extra_args=(), run=True)\n\n * `run()` starts the subprocess, needed when object created with `run=False`.\n * `send_command(cmd, timeout=180, resync=True)` sends a command to tg-cli. use `resync` for consuming text since last timeout.\n * `cmd_*(*args, **kwargs)` is the convenience method to send a command and get response. `args` are for the command, `kwargs` are arguments for `TelegramCliInterface.send_command`.\n * `on_info(text)`(callback) is called when a line of text is printed on stdout.\n * `on_json(obj)`(callback) is called with the interpreted object when a line of json is printed on stdout.\n * `on_text(text)`(callback) is called when a line of anything is printed on stdout.\n * `on_start()`(callback) is called after telegram-cli starts.\n * `on_exit()`(callback) is called after telegram-cli dies.\n * `close()` properly ends the subprocess.\n\n`do_nothing()` function does nothing. (for callbacks)\n\n`TelegramCliExited` exception is raised if telegram-cli dies when reading an answer.\n\n## License\n\nNow it's LGPLv3+.\n","project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fgumblex%2Ftg-export","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Fgumblex%2Ftg-export","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fgumblex%2Ftg-export/lists"}