Skip to content

roman-strilets/telegram-tools

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

1 Commit
 
 
 
 
 
 
 
 
 
 
 
 
 
 

Repository files navigation

Telegram Tools

A collection of simple TypeScript scripts for managing Telegram messages and chats.

Prerequisites

Installation

  1. Clone the repository

  2. Install dependencies:

    npm install
  3. Create a .env file in the root directory:

    API_ID=your_api_id
    API_HASH=your_api_hash
    SESSION_STRING=your_session_string

Scripts

1. Get Session String

Get your Telegram session string for authentication.

npm run get-session
  • Enter your phone number
  • Enter the verification code
  • Save the session string to your .env file as SESSION_STRING

2. Get Chats

List all your Telegram chats with their IDs.

npm run get-chats

Displays:

  • Chat name
  • Chat ID (needed for other scripts)
  • Chat type (User/Group/Channel)

3. Get Messages

Export all messages from a specific chat to an HTML file.

npm run get-messages
  • Enter the chat ID when prompted
  • Messages are sorted by date (ascending)
  • Output saved as chat_{chatId}_{timestamp}.html

4. Clean Messages

Delete all YOUR messages from a specific chat.

npm run clean-messages
  • Enter the chat ID when prompted
  • Confirm the deletion
  • Only your messages will be deleted
  • ⚠️ Warning: This action cannot be undone!

Notes

  • Session strings are sensitive - keep your .env file secure
  • Add .env to .gitignore to avoid committing credentials
  • The chat ID can be obtained using the get-chats script
  • For the clean-messages script to work, you need to have an active conversation with the user/chat

License

ISC

About

No description, website, or topics provided.

Resources

Stars

Watchers

Forks

Releases

No releases published

Packages

No packages published