Pingram simplifies the process of sending Telegram messages with just one line of Python code. This ultra-lightweight wrapper focuses on efficient one-way messaging without the need for complex setups, making it the ideal choice for alerts, logs, and automated notifications.
Pingram is a lightweight Python wrapper designed for seamless communication with Telegram. This tool simplifies the process of sending outbound messages via a Telegram bot, providing a streamlined solution without the need for webhooks or complex setups. Ideal for alerts, logs, or automated notifications, Pingram excels in one-way messaging that replaces traditional email and SMS notifications.
Key Features
- Simplified Messaging: Send messages, photos, documents, audio, and video with straightforward method calls like
bot.message()andbot.send_photo(). - Minimalistic Design: Built as a single-file package, Pingram ensures ease of deployment and low overhead.
- Efficiency: With a core size of approximately 20 KB, Pingram is significantly smaller than alternatives, offering an over 9× smaller footprint than
python-telegram-bot(PTB), and a ~99.7% reduction in size without dependencies.
Target Audience
Pingram is tailored for:
- Developers seeking hassle-free Telegram alerts.
- System administrators looking to replace email or SMS for routine tasks.
- Raspberry Pi and IoT project enthusiasts requiring compact tools.
- Traders and scrapers who benefit from lightweight notification systems.
Quick Start Example
Using Pingram is straightforward:
from pingram import Pingram
bot = Pingram(token="<BOT_TOKEN>")
bot.me() # Verifies bot authentication
This simple command checks the bot's setup and returns relevant information.
Media Handling
Pingram supports sending various media formats, accommodating both local file paths and URLs:
- Send Photo:
bot.send_photo(chat_id=123456789, path="https://example.com/image.jpg", caption="Test Photo")
- Send Document:
bot.send_doc(chat_id=123456789, path="https://example.com/file.pdf", caption="Monthly Report")
- Send Audio:
bot.send_audio(chat_id=123456789, path="https://example.com/audio.mp3", caption="Greetings.")
- Send Video:
bot.send_video(chat_id=123456789, path="https://example.com/video.mp4", caption="Security Footage")
Benefits of Pingram
- Zero Dependencies: Operates on minimal core functionality or can include optional HTTP transport with
httpx. - Versatile Integration: Drops into shell scripts, cron jobs, CI pipelines, and can run on various platforms including Raspberry Pi.
- Instant Notifications: Designed for reliability, Pingram sends messages swiftly without concerns of spam filters.
- Rich Media Support: Easily send different media types, enhancing communication.
Testing and Future Improvements
Pingram includes a real-world testing suite that ensures functionality by sending actual messages, which aids in identifying edge cases and validating API behavior. Future enhancements will include support for async operations, message templating, and additional robust error handling features.
For a compact yet powerful solution to manage Telegram messaging, Pingram stands as an effective choice.
No comments yet.
Sign in to be the first to comment.