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": 66, "audio_file_id": "string", "audio_file_size": 63, "audio_mime_type": "string", "audio_performer": "string", "audio_title": "string", "caption": "string", "chat_firstname": "string", "chat_id": 55, "chat_lastname": "string", "chat_username": "string", "contact_first_name": "string", "contact_last_name": "string", "contact_phone_number": "string", "contact_user_id": 90, "contact_vcard": "string", "creation_date": "date", "document_file_id": "string", "document_file_name": "string", "document_file_size": 26, "document_mime_type": "string", "edit_date": "date", "forward_date": "date", "forward_from_message_id": 95, "from_firstname": "string", "from_lastname": "string", "from_user_id": 32, "from_username": "string", "link": "string", "location_latitude": 74, "location_longitude": 53, "media_group_id": "string", "message_id": 87, "photo_file_id": "string", "photo_file_size": 82, "photo_height": 49, "photo_width": 20, "text": "string", "video_duration": 33, "video_file_id": "string", "video_file_size": 17, "video_height": 13, "video_mime_type": "string", "video_width": 41 }
user –
{ "first_name": "string", "is_bot": false, "language_code": "string", "last_name": "string", "link": "string", "user_id": 55, "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": 16, "audio_file_id": "string", "audio_file_size": 93, "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": 79, "contact_vcard": "string", "creation_date": "date", "document_file_id": "string", "document_file_name": "string", "document_file_size": 59, "document_mime_type": "string", "edit_date": "date", "forward_date": "date", "forward_from_message_id": 25, "from_firstname": "string", "from_lastname": "string", "from_user_id": 27, "from_username": "string", "link": "string", "location_latitude": 96, "location_longitude": 53, "media_group_id": "string", "message_id": 98, "photo_file_id": "string", "photo_file_size": 2, "photo_height": 48, "photo_width": 29, "text": "string", "video_duration": 31, "video_file_id": "string", "video_file_size": 4, "video_height": 46, "video_mime_type": "string", "video_width": 50 }
user –
{ "first_name": "string", "is_bot": true, "language_code": "string", "last_name": "string", "link": "string", "user_id": 98, "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": 42, "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": 63, "chat_lastname": "string", "chat_username": "string", "contact_first_name": "string", "contact_last_name": "string", "contact_phone_number": "string", "contact_user_id": 52, "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": 42, "from_firstname": "string", "from_lastname": "string", "from_user_id": 82, "from_username": "string", "link": "string", "location_latitude": 99, "location_longitude": 28, "media_group_id": "string", "message_id": 30, "photo_file_id": "string", "photo_file_size": 62, "photo_height": 44, "photo_width": 27, "text": "string", "video_duration": 84, "video_file_id": "string", "video_file_size": 43, "video_height": 36, "video_mime_type": "string", "video_width": 59 }
user –
{ "first_name": "string", "is_bot": true, "language_code": "string", "last_name": "string", "link": "string", "user_id": 73, "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": 6, "audio_file_id": "string", "audio_file_size": 87, "audio_mime_type": "string", "audio_performer": "string", "audio_title": "string", "caption": "string", "chat_firstname": "string", "chat_id": 96, "chat_lastname": "string", "chat_username": "string", "contact_first_name": "string", "contact_last_name": "string", "contact_phone_number": "string", "contact_user_id": 44, "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": 11, "from_firstname": "string", "from_lastname": "string", "from_user_id": 41, "from_username": "string", "link": "string", "location_latitude": 66, "location_longitude": 70, "media_group_id": "string", "message_id": 16, "photo_file_id": "string", "photo_file_size": 75, "photo_height": 23, "photo_width": 22, "text": "string", "video_duration": 17, "video_file_id": "string", "video_file_size": 21, "video_height": 59, "video_mime_type": "string", "video_width": 23 }
user –
{ "first_name": "string", "is_bot": false, "language_code": "string", "last_name": "string", "link": "string", "user_id": 71, "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": 78, "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": 58, "chat_lastname": "string", "chat_username": "string", "contact_first_name": "string", "contact_last_name": "string", "contact_phone_number": "string", "contact_user_id": 76, "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": 13, "from_firstname": "string", "from_lastname": "string", "from_user_id": 15, "from_username": "string", "link": "string", "location_latitude": 78, "location_longitude": 95, "media_group_id": "string", "message_id": 19, "photo_file_id": "string", "photo_file_size": 84, "photo_height": 24, "photo_width": 87, "text": "string", "video_duration": 21, "video_file_id": "string", "video_file_size": 1, "video_height": 45, "video_mime_type": "string", "video_width": 5 }
user –
{ "first_name": "string", "is_bot": true, "language_code": "string", "last_name": "string", "link": "string", "user_id": 97, "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": 64, "audio_file_id": "string", "audio_file_size": 1, "audio_mime_type": "string", "audio_performer": "string", "audio_title": "string", "caption": "string", "chat_firstname": "string", "chat_id": 10, "chat_lastname": "string", "chat_username": "string", "contact_first_name": "string", "contact_last_name": "string", "contact_phone_number": "string", "contact_user_id": 75, "contact_vcard": "string", "creation_date": "date", "document_file_id": "string", "document_file_name": "string", "document_file_size": 47, "document_mime_type": "string", "edit_date": "date", "forward_date": "date", "forward_from_message_id": 41, "from_firstname": "string", "from_lastname": "string", "from_user_id": 75, "from_username": "string", "link": "string", "location_latitude": 93, "location_longitude": 59, "media_group_id": "string", "message_id": 21, "photo_file_id": "string", "photo_file_size": 17, "photo_height": 46, "photo_width": 40, "text": "string", "video_duration": 70, "video_file_id": "string", "video_file_size": 79, "video_height": 2, "video_mime_type": "string", "video_width": 99 }
user –
{ "first_name": "string", "is_bot": false, "language_code": "string", "last_name": "string", "link": "string", "user_id": 33, "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": 60, "audio_file_id": "string", "audio_file_size": 82, "audio_mime_type": "string", "audio_performer": "string", "audio_title": "string", "caption": "string", "chat_firstname": "string", "chat_id": 82, "chat_lastname": "string", "chat_username": "string", "contact_first_name": "string", "contact_last_name": "string", "contact_phone_number": "string", "contact_user_id": 21, "contact_vcard": "string", "creation_date": "date", "document_file_id": "string", "document_file_name": "string", "document_file_size": 3, "document_mime_type": "string", "edit_date": "date", "forward_date": "date", "forward_from_message_id": 32, "from_firstname": "string", "from_lastname": "string", "from_user_id": 39, "from_username": "string", "link": "string", "location_latitude": 96, "location_longitude": 38, "media_group_id": "string", "message_id": 48, "photo_file_id": "string", "photo_file_size": 81, "photo_height": 25, "photo_width": 16, "text": "string", "video_duration": 27, "video_file_id": "string", "video_file_size": 73, "video_height": 74, "video_mime_type": "string", "video_width": 82 }
user –
{ "first_name": "string", "is_bot": false, "language_code": "string", "last_name": "string", "link": "string", "user_id": 63, "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": 49, "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": 25, "chat_lastname": "string", "chat_username": "string", "contact_first_name": "string", "contact_last_name": "string", "contact_phone_number": "string", "contact_user_id": 84, "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": 9, "from_firstname": "string", "from_lastname": "string", "from_user_id": 19, "from_username": "string", "link": "string", "location_latitude": 24, "location_longitude": 23, "media_group_id": "string", "message_id": 21, "photo_file_id": "string", "photo_file_size": 53, "photo_height": 33, "photo_width": 57, "text": "string", "video_duration": 13, "video_file_id": "string", "video_file_size": 84, "video_height": 28, "video_mime_type": "string", "video_width": 61 }
user –
{ "first_name": "string", "is_bot": true, "language_code": "string", "last_name": "string", "link": "string", "user_id": 23, "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