telegram#
- class platypush.message.event.telegram.CommandMessageEvent(*args, command: str, cmdargs: List[str] | None = None, **kwargs)[source]#
Bases:
MessageEventEvent 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:
MessageEventEvent 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": 98, "audio_file_id": "string", "audio_file_size": 67, "audio_mime_type": "string", "audio_performer": "string", "audio_title": "string", "caption": "string", "chat_firstname": "string", "chat_id": 91, "chat_lastname": "string", "chat_username": "string", "contact_first_name": "string", "contact_last_name": "string", "contact_phone_number": "string", "contact_user_id": 55, "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": 74, "from_firstname": "string", "from_lastname": "string", "from_user_id": 90, "from_username": "string", "link": "string", "location_latitude": 61, "location_longitude": 28, "media_group_id": "string", "message_id": 44, "photo_file_id": "string", "photo_file_size": 43, "photo_height": 7, "photo_width": 70, "text": "string", "video_duration": 29, "video_file_id": "string", "video_file_size": 13, "video_height": 42, "video_mime_type": "string", "video_width": 8 }
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:
MessageEventEvent 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": 77, "audio_file_id": "string", "audio_file_size": 88, "audio_mime_type": "string", "audio_performer": "string", "audio_title": "string", "caption": "string", "chat_firstname": "string", "chat_id": 48, "chat_lastname": "string", "chat_username": "string", "contact_first_name": "string", "contact_last_name": "string", "contact_phone_number": "string", "contact_user_id": 97, "contact_vcard": "string", "creation_date": "date", "document_file_id": "string", "document_file_name": "string", "document_file_size": 53, "document_mime_type": "string", "edit_date": "date", "forward_date": "date", "forward_from_message_id": 95, "from_firstname": "string", "from_lastname": "string", "from_user_id": 93, "from_username": "string", "link": "string", "location_latitude": 7, "location_longitude": 43, "media_group_id": "string", "message_id": 18, "photo_file_id": "string", "photo_file_size": 20, "photo_height": 62, "photo_width": 10, "text": "string", "video_duration": 1, "video_file_id": "string", "video_file_size": 75, "video_height": 57, "video_mime_type": "string", "video_width": 76 }
user –
{ "first_name": "string", "is_bot": true, "language_code": "string", "last_name": "string", "link": "string", "user_id": 47, "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:
MessageEventEvent triggered when a new group chat is created.
- __init__(*args, message: dict | None, user: dict | None, **kwargs)#
- Parameters:
message –
{ "audio_duration": 30, "audio_file_id": "string", "audio_file_size": 81, "audio_mime_type": "string", "audio_performer": "string", "audio_title": "string", "caption": "string", "chat_firstname": "string", "chat_id": 86, "chat_lastname": "string", "chat_username": "string", "contact_first_name": "string", "contact_last_name": "string", "contact_phone_number": "string", "contact_user_id": 32, "contact_vcard": "string", "creation_date": "date", "document_file_id": "string", "document_file_name": "string", "document_file_size": 65, "document_mime_type": "string", "edit_date": "date", "forward_date": "date", "forward_from_message_id": 34, "from_firstname": "string", "from_lastname": "string", "from_user_id": 53, "from_username": "string", "link": "string", "location_latitude": 6, "location_longitude": 52, "media_group_id": "string", "message_id": 82, "photo_file_id": "string", "photo_file_size": 89, "photo_height": 42, "photo_width": 87, "text": "string", "video_duration": 8, "video_file_id": "string", "video_file_size": 98, "video_height": 50, "video_mime_type": "string", "video_width": 64 }
user –
{ "first_name": "string", "is_bot": true, "language_code": "string", "last_name": "string", "link": "string", "user_id": 48, "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:
MessageEventEvent 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": 85, "audio_file_id": "string", "audio_file_size": 15, "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": 56, "contact_vcard": "string", "creation_date": "date", "document_file_id": "string", "document_file_name": "string", "document_file_size": 76, "document_mime_type": "string", "edit_date": "date", "forward_date": "date", "forward_from_message_id": 8, "from_firstname": "string", "from_lastname": "string", "from_user_id": 72, "from_username": "string", "link": "string", "location_latitude": 50, "location_longitude": 1, "media_group_id": "string", "message_id": 94, "photo_file_id": "string", "photo_file_size": 12, "photo_height": 45, "photo_width": 92, "text": "string", "video_duration": 90, "video_file_id": "string", "video_file_size": 83, "video_height": 70, "video_mime_type": "string", "video_width": 90 }
user –
{ "first_name": "string", "is_bot": false, "language_code": "string", "last_name": "string", "link": "string", "user_id": 43, "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:
TelegramEventEvent 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": 30, "audio_file_id": "string", "audio_file_size": 55, "audio_mime_type": "string", "audio_performer": "string", "audio_title": "string", "caption": "string", "chat_firstname": "string", "chat_id": 89, "chat_lastname": "string", "chat_username": "string", "contact_first_name": "string", "contact_last_name": "string", "contact_phone_number": "string", "contact_user_id": 32, "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": 98, "from_firstname": "string", "from_lastname": "string", "from_user_id": 48, "from_username": "string", "link": "string", "location_latitude": 94, "location_longitude": 33, "media_group_id": "string", "message_id": 77, "photo_file_id": "string", "photo_file_size": 51, "photo_height": 7, "photo_width": 38, "text": "string", "video_duration": 12, "video_file_id": "string", "video_file_size": 37, "video_height": 20, "video_mime_type": "string", "video_width": 36 }
user –
{ "first_name": "string", "is_bot": true, "language_code": "string", "last_name": "string", "link": "string", "user_id": 19, "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:
MessageEventEvent 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": 45, "audio_file_id": "string", "audio_file_size": 45, "audio_mime_type": "string", "audio_performer": "string", "audio_title": "string", "caption": "string", "chat_firstname": "string", "chat_id": 54, "chat_lastname": "string", "chat_username": "string", "contact_first_name": "string", "contact_last_name": "string", "contact_phone_number": "string", "contact_user_id": 86, "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": 29, "from_firstname": "string", "from_lastname": "string", "from_user_id": 23, "from_username": "string", "link": "string", "location_latitude": 38, "location_longitude": 82, "media_group_id": "string", "message_id": 62, "photo_file_id": "string", "photo_file_size": 44, "photo_height": 26, "photo_width": 50, "text": "string", "video_duration": 80, "video_file_id": "string", "video_file_size": 9, "video_height": 71, "video_mime_type": "string", "video_width": 68 }
user –
{ "first_name": "string", "is_bot": true, "language_code": "string", "last_name": "string", "link": "string", "user_id": 51, "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:
EventBase 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:
MessageEventEvent 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": 1, "audio_file_id": "string", "audio_file_size": 38, "audio_mime_type": "string", "audio_performer": "string", "audio_title": "string", "caption": "string", "chat_firstname": "string", "chat_id": 21, "chat_lastname": "string", "chat_username": "string", "contact_first_name": "string", "contact_last_name": "string", "contact_phone_number": "string", "contact_user_id": 43, "contact_vcard": "string", "creation_date": "date", "document_file_id": "string", "document_file_name": "string", "document_file_size": 2, "document_mime_type": "string", "edit_date": "date", "forward_date": "date", "forward_from_message_id": 83, "from_firstname": "string", "from_lastname": "string", "from_user_id": 74, "from_username": "string", "link": "string", "location_latitude": 64, "location_longitude": 23, "media_group_id": "string", "message_id": 20, "photo_file_id": "string", "photo_file_size": 39, "photo_height": 66, "photo_width": 22, "text": "string", "video_duration": 30, "video_file_id": "string", "video_file_size": 21, "video_height": 41, "video_mime_type": "string", "video_width": 42 }
user –
{ "first_name": "string", "is_bot": false, "language_code": "string", "last_name": "string", "link": "string", "user_id": 22, "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:
MessageEventEvent 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": 78, "audio_file_id": "string", "audio_file_size": 37, "audio_mime_type": "string", "audio_performer": "string", "audio_title": "string", "caption": "string", "chat_firstname": "string", "chat_id": 30, "chat_lastname": "string", "chat_username": "string", "contact_first_name": "string", "contact_last_name": "string", "contact_phone_number": "string", "contact_user_id": 50, "contact_vcard": "string", "creation_date": "date", "document_file_id": "string", "document_file_name": "string", "document_file_size": 78, "document_mime_type": "string", "edit_date": "date", "forward_date": "date", "forward_from_message_id": 72, "from_firstname": "string", "from_lastname": "string", "from_user_id": 10, "from_username": "string", "link": "string", "location_latitude": 68, "location_longitude": 99, "media_group_id": "string", "message_id": 36, "photo_file_id": "string", "photo_file_size": 36, "photo_height": 11, "photo_width": 16, "text": "string", "video_duration": 55, "video_file_id": "string", "video_file_size": 92, "video_height": 92, "video_mime_type": "string", "video_width": 46 }
user –
{ "first_name": "string", "is_bot": true, "language_code": "string", "last_name": "string", "link": "string", "user_id": 84, "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