8000 GitHub - Finesse/TelegramDeletions: A CLI script to save messages deleted from a Telegram chat
[go: up one dir, main page]
More Web Proxy on the site http://driver.im/
Skip to content

Finesse/TelegramDeletions

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

7 Commits
 
 
 
 
 
 
 
 
 
 
 
 
 
 

Repository files navigation

Telegram Deletions

A simple CLI application to save messages deleted in specific Telegram chats.

How it works:

  1. The app signs-in to Telegram behalf your account
  2. The app watches all incoming messages in selected dialogs and saves them to disk
  3. When a saved message is deleted, the app posts the message to another chat

The script can't restore messages posted or deleted when it didn't run. So you should always keep it running, ideally on a server.

Installation

Requirements:

  • Python version 3.10 or newer
  • A Telegram account
  • Git (optional)

Download the code and install the dependencies:

git clone --depth 1 git@github.com:Finesse/WordleSolver.git telegram_deletions
cd telegram_deletions
python3 -m venv .venv
source ./.venv/bin/activate
python3 -m pip install --upgrade pip
python3 -m pip install -r requirements.txt
cp .env.example .env

Get a Telegram application credentials from https://my.telegram.org, under API Development. Or from https://tjhorner.dev/webogram/#/login.

Configure the app by editing the .env file (or provide the environment variable any other way):

  • TELEGRAM_APP_ID — the application id
  • TELEGRAM_APP_HASH — the application hash
  • APP_DATA_DIRECTORY (optional) — path to the directory to store data (cookie, messages) at. The running application must have permissions to read and write in the directory. The default is data.
  • Ignore the chat options for now

List your dialogs to see their ids by running:

python3 src/list_dialogs.py

When you run it the first time, it will ask your credentials to sign in.

Configure .env again:

  • APP_CHATS_TO_WATCH — id of the chat(s) to watch (integer). If multiple, must be separated by ,. You can find them after Chat id: in the dialog list.
  • APP_CHAT_TO_OUTPUT — input entity of the chat to post deleted messages (a Python function call string). Copy the part after Input entity: in the dialog list.

Usage

Run the app:

python3 src/watch_deletions.py

Keep it running. Press Ctrl+C to stop watching.

Warning

The app never deletes messages from the data directory. You should remove them manually; it's ok to delete any message when the app is running.

Running as daemon

This section tells how to configure the app as a Linux service so that the app always runs.

Connect to the server via SSH as a regular user. It must have a sudo access to execute one command. Install and configure the app following the above steps. Make sure you've called python3 src/list_dialogs.py on the server, otherwise the service will stuck on the Telegram sign-in dialog.

Important

The following steps assume the app directory is ~/telegram_deletions. If it's false in your case, adjust the commands accordingly.

Run on the server:

sudo loginctl enable-linger "$USER"

mkdir -p ~/.config/systemd/user
ln -s ~/telegram_deletions/telegram_deletions.service ~/.config/systemd/user/telegram_deletions.service
systemctl --user daemon-reload
systemctl --user enable telegram_deletions
systemctl --user start telegram_deletions

Check the logs to make sure it works:

journalctl --user -u telegram_deletions

If you want to stop and unregister the service:

systemctl --user stop telegram_deletions
systemctl --user disable telegram_deletions

About

A CLI script to save messages deleted from a Telegram chat

Topics

Resources

Stars

Watchers

Forks

Languages

0