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": 57, "audio_file_id": "string", "audio_file_size": 54, "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": 88, "contact_vcard": "string", "creation_date": "date", "document_file_id": "string", "document_file_name": "string", "document_file_size": 60, "document_mime_type": "string", "edit_date": "date", "forward_date": "date", "forward_from_message_id": 77, "from_firstname": "string", "from_lastname": "string", "from_user_id": 41, "from_username": "string", "link": "string", "location_latitude": 97, "location_longitude": 18, "media_group_id": "string", "message_id": 78, "photo_file_id": "string", "photo_file_size": 48, "photo_height": 66, "photo_width": 86, "text": "string", "video_duration": 97, "video_file_id": "string", "video_file_size": 77, "video_height": 3, "video_mime_type": "string", "video_width": 5 }
user –
{ "first_name": "string", "is_bot": false, "language_code": "string", "last_name": "string", "link": "string", "user_id": 75, "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": 75, "audio_file_id": "string", "audio_file_size": 42, "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": 53, "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": 63, "from_firstname": "string", "from_lastname": "string", "from_user_id": 52, "from_username": "string", "link": "string", "location_latitude": 56, "location_longitude": 24, "media_group_id": "string", "message_id": 93, "photo_file_id": "string", "photo_file_size": 31, "photo_height": 10, "photo_width": 31, "text": "string", "video_duration": 8, "video_file_id": "string", "video_file_size": 44, "video_height": 70, "video_mime_type": "string", "video_width": 17 }
user –
{ "first_name": "string", "is_bot": false, "language_code": "string", "last_name": "string", "link": "string", "user_id": 17, "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": 14, "audio_file_id": "string", "audio_file_size": 8, "audio_mime_type": "string", "audio_performer": "string", "audio_title": "string", "caption": "string", "chat_firstname": "string", "chat_id": 75, "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": 21, "document_mime_type": "string", "edit_date": "date", "forward_date": "date", "forward_from_message_id": 51, "from_firstname": "string", "from_lastname": "string", "from_user_id": 4, "from_username": "string", "link": "string", "location_latitude": 23, "location_longitude": 70, "media_group_id": "string", "message_id": 56, "photo_file_id": "string", "photo_file_size": 30, "photo_height": 83, "photo_width": 15, "text": "string", "video_duration": 24, "video_file_id": "string", "video_file_size": 60, "video_height": 26, "video_mime_type": "string", "video_width": 13 }
user –
{ "first_name": "string", "is_bot": false, "language_code": "string", "last_name": "string", "link": "string", "user_id": 9, "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": 4, "audio_file_id": "string", "audio_file_size": 50, "audio_mime_type": "string", "audio_performer": "string", "audio_title": "string", "caption": "string", "chat_firstname": "string", "chat_id": 26, "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": 77, "document_mime_type": "string", "edit_date": "date", "forward_date": "date", "forward_from_message_id": 18, "from_firstname": "string", "from_lastname": "string", "from_user_id": 24, "from_username": "string", "link": "string", "location_latitude": 32, "location_longitude": 43, "media_group_id": "string", "message_id": 47, "photo_file_id": "string", "photo_file_size": 72, "photo_height": 24, "photo_width": 60, "text": "string", "video_duration": 2, "video_file_id": "string", "video_file_size": 90, "video_height": 72, "video_mime_type": "string", "video_width": 21 }
user –
{ "first_name": "string", "is_bot": false, "language_code": "string", "last_name": "string", "link": "string", "user_id": 12, "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": 61, "audio_file_id": "string", "audio_file_size": 97, "audio_mime_type": "string", "audio_performer": "string", "audio_title": "string", "caption": "string", "chat_firstname": "string", "chat_id": 8, "chat_lastname": "string", "chat_username": "string", "contact_first_name": "string", "contact_last_name": "string", "contact_phone_number": "string", "contact_user_id": 39, "contact_vcard": "string", "creation_date": "date", "document_file_id": "string", "document_file_name": "string", "document_file_size": 28, "document_mime_type": "string", "edit_date": "date", "forward_date": "date", "forward_from_message_id": 62, "from_firstname": "string", "from_lastname": "string", "from_user_id": 56, "from_username": "string", "link": "string", "location_latitude": 77, "location_longitude": 9, "media_group_id": "string", "message_id": 80, "photo_file_id": "string", "photo_file_size": 91, "photo_height": 22, "photo_width": 40, "text": "string", "video_duration": 15, "video_file_id": "string", "video_file_size": 72, "video_height": 88, "video_mime_type": "string", "video_width": 9 }
user –
{ "first_name": "string", "is_bot": false, "language_code": "string", "last_name": "string", "link": "string", "user_id": 13, "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": 48, "audio_mime_type": "string", "audio_performer": "string", "audio_title": "string", "caption": "string", "chat_firstname": "string", "chat_id": 65, "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": 44, "document_mime_type": "string", "edit_date": "date", "forward_date": "date", "forward_from_message_id": 59, "from_firstname": "string", "from_lastname": "string", "from_user_id": 29, "from_username": "string", "link": "string", "location_latitude": 42, "location_longitude": 99, "media_group_id": "string", "message_id": 36, "photo_file_id": "string", "photo_file_size": 16, "photo_height": 4, "photo_width": 1, "text": "string", "video_duration": 48, "video_file_id": "string", "video_file_size": 86, "video_height": 50, "video_mime_type": "string", "video_width": 48 }
user –
{ "first_name": "string", "is_bot": true, "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:
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": 24, "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": 82, "chat_lastname": "string", "chat_username": "string", "contact_first_name": "string", "contact_last_name": "string", "contact_phone_number": "string", "contact_user_id": 72, "contact_vcard": "string", "creation_date": "date", "document_file_id": "string", "document_file_name": "string", "document_file_size": 97, "document_mime_type": "string", "edit_date": "date", "forward_date": "date", "forward_from_message_id": 11, "from_firstname": "string", "from_lastname": "string", "from_user_id": 82, "from_username": "string", "link": "string", "location_latitude": 68, "location_longitude": 90, "media_group_id": "string", "message_id": 74, "photo_file_id": "string", "photo_file_size": 70, "photo_height": 80, "photo_width": 95, "text": "string", "video_duration": 41, "video_file_id": "string", "video_file_size": 39, "video_height": 2, "video_mime_type": "string", "video_width": 96 }
user –
{ "first_name": "string", "is_bot": false, "language_code": "string", "last_name": "string", "link": "string", "user_id": 92, "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": 88, "audio_mime_type": "string", "audio_performer": "string", "audio_title": "string", "caption": "string", "chat_firstname": "string", "chat_id": 61, "chat_lastname": "string", "chat_username": "string", "contact_first_name": "string", "contact_last_name": "string", "contact_phone_number": "string", "contact_user_id": 71, "contact_vcard": "string", "creation_date": "date", "document_file_id": "string", "document_file_name": "string", "document_file_size": 57, "document_mime_type": "string", "edit_date": "date", "forward_date": "date", "forward_from_message_id": 87, "from_firstname": "string", "from_lastname": "string", "from_user_id": 87, "from_username": "string", "link": "string", "location_latitude": 84, "location_longitude": 86, "media_group_id": "string", "message_id": 27, "photo_file_id": "string", "photo_file_size": 67, "photo_height": 69, "photo_width": 78, "text": "string", "video_duration": 6, "video_file_id": "string", "video_file_size": 14, "video_height": 74, "video_mime_type": "string", "video_width": 62 }
user –
{ "first_name": "string", "is_bot": true, "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