tg_sender is a Python library that transforms protobuf-based message packages into Telegram messages using the aiogram framework. It is designed to help you send various types of content (text, images, files, media groups, etc.) to Telegram channels, groups, or users, with support for advanced features like Markdown formatting, inline keyboards, message pinning, and more.
- Protobuf Integration: Accepts message data in protobuf format for structured, type-safe messaging.
- Telegram Messaging: Sends text, images, files, and media groups to Telegram via the Bot API.
- Markdown Support: Handles Markdown formatting and escaping for safe, rich-text messages.
- Inline Keyboards: Supports sending messages with inline buttons and custom markup.
- Message Management: Pin, unpin, forward, and delete messages programmatically.
- Logging: Obfuscates sensitive data in logs for security.
Install via Poetry (recommended):
poetry add tg_senderOr clone the repository and install dependencies:
git clone https://github.com/fun-limited/tg_sender.git
cd tg_sender
poetry install- Inline Keyboards: Use
send_markupto send messages with inline buttons. - Pin/Unpin/Delete: Use
Pin,Unpin, andDeletemethods for message management. - Forwarding: Use
Forwardto forward messages between chats.
SendText(bmd)— Send a text message.send_markup(bmd)— Send a message with inline keyboard.SendPhoto(bmd, path)— Send a photo with optional caption.SendMultipleImages(bmd, paths)— Send multiple images as a media group.SendFile(bmd, path)— Send a file/document.Forward(chat_id, from_chat_id, message_id, thread_id)— Forward a message.Pin(chat_id, message_id, disable_notification)— Pin a message.Unpin(chat_id, message_id)— Unpin a message.Delete(chat_id, message_id)— Delete a message.
The BaseMessageData class contains fields like:
channel: Target chat/channel username or IDtext: Message textparse_mode: Markdown/HTML formattingthread_id: (Optional) Topic/thread IDreply_to: (Optional) Message ID to reply todisable_web_page_preview: (Optional) Disable link previewsbuttons: (Optional) List of inline keyboard buttons
Contributions are welcome! Please open issues or submit pull requests for bug fixes, features, or documentation improvements.
This project is licensed under the MIT License.
For questions or support, please open an issue or contact the maintainer.