Skip to main content

A Python package for sending Telegram notifications asynchronously.

Project description

DeepWhisperer

Overview

DeepWhisperer is a Python package for sending Telegram notifications asynchronously with advanced message handling. It provides a queue-based, non-blocking mechanism to send messages, images, documents, and other media via Telegram.

Key Features

  • 🚀 Asynchronous message handling via background processing
  • 🔁 Retry logic with exponential backoff for failed messages
  • 🔄 Duplicate message filtering using a TTL-based cache
  • 📦 Queue overflow handling to prevent excessive accumulation
  • 📢 Message batching to reduce API calls
  • 🖼 Support for multiple media types (photos, videos, audio, documents)
  • Function Execution Notification Decorator (deepwhisper_sentinel)

Installation

Using pip (Recommended)

pip install deepwhisperer

From Source

git clone https://github.com/yourusername/deepwhisperer.git
cd deepwhisperer
pip install -e .

Usage

1️⃣ Initializing DeepWhisperer

from deepwhisperer import DeepWhisperer

notifier = DeepWhisperer(access_token="your_telegram_bot_token")
notifier.send_message("Hello, Telegram!")

2️⃣ Using the Decorator for Function Execution Notifications

from deepwhisperer import DeepWhisperer, deepwhisper_sentinel

notifier = DeepWhisperer(access_token="your_telegram_bot_token")

@deepwhisper_sentinel(notifier, default_description="Data Processing Task")
def process_data():
    import time
    time.sleep(3)  # Simulating a task
    print("Task Completed")

process_data()

3️⃣ Sending Different Types of Messages

# Sending a photo
notifier.send_photo("path/to/photo.jpg", caption="Look at this!")

# Sending a document
notifier.send_file("path/to/document.pdf", caption="Important file")

# Sending a location
notifier.send_location(latitude=37.7749, longitude=-122.4194)

# Sending a video
notifier.send_video("path/to/video.mp4", caption="Watch this!")

Configuration & Parameters

DeepWhisperer Class Arguments

Parameter Type Default Description
access_token str Required Telegram Bot API token
chat_id str None Target chat ID (auto-detected if not provided)
max_retries int 5 Max retry attempts for failed messages
retry_delay int 3 Base delay for exponential backoff
queue_size int 100 Max message queue size before discarding
deduplication_ttl int 300 Time-to-live for duplicate message tracking
batch_interval int 15 Time window for batching text messages

Decorator Parameters (deepwhisper_sentinel)

Parameter Type Default Description
notifier DeepWhisperer Required Instance of DeepWhisperer
default_description str "Task" Default function description

Dependencies

DeepWhisperer requires the following dependencies, which are automatically installed:

[dependencies]
httpx = "*"  # Handles Telegram API requests
cachetools = "*"  # Provides TTLCache for duplicate prevention

Code Structure

To improve efficiency, helper functions have been refactored into _helpers.py.

deepwhisperer/
│── __init__.py
│── deepwhisperer.py  # Core class
│── _helpers.py       # Internal helper functions
│── decorators.py     # Function execution notifier
│── constants.py      # Store class-wide constants
│── tests/            # Test cases
│   ├── test_deepwhisperer.py
│── pyproject.toml    # Project metadata
│── README.md         # Documentation
│── LICENSE           # License file
│── .gitignore        # Ignore unnecessary files

License

This project is licensed under the MIT License. See LICENSE for details.

Author

Tom Mathews

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

deepwhisperer-0.1.0.tar.gz (13.6 kB view details)

Uploaded Source

Built Distribution

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

deepwhisperer-0.1.0-py3-none-any.whl (12.6 kB view details)

Uploaded Python 3

File details

Details for the file deepwhisperer-0.1.0.tar.gz.

File metadata

  • Download URL: deepwhisperer-0.1.0.tar.gz
  • Upload date:
  • Size: 13.6 kB
  • Tags: Source
  • Uploaded using Trusted Publishing? No
  • Uploaded via: twine/6.1.0 CPython/3.12.8

File hashes

Hashes for deepwhisperer-0.1.0.tar.gz
Algorithm Hash digest
SHA256 92d31f7773788ed285b1ea4fac33e7ec842e4afb0ea18c5a1aceaaec3598da49
MD5 3a4eeed8a19471aa1662df7b62c1ba4a
BLAKE2b-256 31d6d83829a0e5fd9dee98340b3c906272c70597df973d0b037d694d6f0060f2

See more details on using hashes here.

File details

Details for the file deepwhisperer-0.1.0-py3-none-any.whl.

File metadata

  • Download URL: deepwhisperer-0.1.0-py3-none-any.whl
  • Upload date:
  • Size: 12.6 kB
  • Tags: Python 3
  • Uploaded using Trusted Publishing? No
  • Uploaded via: twine/6.1.0 CPython/3.12.8

File hashes

Hashes for deepwhisperer-0.1.0-py3-none-any.whl
Algorithm Hash digest
SHA256 6852c707d96252d62c4e1dfc391e69b700a5281d81f3cd6a0fe519cb26e19707
MD5 47758e9fdc265e26c2d6513ca0276aa8
BLAKE2b-256 b8f08d11ffd64e580ef4288a1782d096394352a44d343f69566ea2abfcd0b8e6

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