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": 71, "audio_file_id": "string", "audio_file_size": 19, "audio_mime_type": "string", "audio_performer": "string", "audio_title": "string", "caption": "string", "chat_firstname": "string", "chat_id": 52, "chat_lastname": "string", "chat_username": "string", "contact_first_name": "string", "contact_last_name": "string", "contact_phone_number": "string", "contact_user_id": 38, "contact_vcard": "string", "creation_date": "date", "document_file_id": "string", "document_file_name": "string", "document_file_size": 34, "document_mime_type": "string", "edit_date": "date", "forward_date": "date", "forward_from_message_id": 30, "from_firstname": "string", "from_lastname": "string", "from_user_id": 81, "from_username": "string", "link": "string", "location_latitude": 90, "location_longitude": 26, "media_group_id": "string", "message_id": 51, "photo_file_id": "string", "photo_file_size": 7, "photo_height": 8, "photo_width": 65, "text": "string", "video_duration": 21, "video_file_id": "string", "video_file_size": 27, "video_height": 1, "video_mime_type": "string", "video_width": 37 }
user –
{ "first_name": "string", "is_bot": true, "language_code": "string", "last_name": "string", "link": "string", "user_id": 80, "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": 49, "audio_file_id": "string", "audio_file_size": 28, "audio_mime_type": "string", "audio_performer": "string", "audio_title": "string", "caption": "string", "chat_firstname": "string", "chat_id": 52, "chat_lastname": "string", "chat_username": "string", "contact_first_name": "string", "contact_last_name": "string", "contact_phone_number": "string", "contact_user_id": 69, "contact_vcard": "string", "creation_date": "date", "document_file_id": "string", "document_file_name": "string", "document_file_size": 17, "document_mime_type": "string", "edit_date": "date", "forward_date": "date", "forward_from_message_id": 38, "from_firstname": "string", "from_lastname": "string", "from_user_id": 68, "from_username": "string", "link": "string", "location_latitude": 88, "location_longitude": 87, "media_group_id": "string", "message_id": 10, "photo_file_id": "string", "photo_file_size": 60, "photo_height": 82, "photo_width": 32, "text": "string", "video_duration": 69, "video_file_id": "string", "video_file_size": 90, "video_height": 58, "video_mime_type": "string", "video_width": 57 }
user –
{ "first_name": "string", "is_bot": false, "language_code": "string", "last_name": "string", "link": "string", "user_id": 45, "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": 93, "audio_file_id": "string", "audio_file_size": 18, "audio_mime_type": "string", "audio_performer": "string", "audio_title": "string", "caption": "string", "chat_firstname": "string", "chat_id": 27, "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": 18, "document_mime_type": "string", "edit_date": "date", "forward_date": "date", "forward_from_message_id": 27, "from_firstname": "string", "from_lastname": "string", "from_user_id": 92, "from_username": "string", "link": "string", "location_latitude": 71, "location_longitude": 53, "media_group_id": "string", "message_id": 85, "photo_file_id": "string", "photo_file_size": 68, "photo_height": 9, "photo_width": 2, "text": "string", "video_duration": 57, "video_file_id": "string", "video_file_size": 62, "video_height": 74, "video_mime_type": "string", "video_width": 69 }
user –
{ "first_name": "string", "is_bot": true, "language_code": "string", "last_name": "string", "link": "string", "user_id": 36, "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": 47, "audio_file_id": "string", "audio_file_size": 65, "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": 70, "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": 79, "from_firstname": "string", "from_lastname": "string", "from_user_id": 41, "from_username": "string", "link": "string", "location_latitude": 12, "location_longitude": 31, "media_group_id": "string", "message_id": 46, "photo_file_id": "string", "photo_file_size": 95, "photo_height": 34, "photo_width": 2, "text": "string", "video_duration": 96, "video_file_id": "string", "video_file_size": 88, "video_height": 5, "video_mime_type": "string", "video_width": 43 }
user –
{ "first_name": "string", "is_bot": true, "language_code": "string", "last_name": "string", "link": "string", "user_id": 3, "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": 15, "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": 15, "chat_lastname": "string", "chat_username": "string", "contact_first_name": "string", "contact_last_name": "string", "contact_phone_number": "string", "contact_user_id": 81, "contact_vcard": "string", "creation_date": "date", "document_file_id": "string", "document_file_name": "string", "document_file_size": 8, "document_mime_type": "string", "edit_date": "date", "forward_date": "date", "forward_from_message_id": 41, "from_firstname": "string", "from_lastname": "string", "from_user_id": 4, "from_username": "string", "link": "string", "location_latitude": 35, "location_longitude": 65, "media_group_id": "string", "message_id": 29, "photo_file_id": "string", "photo_file_size": 19, "photo_height": 84, "photo_width": 49, "text": "string", "video_duration": 72, "video_file_id": "string", "video_file_size": 84, "video_height": 41, "video_mime_type": "string", "video_width": 44 }
user –
{ "first_name": "string", "is_bot": true, "language_code": "string", "last_name": "string", "link": "string", "user_id": 56, "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": 40, "audio_file_id": "string", "audio_file_size": 43, "audio_mime_type": "string", "audio_performer": "string", "audio_title": "string", "caption": "string", "chat_firstname": "string", "chat_id": 94, "chat_lastname": "string", "chat_username": "string", "contact_first_name": "string", "contact_last_name": "string", "contact_phone_number": "string", "contact_user_id": 12, "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": 2, "from_firstname": "string", "from_lastname": "string", "from_user_id": 2, "from_username": "string", "link": "string", "location_latitude": 55, "location_longitude": 91, "media_group_id": "string", "message_id": 69, "photo_file_id": "string", "photo_file_size": 93, "photo_height": 63, "photo_width": 26, "text": "string", "video_duration": 3, "video_file_id": "string", "video_file_size": 73, "video_height": 9, "video_mime_type": "string", "video_width": 63 }
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
- 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": 72, "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": 45, "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": 86, "document_mime_type": "string", "edit_date": "date", "forward_date": "date", "forward_from_message_id": 19, "from_firstname": "string", "from_lastname": "string", "from_user_id": 18, "from_username": "string", "link": "string", "location_latitude": 47, "location_longitude": 29, "media_group_id": "string", "message_id": 27, "photo_file_id": "string", "photo_file_size": 71, "photo_height": 37, "photo_width": 69, "text": "string", "video_duration": 60, "video_file_id": "string", "video_file_size": 20, "video_height": 92, "video_mime_type": "string", "video_width": 65 }
user –
{ "first_name": "string", "is_bot": true, "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.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": 69, "audio_file_id": "string", "audio_file_size": 78, "audio_mime_type": "string", "audio_performer": "string", "audio_title": "string", "caption": "string", "chat_firstname": "string", "chat_id": 15, "chat_lastname": "string", "chat_username": "string", "contact_first_name": "string", "contact_last_name": "string", "contact_phone_number": "string", "contact_user_id": 17, "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": 97, "from_firstname": "string", "from_lastname": "string", "from_user_id": 87, "from_username": "string", "link": "string", "location_latitude": 68, "location_longitude": 28, "media_group_id": "string", "message_id": 80, "photo_file_id": "string", "photo_file_size": 21, "photo_height": 21, "photo_width": 3, "text": "string", "video_duration": 37, "video_file_id": "string", "video_file_size": 97, "video_height": 44, "video_mime_type": "string", "video_width": 23 }
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