Linux command
tgutil 命令
安全
复制后可按需替换文件名、目录或参数。
常用示例
Delete all messages matching text in a chat
tgutil -n [session] -u [chat_id] -m deleteall --text "[text]"
Edit a specific message
tgutil -n [session] -u [me] -m edit --text "[old text]" --newtext "[new text]"
Edit all matching messages
tgutil -n [session] -u [chat_id] -m editall --text "[old text]" --newtext "[new text]"
Delete a single matching message in saved messages
tgutil -n [session] -u [me] -m delete --text "[text]"
说明
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`.
参数
- -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).
FAQ
What is the tgutil command used for?
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`.
How do I run a basic tgutil example?
Run `tgutil -n [session] -u [chat_id] -m deleteall --text "[text]"` in a terminal, then adjust file names, paths, flags, or remote targets for your system.
What does -n, --name _SESSION_ do in tgutil?
Session name (authenticated Telegram account).