telegram
#
- class platypush.message.event.telegram.CommandMessageEvent(*args, command: str, cmdargs: List[str] | None = None, **kwargs)[source]#
Bases:
MessageEvent
Event triggered when a new message is received by the Telegram bot.
- __init__(*args, command: str, cmdargs: List[str] | None = None, **kwargs)[source]#
- Parameters:
command – Command name.
cmdargs – Command arguments.
- as_dict()#
Converts the event into a dictionary
- classmethod build(msg)#
Builds an event message from a JSON UTF-8 string/bytearray, a dictionary, or another Event
- matches_condition(condition)#
If the event matches an event condition, it will return an EventMatchResult :param condition: The platypush.event.hook.EventCondition object
- classmethod parse(msg)#
Parse a generic message into a key-value dictionary
- Parameters:
msg – Original message. It can be a dictionary, a Message, or a string/bytearray, as long as it’s valid UTF-8 JSON
- classmethod to_dict(msg)#
Converts a Message object into a dictionary
- Parameters:
msg – Message object
- class platypush.message.event.telegram.ContactMessageEvent(*args, message: dict | None, user: dict | None, **kwargs)[source]#
Bases:
MessageEvent
Event triggered when a new contact message is received by the Telegram bot.
- __init__(*args, message: dict | None, user: dict | None, **kwargs)#
- Parameters:
message –
{ "audio_duration": 86, "audio_file_id": "string", "audio_file_size": 64, "audio_mime_type": "string", "audio_performer": "string", "audio_title": "string", "caption": "string", "chat_firstname": "string", "chat_id": 81, "chat_lastname": "string", "chat_username": "string", "contact_first_name": "string", "contact_last_name": "string", "contact_phone_number": "string", "contact_user_id": 80, "contact_vcard": "string", "creation_date": "date", "document_file_id": "string", "document_file_name": "string", "document_file_size": 90, "document_mime_type": "string", "edit_date": "date", "forward_date": "date", "forward_from_message_id": 91, "from_firstname": "string", "from_lastname": "string", "from_user_id": 20, "from_username": "string", "link": "string", "location_latitude": 51, "location_longitude": 28, "media_group_id": "string", "message_id": 30, "photo_file_id": "string", "photo_file_size": 91, "photo_height": 65, "photo_width": 45, "text": "string", "video_duration": 83, "video_file_id": "string", "video_file_size": 79, "video_height": 14, "video_mime_type": "string", "video_width": 62 }
user –
{ "first_name": "string", "is_bot": true, "language_code": "string", "last_name": "string", "link": "string", "user_id": 39, "username": "string" }
- as_dict()#
Converts the event into a dictionary
- classmethod build(msg)#
Builds an event message from a JSON UTF-8 string/bytearray, a dictionary, or another Event
- matches_condition(condition)#
If the event matches an event condition, it will return an EventMatchResult :param condition: The platypush.event.hook.EventCondition object
- classmethod parse(msg)#
Parse a generic message into a key-value dictionary
- Parameters:
msg – Original message. It can be a dictionary, a Message, or a string/bytearray, as long as it’s valid UTF-8 JSON
- classmethod to_dict(msg)#
Converts a Message object into a dictionary
- Parameters:
msg – Message object
- class platypush.message.event.telegram.DocumentMessageEvent(*args, message: dict | None, user: dict | None, **kwargs)[source]#
Bases:
MessageEvent
Event triggered when a new document message is received by the Telegram bot.
- __init__(*args, message: dict | None, user: dict | None, **kwargs)#
- Parameters:
message –
{ "audio_duration": 1, "audio_file_id": "string", "audio_file_size": 13, "audio_mime_type": "string", "audio_performer": "string", "audio_title": "string", "caption": "string", "chat_firstname": "string", "chat_id": 97, "chat_lastname": "string", "chat_username": "string", "contact_first_name": "string", "contact_last_name": "string", "contact_phone_number": "string", "contact_user_id": 29, "contact_vcard": "string", "creation_date": "date", "document_file_id": "string", "document_file_name": "string", "document_file_size": 19, "document_mime_type": "string", "edit_date": "date", "forward_date": "date", "forward_from_message_id": 93, "from_firstname": "string", "from_lastname": "string", "from_user_id": 87, "from_username": "string", "link": "string", "location_latitude": 88, "location_longitude": 87, "media_group_id": "string", "message_id": 28, "photo_file_id": "string", "photo_file_size": 17, "photo_height": 84, "photo_width": 18, "text": "string", "video_duration": 30, "video_file_id": "string", "video_file_size": 24, "video_height": 44, "video_mime_type": "string", "video_width": 80 }
user –
{ "first_name": "string", "is_bot": false, "language_code": "string", "last_name": "string", "link": "string", "user_id": 93, "username": "string" }
- as_dict()#
Converts the event into a dictionary
- classmethod build(msg)#
Builds an event message from a JSON UTF-8 string/bytearray, a dictionary, or another Event
- matches_condition(condition)#
If the event matches an event condition, it will return an EventMatchResult :param condition: The platypush.event.hook.EventCondition object
- classmethod parse(msg)#
Parse a generic message into a key-value dictionary
- Parameters:
msg – Original message. It can be a dictionary, a Message, or a string/bytearray, as long as it’s valid UTF-8 JSON
- classmethod to_dict(msg)#
Converts a Message object into a dictionary
- Parameters:
msg – Message object
- class platypush.message.event.telegram.GroupChatCreatedEvent(*args, message: dict | None, user: dict | None, **kwargs)[source]#
Bases:
MessageEvent
Event triggered when a new group chat is created.
- __init__(*args, message: dict | None, user: dict | None, **kwargs)#
- Parameters:
message –
{ "audio_duration": 8, "audio_file_id": "string", "audio_file_size": 61, "audio_mime_type": "string", "audio_performer": "string", "audio_title": "string", "caption": "string", "chat_firstname": "string", "chat_id": 24, "chat_lastname": "string", "chat_username": "string", "contact_first_name": "string", "contact_last_name": "string", "contact_phone_number": "string", "contact_user_id": 23, "contact_vcard": "string", "creation_date": "date", "document_file_id": "string", "document_file_name": "string", "document_file_size": 37, "document_mime_type": "string", "edit_date": "date", "forward_date": "date", "forward_from_message_id": 55, "from_firstname": "string", "from_lastname": "string", "from_user_id": 78, "from_username": "string", "link": "string", "location_latitude": 23, "location_longitude": 99, "media_group_id": "string", "message_id": 91, "photo_file_id": "string", "photo_file_size": 76, "photo_height": 34, "photo_width": 79, "text": "string", "video_duration": 19, "video_file_id": "string", "video_file_size": 79, "video_height": 26, "video_mime_type": "string", "video_width": 61 }
user –
{ "first_name": "string", "is_bot": false, "language_code": "string", "last_name": "string", "link": "string", "user_id": 34, "username": "string" }
- as_dict()#
Converts the event into a dictionary
- classmethod build(msg)#
Builds an event message from a JSON UTF-8 string/bytearray, a dictionary, or another Event
- matches_condition(condition)#
If the event matches an event condition, it will return an EventMatchResult :param condition: The platypush.event.hook.EventCondition object
- classmethod parse(msg)#
Parse a generic message into a key-value dictionary
- Parameters:
msg – Original message. It can be a dictionary, a Message, or a string/bytearray, as long as it’s valid UTF-8 JSON
- classmethod to_dict(msg)#
Converts a Message object into a dictionary
- Parameters:
msg – Message object
- class platypush.message.event.telegram.LocationMessageEvent(*args, message: dict | None, user: dict | None, **kwargs)[source]#
Bases:
MessageEvent
Event triggered when a new location message is received by the Telegram bot.
- __init__(*args, message: dict | None, user: dict | None, **kwargs)#
- Parameters:
message –
{ "audio_duration": 22, "audio_file_id": "string", "audio_file_size": 59, "audio_mime_type": "string", "audio_performer": "string", "audio_title": "string", "caption": "string", "chat_firstname": "string", "chat_id": 3, "chat_lastname": "string", "chat_username": "string", "contact_first_name": "string", "contact_last_name": "string", "contact_phone_number": "string", "contact_user_id": 48, "contact_vcard": "string", "creation_date": "date", "document_file_id": "string", "document_file_name": "string", "document_file_size": 89, "document_mime_type": "string", "edit_date": "date", "forward_date": "date", "forward_from_message_id": 10, "from_firstname": "string", "from_lastname": "string", "from_user_id": 80, "from_username": "string", "link": "string", "location_latitude": 69, "location_longitude": 38, "media_group_id": "string", "message_id": 60, "photo_file_id": "string", "photo_file_size": 45, "photo_height": 78, "photo_width": 60, "text": "string", "video_duration": 4, "video_file_id": "string", "video_file_size": 77, "video_height": 17, "video_mime_type": "string", "video_width": 16 }
user –
{ "first_name": "string", "is_bot": false, "language_code": "string", "last_name": "string", "link": "string", "user_id": 25, "username": "string" }
- as_dict()#
Converts the event into a dictionary
- classmethod build(msg)#
Builds an event message from a JSON UTF-8 string/bytearray, a dictionary, or another Event
- matches_condition(condition)#
If the event matches an event condition, it will return an EventMatchResult :param condition: The platypush.event.hook.EventCondition object
- classmethod parse(msg)#
Parse a generic message into a key-value dictionary
- Parameters:
msg – Original message. It can be a dictionary, a Message, or a string/bytearray, as long as it’s valid UTF-8 JSON
- classmethod to_dict(msg)#
Converts a Message object into a dictionary
- Parameters:
msg – Message object
- class platypush.message.event.telegram.MessageEvent(*args, message: dict | None, user: dict | None, **kwargs)[source]#
Bases:
TelegramEvent
Event triggered when a new message is received by the Telegram bot.
- __init__(*args, message: dict | None, user: dict | None, **kwargs)[source]#
- Parameters:
message –
{ "audio_duration": 66, "audio_file_id": "string", "audio_file_size": 32, "audio_mime_type": "string", "audio_performer": "string", "audio_title": "string", "caption": "string", "chat_firstname": "string", "chat_id": 22, "chat_lastname": "string", "chat_username": "string", "contact_first_name": "string", "contact_last_name": "string", "contact_phone_number": "string", "contact_user_id": 68, "contact_vcard": "string", "creation_date": "date", "document_file_id": "string", "document_file_name": "string", "document_file_size": 4, "document_mime_type": "string", "edit_date": "date", "forward_date": "date", "forward_from_message_id": 32, "from_firstname": "string", "from_lastname": "string", "from_user_id": 22, "from_username": "string", "link": "string", "location_latitude": 38, "location_longitude": 29, "media_group_id": "string", "message_id": 98, "photo_file_id": "string", "photo_file_size": 61, "photo_height": 70, "photo_width": 54, "text": "string", "video_duration": 61, "video_file_id": "string", "video_file_size": 24, "video_height": 86, "video_mime_type": "string", "video_width": 77 }
user –
{ "first_name": "string", "is_bot": false, "language_code": "string", "last_name": "string", "link": "string", "user_id": 20, "username": "string" }
- as_dict()#
Converts the event into a dictionary
- classmethod build(msg)#
Builds an event message from a JSON UTF-8 string/bytearray, a dictionary, or another Event
- matches_condition(condition)#
If the event matches an event condition, it will return an EventMatchResult :param condition: The platypush.event.hook.EventCondition object
- classmethod parse(msg)#
Parse a generic message into a key-value dictionary
- Parameters:
msg – Original message. It can be a dictionary, a Message, or a string/bytearray, as long as it’s valid UTF-8 JSON
- classmethod to_dict(msg)#
Converts a Message object into a dictionary
- Parameters:
msg – Message object
- class platypush.message.event.telegram.PhotoMessageEvent(*args, message: dict | None, user: dict | None, **kwargs)[source]#
Bases:
MessageEvent
Event triggered when a new photo message is received by the Telegram bot.
- __init__(*args, message: dict | None, user: dict | None, **kwargs)#
- Parameters:
message –
{ "audio_duration": 27, "audio_file_id": "string", "audio_file_size": 22, "audio_mime_type": "string", "audio_performer": "string", "audio_title": "string", "caption": "string", "chat_firstname": "string", "chat_id": 17, "chat_lastname": "string", "chat_username": "string", "contact_first_name": "string", "contact_last_name": "string", "contact_phone_number": "string", "contact_user_id": 26, "contact_vcard": "string", "creation_date": "date", "document_file_id": "string", "document_file_name": "string", "document_file_size": 39, "document_mime_type": "string", "edit_date": "date", "forward_date": "date", "forward_from_message_id": 93, "from_firstname": "string", "from_lastname": "string", "from_user_id": 20, "from_username": "string", "link": "string", "location_latitude": 52, "location_longitude": 71, "media_group_id": "string", "message_id": 14, "photo_file_id": "string", "photo_file_size": 30, "photo_height": 22, "photo_width": 61, "text": "string", "video_duration": 41, "video_file_id": "string", "video_file_size": 62, "video_height": 91, "video_mime_type": "string", "video_width": 96 }
user –
{ "first_name": "string", "is_bot": false, "language_code": "string", "last_name": "string", "link": "string", "user_id": 65, "username": "string" }
- as_dict()#
Converts the event into a dictionary
- classmethod build(msg)#
Builds an event message from a JSON UTF-8 string/bytearray, a dictionary, or another Event
- matches_condition(condition)#
If the event matches an event condition, it will return an EventMatchResult :param condition: The platypush.event.hook.EventCondition object
- classmethod parse(msg)#
Parse a generic message into a key-value dictionary
- Parameters:
msg – Original message. It can be a dictionary, a Message, or a string/bytearray, as long as it’s valid UTF-8 JSON
- classmethod to_dict(msg)#
Converts a Message object into a dictionary
- Parameters:
msg – Message object
- class platypush.message.event.telegram.TelegramEvent(*args, chat_id: int, **kwargs)[source]#
Bases:
Event
Base class for all the Telegram events.
- __init__(*args, chat_id: int, **kwargs)[source]#
- Parameters:
target (str) – Target node
origin (str) – Origin node (default: current node)
id (str) – Event ID (default: auto-generated)
timestamp (float) – Event timestamp (default: current time)
logging_level – Logging level for this event (default:
logging.INFO
)disable_web_clients_notification – Don’t send a notification of this event to the websocket clients
kwargs – Additional arguments for the event
- as_dict()#
Converts the event into a dictionary
- classmethod build(msg)#
Builds an event message from a JSON UTF-8 string/bytearray, a dictionary, or another Event
- matches_condition(condition)#
If the event matches an event condition, it will return an EventMatchResult :param condition: The platypush.event.hook.EventCondition object
- classmethod parse(msg)#
Parse a generic message into a key-value dictionary
- Parameters:
msg – Original message. It can be a dictionary, a Message, or a string/bytearray, as long as it’s valid UTF-8 JSON
- classmethod to_dict(msg)#
Converts a Message object into a dictionary
- Parameters:
msg – Message object
- class platypush.message.event.telegram.TextMessageEvent(*args, message: dict | None, user: dict | None, **kwargs)[source]#
Bases:
MessageEvent
Event triggered when a new text message is received by the Telegram bot.
- __init__(*args, message: dict | None, user: dict | None, **kwargs)#
- Parameters:
message –
{ "audio_duration": 60, "audio_file_id": "string", "audio_file_size": 71, "audio_mime_type": "string", "audio_performer": "string", "audio_title": "string", "caption": "string", "chat_firstname": "string", "chat_id": 23, "chat_lastname": "string", "chat_username": "string", "contact_first_name": "string", "contact_last_name": "string", "contact_phone_number": "string", "contact_user_id": 27, "contact_vcard": "string", "creation_date": "date", "document_file_id": "string", "document_file_name": "string", "document_file_size": 19, "document_mime_type": "string", "edit_date": "date", "forward_date": "date", "forward_from_message_id": 19, "from_firstname": "string", "from_lastname": "string", "from_user_id": 67, "from_username": "string", "link": "string", "location_latitude": 33, "location_longitude": 15, "media_group_id": "string", "message_id": 4, "photo_file_id": "string", "photo_file_size": 93, "photo_height": 62, "photo_width": 48, "text": "string", "video_duration": 99, "video_file_id": "string", "video_file_size": 23, "video_height": 43, "video_mime_type": "string", "video_width": 59 }
user –
{ "first_name": "string", "is_bot": false, "language_code": "string", "last_name": "string", "link": "string", "user_id": 83, "username": "string" }
- as_dict()#
Converts the event into a dictionary
- classmethod build(msg)#
Builds an event message from a JSON UTF-8 string/bytearray, a dictionary, or another Event
- matches_condition(condition)#
If the event matches an event condition, it will return an EventMatchResult :param condition: The platypush.event.hook.EventCondition object
- classmethod parse(msg)#
Parse a generic message into a key-value dictionary
- Parameters:
msg – Original message. It can be a dictionary, a Message, or a string/bytearray, as long as it’s valid UTF-8 JSON
- classmethod to_dict(msg)#
Converts a Message object into a dictionary
- Parameters:
msg – Message object
- class platypush.message.event.telegram.VideoMessageEvent(*args, message: dict | None, user: dict | None, **kwargs)[source]#
Bases:
MessageEvent
Event triggered when a new video message is received by the Telegram bot.
- __init__(*args, message: dict | None, user: dict | None, **kwargs)#
- Parameters:
message –
{ "audio_duration": 64, "audio_file_id": "string", "audio_file_size": 26, "audio_mime_type": "string", "audio_performer": "string", "audio_title": "string", "caption": "string", "chat_firstname": "string", "chat_id": 68, "chat_lastname": "string", "chat_username": "string", "contact_first_name": "string", "contact_last_name": "string", "contact_phone_number": "string", "contact_user_id": 62, "contact_vcard": "string", "creation_date": "date", "document_file_id": "string", "document_file_name": "string", "document_file_size": 98, "document_mime_type": "string", "edit_date": "date", "forward_date": "date", "forward_from_message_id": 10, "from_firstname": "string", "from_lastname": "string", "from_user_id": 75, "from_username": "string", "link": "string", "location_latitude": 13, "location_longitude": 89, "media_group_id": "string", "message_id": 38, "photo_file_id": "string", "photo_file_size": 47, "photo_height": 31, "photo_width": 76, "text": "string", "video_duration": 22, "video_file_id": "string", "video_file_size": 98, "video_height": 51, "video_mime_type": "string", "video_width": 44 }
user –
{ "first_name": "string", "is_bot": false, "language_code": "string", "last_name": "string", "link": "string", "user_id": 91, "username": "string" }
- as_dict()#
Converts the event into a dictionary
- classmethod build(msg)#
Builds an event message from a JSON UTF-8 string/bytearray, a dictionary, or another Event
- matches_condition(condition)#
If the event matches an event condition, it will return an EventMatchResult :param condition: The platypush.event.hook.EventCondition object
- classmethod parse(msg)#
Parse a generic message into a key-value dictionary
- Parameters:
msg – Original message. It can be a dictionary, a Message, or a string/bytearray, as long as it’s valid UTF-8 JSON
- classmethod to_dict(msg)#
Converts a Message object into a dictionary
- Parameters:
msg – Message object