LinuxCommandLibrary
GitHubF-DroidGoogle Play Store

tgutil

Edit and delete Telegram messages from the command line

TLDR

Delete all messages matching text in a chat
$ tgutil -n [session] -u [chat_id] -m deleteall --text "[text]"
copy
Edit a specific message
$ tgutil -n [session] -u [me] -m edit --text "[old text]" --newtext "[new text]"
copy
Edit all matching messages
$ tgutil -n [session] -u [chat_id] -m editall --text "[old text]" --newtext "[new text]"
copy
Delete a single matching message in saved messages
$ tgutil -n [session] -u [me] -m delete --text "[text]"
copy

SYNOPSIS

tgutil -n session -u chat -m mode --text text [--newtext text]

DESCRIPTION

tgutil is a CLI tool for editing and deleting messages in Telegram chats. It is part of the telegram-cloud Python package, which provides a suite of tools for interacting with Telegram from the command line.The tool operates in four modes: `edit` modifies the first matching message, `editall` modifies all matching messages, `delete` removes the first matching message, and `deleteall` removes all matching messages containing the specified text.Install via pip: `pip install telegram-cloud`.

PARAMETERS

-n, --name SESSION

Session name (authenticated Telegram account).
-u, --username CHAT
Target chat ID or username. Use `me` for Saved Messages.
-m, --mode MODE
Operation mode: `edit`, `editall`, `delete`, `deleteall`.
--text TEXT
Text to search for in messages.
--newtext TEXT
Replacement text (required for `edit` and `editall` modes).

CAVEATS

Requires prior authentication via tglogin with a Telegram API id and hash from https://my.telegram.org. Part of the telegram-cloud package. Can only edit or delete your own messages.

SEE ALSO

tgsend(1), tgcloud(1), tginfo(1)

Copied to clipboard
Kai