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)
Prerequisite - Create a Telegram Bot
-
Open Telegram App on your device
-
Search @BotFather and click/tap on it and send the message
/start. -
Then you will receive a message from BotFather
-
Send
/newbotand then follow the instructions given by BotFather. -
Send
/tokento get HTTP API access token.
Installation
Using pip (Recommended)
pip install deepwhisperer
From Source
gh repo clone Mathews-Tom/deepwhisperer
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 reques
cachetools = "*" # Provides TTLCache for duplicate prevention
Code Structure
deepwhisperer/
│── __init__.py
│── deepwhisperer.py # Core class
│── decorators.py # Function execution notifier
│── constants.py # Store class-wide constants
│── tests/ # Test cases
│ ├── __init__.py
│ ├── test_deepwhisperer.py
│ ├── test_decorators.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
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
Built Distribution
Filter files by name, interpreter, ABI, and platform.
If you're not sure about the file name format, learn more about wheel file names.
Copy a direct link to the current filters
File details
Details for the file deepwhisperer-0.1.1.tar.gz.
File metadata
- Download URL: deepwhisperer-0.1.1.tar.gz
- Upload date:
- Size: 13.9 kB
- Tags: Source
- Uploaded using Trusted Publishing? No
- Uploaded via: twine/6.1.0 CPython/3.12.8
File hashes
| Algorithm | Hash digest | |
|---|---|---|
| SHA256 |
917bad939271ef9104ef8bea9a345c4078f2d521849b64dabbfa039fb95b846b
|
|
| MD5 |
03e767f8b5d1d1b303edb0ddd3d84716
|
|
| BLAKE2b-256 |
8ed7bdc170399919690108e553487031db73d7f002f33ab469a4668855df6c79
|
File details
Details for the file deepwhisperer-0.1.1-py3-none-any.whl.
File metadata
- Download URL: deepwhisperer-0.1.1-py3-none-any.whl
- Upload date:
- Size: 12.7 kB
- Tags: Python 3
- Uploaded using Trusted Publishing? No
- Uploaded via: twine/6.1.0 CPython/3.12.8
File hashes
| Algorithm | Hash digest | |
|---|---|---|
| SHA256 |
5c8898f0238a808c3372412db6a1df4cf22dda6a52b4e6895aa35ed1b8b6c5b7
|
|
| MD5 |
5419f2673df04ee8ae8bb0e6b7d27894
|
|
| BLAKE2b-256 |
b8288c7dd90f3039a5b457d43538b9b8996285caaecda85992c0e9bd2bf00582
|