Metadata-Version: 2.4
Name: tgsweep
Version: 0.3.1
Summary: Delete your own messages, comments and reactions in the Telegram groups you select
Keywords: telegram,privacy,cleanup,delete messages,cli
Author: umbrella-at
Author-email: umbrella-at <148526531+umbrella-at@users.noreply.github.com>
License-Expression: MIT
License-File: LICENSE
Classifier: Development Status :: 4 - Beta
Classifier: Environment :: Console
Classifier: Intended Audience :: End Users/Desktop
Classifier: Operating System :: OS Independent
Classifier: Programming Language :: Python :: 3.11
Classifier: Programming Language :: Python :: 3.12
Classifier: Programming Language :: Python :: 3.13
Classifier: Programming Language :: Python :: 3.14
Classifier: Programming Language :: Python :: 3.15
Classifier: Topic :: Communications :: Chat
Requires-Dist: platformdirs>=4.3.0,<5
Requires-Dist: prompt-toolkit>=3.0.53,<3.1
Requires-Dist: pydantic>=2.14.3,<3
Requires-Dist: pyyaml>=6.0.3,<7
Requires-Dist: questionary>=2.1.1,<2.2
Requires-Dist: segno>=1.6.6,<2
Requires-Dist: telethon>=1.45.0,<2
Requires-Dist: wcwidth>=0.9.4,<1
Requires-Python: >=3.11
Project-URL: Homepage, https://tgsweep.atworks.dev/en/
Project-URL: Source, https://github.com/umbrella-at/tgsweep
Project-URL: Issues, https://github.com/umbrella-at/tgsweep/issues
Project-URL: Changelog, https://github.com/umbrella-at/tgsweep/blob/main/CHANGELOG.md
Description-Content-Type: text/markdown

# tgsweep

[![PyPI version](https://img.shields.io/pypi/v/tgsweep)](https://pypi.org/project/tgsweep/)
[![Python versions](https://img.shields.io/pypi/pyversions/tgsweep)](https://pypi.org/project/tgsweep/)
[![Tests](https://img.shields.io/github/actions/workflow/status/umbrella-at/tgsweep/tests.yml?branch=main&label=tests)](https://github.com/umbrella-at/tgsweep/actions/workflows/tests.yml)
[![License](https://img.shields.io/github/license/umbrella-at/tgsweep)](https://github.com/umbrella-at/tgsweep/blob/main/LICENSE)

English · [Русский](https://github.com/umbrella-at/tgsweep/blob/main/README.ru.md)

![tgsweep deleting messages in two selected Telegram groups](https://raw.githubusercontent.com/umbrella-at/tgsweep/main/docs/media/demo-en.gif)

Recorded on a made-up account, pauses shortened.

Deletes your messages, comments on posts and reactions in the Telegram groups you select. Runs on your computer: macOS, Windows or Linux. No server or bot needed.

Step-by-step guide for Windows, macOS and Linux: https://tgsweep.atworks.dev/en/

What tgsweep never does:

- never opens private chats, bots, Saved Messages or the Telegram service chat;
- never touches other people's messages, even if you are a group admin;
- never touches groups you created or your posts in channels;
- deletes nothing until you select chats and confirm.

## Installation

You need uv, a manager for Python programs. It installs Python by itself.

macOS and Linux, in Terminal:

```sh
curl -LsSf https://astral.sh/uv/install.sh | sh
```

Windows, in PowerShell:

```powershell
powershell -ExecutionPolicy ByPass -c "irm https://astral.sh/uv/install.ps1 | iex"
```

Then make uv available in the current window (or just open a new terminal):

macOS and Linux:

```sh
source $HOME/.local/bin/env
```

Windows, in PowerShell:

```powershell
$env:Path = "$HOME\.local\bin;$env:Path"
```

Now install tgsweep:

```sh
uv tool install tgsweep
```

uv downloads the program from PyPI, the public catalog of Python programs, together with everything it needs.

## Update

One command downloads and installs the latest version:

```sh
uv tool upgrade tgsweep
```

If you installed tgsweep earlier from the GitHub archive link, switch to the PyPI version once:

```sh
uv tool install --force tgsweep
```

## api_id and api_hash

Third-party Telegram programs need their own key. It is free:

1. Open https://my.telegram.org and sign in with your phone number. The code comes to Telegram.
2. Choose API development tools and create an application. Any title and URL will do, platform Desktop.
3. On the first run tgsweep asks for App api_id and App api_hash. The api_hash stays hidden as you type.

They are saved only on your computer.

## Usage

```sh
tgsweep
```

1. Sign in with a QR code: on your phone, Telegram > Settings > Devices > Link Desktop Device. If you have Two-Step Verification on, tgsweep asks for that password. If scanning does not work, sign in with a code: `tgsweep --code`.
2. Choose which messages to delete: all, including today's, or older than 1, 2, 7 or 30 days.
3. tgsweep finds your messages in groups and your comments on channel posts. In large chats the search takes a few minutes, and the bottom line shows which chat it is checking and how much time has passed. The next search is faster: tgsweep remembers the chats where none of your reactions were found and reads only new messages there.
4. Select chats with Space and press Enter. At first nothing is selected.
5. Type the number tgsweep shows: that many messages and reactions will be deleted. They cannot be restored.
6. Everything selected is deleted in one go, with pauses so that Telegram does not limit your account. The bottom line shows how much is deleted already. If Telegram asks to wait, tgsweep waits and says so. Ctrl+C stops after the current request, and the rest will be found on the next run.
7. At the end tgsweep offers to sign out on this computer. It is safer: the session file opens your whole account.

To sign out later: `tgsweep --logout`. You can also end the session in Telegram itself: Settings > Devices > the tgsweep session > Terminate Session.

The program uses your system language: Russian on a Russian system, English otherwise. To set it manually: `tgsweep --lang en` or `--lang ru`, the choice is remembered; back to automatic: `--lang auto`. The `TGSWEEP_LANG` variable (ru, en or auto) overrides the saved choice.

## Where the files are

| System | Folder |
|---|---|
| macOS | `~/Library/Application Support/tgsweep` |
| Windows | `%LOCALAPPDATA%\tgsweep` |
| Linux | `~/.local/share/tgsweep` |

It holds the session file (`tgsweep.session`), the api_id and api_hash (`credentials.json`), `settings.json` with the chosen language if you changed it, and the deletion log `logs/actions.jsonl`: chat and message numbers, no texts. You can set another folder with the `TGSWEEP_HOME` variable.

## Uninstall

```sh
tgsweep --logout
uv tool uninstall tgsweep
```

Then delete the folder from the table above.

## Similar tools

tgsweep is not the first tool for this. If it doesn't suit you, try [telegram-delete-all-messages](https://github.com/gurland/telegram-delete-all-messages), [TgEraser](https://github.com/en9inerd/tgeraser) or [wipemychat](https://github.com/rusq/wipemychat). What tgsweep does its own way: it searches all your groups at once and shows how many of your messages each one holds before you pick; it also finds your comments under channel posts and removes your reactions to messages from the last 90 days; it never opens private chats and skips groups you created; it asks you to type a number before deleting and keeps a log without message texts; it installs with one uv command, Python included, and signs in with a QR code.

## License

MIT
