Client Utilities
Helpers for queues, requests, notifications, controllers, fragments, and sending or editing messages.
This module contains the higher-level helpers most plugins use when they need to interact with Telegram internals without dropping into raw Java code every time.
Typical uses:
- queueing work off the UI thread
- sending Telegram requests
- sending or editing messages and media
- reaching the current fragment or account controllers
- listening to
NotificationCenter
Queues (Background Threads)
Use run_on_queue(...) for work that should not block the UI thread: network requests, file I/O, heavy parsing, or long computations.
You can target a specific queue and add a delay in milliseconds:
Available queue-name constants:
If you need the raw Java DispatchQueue, use get_queue_by_name(...):
Sending Telegram API Requests
send_request(request, fn) sends a raw Telegram TLObject through the current account's ConnectionsManager.
You pass a normal Python callback. The SDK wraps it into a RequestDelegate for you.
You usually do not need to instantiate RequestCallback manually unless you specifically want the proxy class itself.
Sending Messages and Media
The send_* helpers build the proper SendMessageParams, prepare media objects when needed, and send the final operation on the correct thread.
All send_* helpers accept optional parse_mode="HTML" or parse_mode="Markdown".
send_text
send_photo
send_document
send_video
send_audio
Low-level send_message
If you need more control, use send_message(params, parse_mode=None) directly.
It accepts a dictionary of fields that map onto SendMessagesHelper.SendMessageParams.
Commonly used keys include:
peermessagecaptionphotodocumentpathreplyToMsgreplyMarkupparamsnotifyscheduleDatettlhasMediaSpoilerssendingHighQuality
Parse mode
parse_mode is case-insensitive and currently supports only html and markdown.
When it is provided, the SDK parses either message or caption and fills entities for you.
Editing Messages
edit_message(...) edits an existing MessageObject.
You can change:
- textual content
- replacement media file
- spoiler state for replaced media
Notes:
message_objmust be a realorg.telegram.messenger.MessageObject- pass
text=when you want to replace message text or caption text - pass
file_path=when you want to replace attached media - unsupported
parse_modevalues raiseValueError
Fragments, Controllers, and Account Helpers
These helpers return the current account's commonly used Telegram components:
These helpers are thin convenience wrappers, but they keep plugin code much cleaner.
NotificationCenterDelegate
NotificationCenterDelegate is a ready-made Python base class for implementing NotificationCenter.NotificationCenterDelegate.
It is useful when you want to listen to client-side notifications from Telegram.
You do not need to wrap NotificationCenterDelegate with dynamic_proxy(...) yourself.
Subclassing it is enough.
If you need a generated Java subclass instead of a simple interface proxy, see Class Proxy.
Displaying Bulletins
For bulletins and bottom notifications, use ui.bulletin.BulletinHelper.
For the full list of supported bulletin helpers and examples, see Bulletin Helper.