Skip to main content

Extract and analyze data from Telegram group chats

Project description

Logo

Sleuth: Powerful telegram message extractor

Telegram Sleuth is a powerful tool designed for extracting and analyzing data from Telegram chats. this tool allows you to efficiently extract messages, media, and metadata for thorough analysis.

The extracted data can be organized chronologically by user, and media files can be downloaded into designated folders for offline access. Additionally, the parsed data can be exported into a structured CSV file, facilitating further processing and integration with other tools.

Features

  • Extract messages, media, and metadata from Telegram chats.

  • Organize messages chronologically by user for easy analysis.

  • Download shared media files (images, videos, audio, documents) into designated folders for offline access.

  • Export parsed data into a structured CSV file for further processing and integration with other tools.

Where to get it

The source code is hosted on GitHub at: https://github.com/naufalmng/telegram-sleuth

Install with PyPI

  pip install telegram-sleuth

Usage

from telegram_sleuth import Sleuth

# Authenticate with your Telegram API credentials
sleuth = Sleuth(
    api_id='YOUR_API_ID', #11513413
    api_hash='YOUR_API_HASH', #843c16a33c3c4e75f36ea546123ec2d
    username='TARGET_USERNAME',
    start_date='2023-11-20',  # Optional: Specify a start date for data extraction
    end_date='2023-11-21',    # Optional: Specify an end date for data extraction
    download_path=r'C:\Path\to\Downloads\Folder',  # Optional: Set a custom download path
    print_to_console=True  # Optional: Print messages to the console as they are extracted
)

# Extract messages and media
data = sleuth.dig()

# Export extracted data to a CSV file
sleuth.export_to_csv('chat_data.csv')

Functions

  • Sleuth(api_id, api_hash, username):

    Purpose: Initializes the Sleuth object for interacting with Telegram.

    Parameters
    api_id Your Telegram API ID (required). you can get it on https://my.telegram.org/apps.
    api_hash Your Telegram API hash (required). same source as api_id.
    username The telegram username target (required). regularly it's on the group/contact info.
    Optional Parameters
    start_date A string in the format 'YYYY-MM-DD' to specify a start date for data extraction (default: None).
    end_date A string in the format 'YYYY-MM-DD' to specify an end date for data extraction (default: None).
    download_path A path to a directory where downloaded media will be saved (default: None).
    print_to_console A boolean indicating whether to print messages to the console as they are extracted (default: False).
  • dig():

    Purpose: Extracts messages, media, and metadata from the specified chat.

    Returns: A python dictionary containing the extracted information.

  • export_to_csv(file_path):

    Purpose: Exports the extracted data to a CSV file.

    Parameter:
    file_path The path to the CSV file where the data will be saved.

License

GNU GPLv3

Support

For support, email naufalmng@gmail.com or create an issue on github page, https://github.com/naufalmng/telegram-sleuth/issues.

Project details


Download files

Download the file for your platform. If you're not sure which to choose, learn more about installing packages.

Source Distribution

telegram_sleuth-0.0.1.post7.tar.gz (17.1 kB view details)

Uploaded Source

Built Distribution

If you're not sure about the file name format, learn more about wheel file names.

telegram_sleuth-0.0.1.post7-py3-none-any.whl (17.4 kB view details)

Uploaded Python 3

File details

Details for the file telegram_sleuth-0.0.1.post7.tar.gz.

File metadata

  • Download URL: telegram_sleuth-0.0.1.post7.tar.gz
  • Upload date:
  • Size: 17.1 kB
  • Tags: Source
  • Uploaded using Trusted Publishing? No
  • Uploaded via: twine/6.1.0 CPython/3.10.6

File hashes

Hashes for telegram_sleuth-0.0.1.post7.tar.gz
Algorithm Hash digest
SHA256 4bcd51b81b1917516950724b6a4a4179215d1b6af1fcc817dbb2b464b81c85ee
MD5 da6eeea6f72c20ea31671e62b695417e
BLAKE2b-256 f6a46d1864aefa71cc7dcbc37ce11b1584315be887d760a9ab6df31fc40b9643

See more details on using hashes here.

File details

Details for the file telegram_sleuth-0.0.1.post7-py3-none-any.whl.

File metadata

File hashes

Hashes for telegram_sleuth-0.0.1.post7-py3-none-any.whl
Algorithm Hash digest
SHA256 04a9a7ef3397ac89c8775e7037d896c85f41596fa8dcd49a16979111de5d8585
MD5 2fdf211fd76fbde223db9030ef140b73
BLAKE2b-256 863136d18fcf4a430b42cee8817bb3b71401fa140bb449289fa92e3aac5731c9

See more details on using hashes here.

Supported by

AWS Cloud computing and Security Sponsor Datadog Monitoring Depot Continuous Integration Fastly CDN Google Download Analytics Pingdom Monitoring Sentry Error logging StatusPage Status page