From e4a6d16cf3f0f5af28608a8e3032bbc2086a0ee9 Mon Sep 17 00:00:00 2001 From: Dan <14043624+delivrance@users.noreply.github.com> Date: Wed, 26 Jun 2019 15:56:08 +0200 Subject: [PATCH 1/7] Remove generated inline query result types --- .../todo/inline_query_result_audio.py | 72 ---------- .../todo/inline_query_result_cached_audio.py | 103 -------------- .../inline_query_result_cached_document.py | 69 ---------- .../todo/inline_query_result_cached_gif.py | 65 --------- .../inline_query_result_cached_mpeg4_gif.py | 65 --------- .../todo/inline_query_result_cached_photo.py | 69 ---------- .../inline_query_result_cached_sticker.py | 52 -------- .../todo/inline_query_result_cached_video.py | 69 ---------- .../todo/inline_query_result_cached_voice.py | 65 --------- .../todo/inline_query_result_contact.py | 78 ----------- .../todo/inline_query_result_document.py | 86 ------------ .../todo/inline_query_result_game.py | 48 ------- .../todo/inline_query_result_gif.py | 82 ------------ .../todo/inline_query_result_location.py | 78 ----------- .../todo/inline_query_result_mpeg4_gif.py | 82 ------------ .../todo/inline_query_result_photo.py | 126 ------------------ .../todo/inline_query_result_venue.py | 86 ------------ .../todo/inline_query_result_video.py | 90 ------------- .../todo/inline_query_result_voice.py | 69 ---------- 19 files changed, 1454 deletions(-) delete mode 100644 pyrogram/client/types/inline_mode/todo/inline_query_result_audio.py delete mode 100644 pyrogram/client/types/inline_mode/todo/inline_query_result_cached_audio.py delete mode 100644 pyrogram/client/types/inline_mode/todo/inline_query_result_cached_document.py delete mode 100644 pyrogram/client/types/inline_mode/todo/inline_query_result_cached_gif.py delete mode 100644 pyrogram/client/types/inline_mode/todo/inline_query_result_cached_mpeg4_gif.py delete mode 100644 pyrogram/client/types/inline_mode/todo/inline_query_result_cached_photo.py delete mode 100644 pyrogram/client/types/inline_mode/todo/inline_query_result_cached_sticker.py delete mode 100644 pyrogram/client/types/inline_mode/todo/inline_query_result_cached_video.py delete mode 100644 pyrogram/client/types/inline_mode/todo/inline_query_result_cached_voice.py delete mode 100644 pyrogram/client/types/inline_mode/todo/inline_query_result_contact.py delete mode 100644 pyrogram/client/types/inline_mode/todo/inline_query_result_document.py delete mode 100644 pyrogram/client/types/inline_mode/todo/inline_query_result_game.py delete mode 100644 pyrogram/client/types/inline_mode/todo/inline_query_result_gif.py delete mode 100644 pyrogram/client/types/inline_mode/todo/inline_query_result_location.py delete mode 100644 pyrogram/client/types/inline_mode/todo/inline_query_result_mpeg4_gif.py delete mode 100644 pyrogram/client/types/inline_mode/todo/inline_query_result_photo.py delete mode 100644 pyrogram/client/types/inline_mode/todo/inline_query_result_venue.py delete mode 100644 pyrogram/client/types/inline_mode/todo/inline_query_result_video.py delete mode 100644 pyrogram/client/types/inline_mode/todo/inline_query_result_voice.py diff --git a/pyrogram/client/types/inline_mode/todo/inline_query_result_audio.py b/pyrogram/client/types/inline_mode/todo/inline_query_result_audio.py deleted file mode 100644 index d5fb954a..00000000 --- a/pyrogram/client/types/inline_mode/todo/inline_query_result_audio.py +++ /dev/null @@ -1,72 +0,0 @@ -# Pyrogram - Telegram MTProto API Client Library for Python -# Copyright (C) 2017-2018 Dan Tès -# -# This file is part of Pyrogram. -# -# Pyrogram is free software: you can redistribute it and/or modify -# it under the terms of the GNU Lesser General Public License as published -# by the Free Software Foundation, either version 3 of the License, or -# (at your option) any later version. -# -# Pyrogram is distributed in the hope that it will be useful, -# but WITHOUT ANY WARRANTY; without even the implied warranty of -# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the -# GNU Lesser General Public License for more details. -# -# You should have received a copy of the GNU Lesser General Public License -# along with Pyrogram. If not, see . - -from pyrogram.client.types.object import Object - - -class InlineQueryResultAudio(Object): - """Represents a link to an mp3 audio file. By default, this audio file will be sent by the user. Alternatively, you can use input_message_content to send a message with the specified content instead of the audio. - - Attributes: - ID: ``0xb0700004`` - - Parameters: - type (``str``): - Type of the result, must be audio. - - id (``str``): - Unique identifier for this result, 1-64 bytes. - - audio_url (``str``): - A valid URL for the audio file. - - title (``str``): - Title. - - caption (``str``, optional): - Caption, 0-200 characters. - - parse_mode (``str``, optional): - Send Markdown or HTML, if you want Telegram apps to show bold, italic, fixed-width text or inline URLs in the media caption. - - performer (``str``, optional): - Performer. - - audio_duration (``int`` ``32-bit``, optional): - Audio duration in seconds. - - reply_markup (:obj:`InlineKeyboardMarkup`, optional): - Inline keyboard attached to the message. - - input_message_content (:obj:`InputMessageContent`, optional): - Content of the message to be sent instead of the audio. - - """ - - def __init__(self, type: str, id: str, audio_url: str, title: str, caption: str = None, parse_mode: str = None, - performer: str = None, audio_duration: int = None, reply_markup=None, input_message_content=None): - self.type = type # string - self.id = id # string - self.audio_url = audio_url # string - self.title = title # string - self.caption = caption # flags.0?string - self.parse_mode = parse_mode # flags.1?string - self.performer = performer # flags.2?string - self.audio_duration = audio_duration # flags.3?int - self.reply_markup = reply_markup # flags.4?InlineKeyboardMarkup - self.input_message_content = input_message_content # flags.5?InputMessageContent diff --git a/pyrogram/client/types/inline_mode/todo/inline_query_result_cached_audio.py b/pyrogram/client/types/inline_mode/todo/inline_query_result_cached_audio.py deleted file mode 100644 index 47b9bbe2..00000000 --- a/pyrogram/client/types/inline_mode/todo/inline_query_result_cached_audio.py +++ /dev/null @@ -1,103 +0,0 @@ -# Pyrogram - Telegram MTProto API Client Library for Python -# Copyright (C) 2017-2018 Dan Tès -# -# This file is part of Pyrogram. -# -# Pyrogram is free software: you can redistribute it and/or modify -# it under the terms of the GNU Lesser General Public License as published -# by the Free Software Foundation, either version 3 of the License, or -# (at your option) any later version. -# -# Pyrogram is distributed in the hope that it will be useful, -# but WITHOUT ANY WARRANTY; without even the implied warranty of -# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the -# GNU Lesser General Public License for more details. -# -# You should have received a copy of the GNU Lesser General Public License -# along with Pyrogram. If not, see . - -import binascii -import struct - -from pyrogram.api import types -from pyrogram.client.ext import utils, BaseClient -from pyrogram.client.style import HTML, Markdown -from pyrogram.client.types.object import Object -from pyrogram.errors import FileIdInvalid - - -class InlineQueryResultCachedAudio(Object): - """Represents a link to an audio file stored on the Telegram servers. - By default, this audio file will be sent by the user. Alternatively, you can use *input_message_content* to send a - message with the specified content instead of the audio. - - Parameters: - id (``str``): - Unique identifier for this result, 1-64 bytes. - - audio_file_id (``str``): - A valid file identifier for the audio file. - - caption (``str``, *optional*): - Caption, 0-200 characters. - - parse_mode (``str``, *optional*): - Send Markdown or HTML, if you want Telegram apps to show bold, italic, fixed-width text or inline URLs in - the media caption. - - reply_markup (:obj:`InlineKeyboardMarkup `, *optional*): - Inline keyboard attached to the message. - - input_message_content (:obj:`InputMessageContent `, *optional*): - Content of the message to be sent instead of the audio. - - """ - - def __init__( - self, - id: str, - audio_file_id: str, - caption: str = "", - parse_mode: str = "", - reply_markup=None, - input_message_content=None - ): - self.id = id - self.audio_file_id = audio_file_id - self.caption = caption - self.parse_mode = parse_mode - self.reply_markup = reply_markup - self.input_message_content = input_message_content - - self.style = HTML() if parse_mode.lower() == "html" else Markdown() - - def write(self): - try: - decoded = utils.decode(self.audio_file_id) - fmt = " 24 else " -# -# This file is part of Pyrogram. -# -# Pyrogram is free software: you can redistribute it and/or modify -# it under the terms of the GNU Lesser General Public License as published -# by the Free Software Foundation, either version 3 of the License, or -# (at your option) any later version. -# -# Pyrogram is distributed in the hope that it will be useful, -# but WITHOUT ANY WARRANTY; without even the implied warranty of -# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the -# GNU Lesser General Public License for more details. -# -# You should have received a copy of the GNU Lesser General Public License -# along with Pyrogram. If not, see . - -from pyrogram.client.types.object import Object - - -class InlineQueryResultCachedDocument(Object): - """Represents a link to a file stored on the Telegram servers. By default, this file will be sent by the user with an optional caption. Alternatively, you can use input_message_content to send a message with the specified content instead of the file. - - Attributes: - ID: ``0xb0700015`` - - Parameters: - type (``str``): - Type of the result, must be document. - - id (``str``): - Unique identifier for this result, 1-64 bytes. - - title (``str``): - Title for the result. - - document_file_id (``str``): - A valid file identifier for the file. - - description (``str``, optional): - Short description of the result. - - caption (``str``, optional): - Caption of the document to be sent, 0-200 characters. - - parse_mode (``str``, optional): - Send Markdown or HTML, if you want Telegram apps to show bold, italic, fixed-width text or inline URLs in the media caption. - - reply_markup (:obj:`InlineKeyboardMarkup`, optional): - Inline keyboard attached to the message. - - input_message_content (:obj:`InputMessageContent`, optional): - Content of the message to be sent instead of the file. - - """ - ID = 0xb0700015 - - def __init__(self, type: str, id: str, title: str, document_file_id: str, description: str = None, - caption: str = None, parse_mode: str = None, reply_markup=None, input_message_content=None): - self.type = type # string - self.id = id # string - self.title = title # string - self.document_file_id = document_file_id # string - self.description = description # flags.0?string - self.caption = caption # flags.1?string - self.parse_mode = parse_mode # flags.2?string - self.reply_markup = reply_markup # flags.3?InlineKeyboardMarkup - self.input_message_content = input_message_content # flags.4?InputMessageContent diff --git a/pyrogram/client/types/inline_mode/todo/inline_query_result_cached_gif.py b/pyrogram/client/types/inline_mode/todo/inline_query_result_cached_gif.py deleted file mode 100644 index 28a3595b..00000000 --- a/pyrogram/client/types/inline_mode/todo/inline_query_result_cached_gif.py +++ /dev/null @@ -1,65 +0,0 @@ -# Pyrogram - Telegram MTProto API Client Library for Python -# Copyright (C) 2017-2018 Dan Tès -# -# This file is part of Pyrogram. -# -# Pyrogram is free software: you can redistribute it and/or modify -# it under the terms of the GNU Lesser General Public License as published -# by the Free Software Foundation, either version 3 of the License, or -# (at your option) any later version. -# -# Pyrogram is distributed in the hope that it will be useful, -# but WITHOUT ANY WARRANTY; without even the implied warranty of -# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the -# GNU Lesser General Public License for more details. -# -# You should have received a copy of the GNU Lesser General Public License -# along with Pyrogram. If not, see . - -from pyrogram.client.types.object import Object - - -class InlineQueryResultCachedGif(Object): - """Represents a link to an animated GIF file stored on the Telegram servers. By default, this animated GIF file will be sent by the user with an optional caption. Alternatively, you can use input_message_content to send a message with specified content instead of the animation. - - Attributes: - ID: ``0xb0700012`` - - Parameters: - type (``str``): - Type of the result, must be gif. - - id (``str``): - Unique identifier for this result, 1-64 bytes. - - gif_file_id (``str``): - A valid file identifier for the GIF file. - - title (``str``, optional): - Title for the result. - - caption (``str``, optional): - Caption of the GIF file to be sent, 0-200 characters. - - parse_mode (``str``, optional): - Send Markdown or HTML, if you want Telegram apps to show bold, italic, fixed-width text or inline URLs in the media caption. - - reply_markup (:obj:`InlineKeyboardMarkup`, optional): - Inline keyboard attached to the message. - - input_message_content (:obj:`InputMessageContent`, optional): - Content of the message to be sent instead of the GIF animation. - - """ - ID = 0xb0700012 - - def __init__(self, type: str, id: str, gif_file_id: str, title: str = None, caption: str = None, - parse_mode: str = None, reply_markup=None, input_message_content=None): - self.type = type # string - self.id = id # string - self.gif_file_id = gif_file_id # string - self.title = title # flags.0?string - self.caption = caption # flags.1?string - self.parse_mode = parse_mode # flags.2?string - self.reply_markup = reply_markup # flags.3?InlineKeyboardMarkup - self.input_message_content = input_message_content # flags.4?InputMessageContent diff --git a/pyrogram/client/types/inline_mode/todo/inline_query_result_cached_mpeg4_gif.py b/pyrogram/client/types/inline_mode/todo/inline_query_result_cached_mpeg4_gif.py deleted file mode 100644 index 95ab03a0..00000000 --- a/pyrogram/client/types/inline_mode/todo/inline_query_result_cached_mpeg4_gif.py +++ /dev/null @@ -1,65 +0,0 @@ -# Pyrogram - Telegram MTProto API Client Library for Python -# Copyright (C) 2017-2018 Dan Tès -# -# This file is part of Pyrogram. -# -# Pyrogram is free software: you can redistribute it and/or modify -# it under the terms of the GNU Lesser General Public License as published -# by the Free Software Foundation, either version 3 of the License, or -# (at your option) any later version. -# -# Pyrogram is distributed in the hope that it will be useful, -# but WITHOUT ANY WARRANTY; without even the implied warranty of -# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the -# GNU Lesser General Public License for more details. -# -# You should have received a copy of the GNU Lesser General Public License -# along with Pyrogram. If not, see . - -from pyrogram.client.types.object import Object - - -class InlineQueryResultCachedMpeg4Gif(Object): - """Represents a link to a video animation (H.264/MPEG-4 AVC video without sound) stored on the Telegram servers. By default, this animated MPEG-4 file will be sent by the user with an optional caption. Alternatively, you can use input_message_content to send a message with the specified content instead of the animation. - - Attributes: - ID: ``0xb0700013`` - - Parameters: - type (``str``): - Type of the result, must be mpeg4_gif. - - id (``str``): - Unique identifier for this result, 1-64 bytes. - - mpeg4_file_id (``str``): - A valid file identifier for the MP4 file. - - title (``str``, optional): - Title for the result. - - caption (``str``, optional): - Caption of the MPEG-4 file to be sent, 0-200 characters. - - parse_mode (``str``, optional): - Send Markdown or HTML, if you want Telegram apps to show bold, italic, fixed-width text or inline URLs in the media caption. - - reply_markup (:obj:`InlineKeyboardMarkup `, optional): - Inline keyboard attached to the message. - - input_message_content (:obj:`InputMessageContent`, optional): - Content of the message to be sent instead of the video animation. - - """ - ID = 0xb0700013 - - def __init__(self, type: str, id: str, mpeg4_file_id: str, title: str = None, caption: str = None, - parse_mode: str = None, reply_markup=None, input_message_content=None): - self.type = type # string - self.id = id # string - self.mpeg4_file_id = mpeg4_file_id # string - self.title = title # flags.0?string - self.caption = caption # flags.1?string - self.parse_mode = parse_mode # flags.2?string - self.reply_markup = reply_markup # flags.3?InlineKeyboardMarkup - self.input_message_content = input_message_content # flags.4?InputMessageContent diff --git a/pyrogram/client/types/inline_mode/todo/inline_query_result_cached_photo.py b/pyrogram/client/types/inline_mode/todo/inline_query_result_cached_photo.py deleted file mode 100644 index 22793cef..00000000 --- a/pyrogram/client/types/inline_mode/todo/inline_query_result_cached_photo.py +++ /dev/null @@ -1,69 +0,0 @@ -# Pyrogram - Telegram MTProto API Client Library for Python -# Copyright (C) 2017-2018 Dan Tès -# -# This file is part of Pyrogram. -# -# Pyrogram is free software: you can redistribute it and/or modify -# it under the terms of the GNU Lesser General Public License as published -# by the Free Software Foundation, either version 3 of the License, or -# (at your option) any later version. -# -# Pyrogram is distributed in the hope that it will be useful, -# but WITHOUT ANY WARRANTY; without even the implied warranty of -# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the -# GNU Lesser General Public License for more details. -# -# You should have received a copy of the GNU Lesser General Public License -# along with Pyrogram. If not, see . - -from pyrogram.client.types.object import Object - - -class InlineQueryResultCachedPhoto(Object): - """Represents a link to a photo stored on the Telegram servers. By default, this photo will be sent by the user with an optional caption. Alternatively, you can use input_message_content to send a message with the specified content instead of the photo. - - Attributes: - ID: ``0xb0700011`` - - Parameters: - type (``str``): - Type of the result, must be photo. - - id (``str``): - Unique identifier for this result, 1-64 bytes. - - photo_file_id (``str``): - A valid file identifier of the photo. - - title (``str``, optional): - Title for the result. - - description (``str``, optional): - Short description of the result. - - caption (``str``, optional): - Caption of the photo to be sent, 0-200 characters. - - parse_mode (``str``, optional): - Send Markdown or HTML, if you want Telegram apps to show bold, italic, fixed-width text or inline URLs in the media caption. - - reply_markup (:obj:`InlineKeyboardMarkup `, optional): - Inline keyboard attached to the message. - - input_message_content (:obj:`InputMessageContent `, optional): - Content of the message to be sent instead of the photo. - - """ - ID = 0xb0700011 - - def __init__(self, type: str, id: str, photo_file_id: str, title: str = None, description: str = None, - caption: str = None, parse_mode: str = None, reply_markup=None, input_message_content=None): - self.type = type # string - self.id = id # string - self.photo_file_id = photo_file_id # string - self.title = title # flags.0?string - self.description = description # flags.1?string - self.caption = caption # flags.2?string - self.parse_mode = parse_mode # flags.3?string - self.reply_markup = reply_markup # flags.4?InlineKeyboardMarkup - self.input_message_content = input_message_content # flags.5?InputMessageContent diff --git a/pyrogram/client/types/inline_mode/todo/inline_query_result_cached_sticker.py b/pyrogram/client/types/inline_mode/todo/inline_query_result_cached_sticker.py deleted file mode 100644 index 6b2b37c9..00000000 --- a/pyrogram/client/types/inline_mode/todo/inline_query_result_cached_sticker.py +++ /dev/null @@ -1,52 +0,0 @@ -# Pyrogram - Telegram MTProto API Client Library for Python -# Copyright (C) 2017-2018 Dan Tès -# -# This file is part of Pyrogram. -# -# Pyrogram is free software: you can redistribute it and/or modify -# it under the terms of the GNU Lesser General Public License as published -# by the Free Software Foundation, either version 3 of the License, or -# (at your option) any later version. -# -# Pyrogram is distributed in the hope that it will be useful, -# but WITHOUT ANY WARRANTY; without even the implied warranty of -# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the -# GNU Lesser General Public License for more details. -# -# You should have received a copy of the GNU Lesser General Public License -# along with Pyrogram. If not, see . - -from pyrogram.client.types.object import Object - - -class InlineQueryResultCachedSticker(Object): - """Represents a link to a sticker stored on the Telegram servers. By default, this sticker will be sent by the user. Alternatively, you can use input_message_content to send a message with the specified content instead of the sticker. - - Attributes: - ID: ``0xb0700014`` - - Parameters: - type (``str``): - Type of the result, must be sticker. - - id (``str``): - Unique identifier for this result, 1-64 bytes. - - sticker_file_id (``str``): - A valid file identifier of the sticker. - - reply_markup (:obj:`InlineKeyboardMarkup`, optional): - Inline keyboard attached to the message. - - input_message_content (:obj:`InputMessageContent`, optional): - Content of the message to be sent instead of the sticker. - - """ - ID = 0xb0700014 - - def __init__(self, type: str, id: str, sticker_file_id: str, reply_markup=None, input_message_content=None): - self.type = type # string - self.id = id # string - self.sticker_file_id = sticker_file_id # string - self.reply_markup = reply_markup # flags.0?InlineKeyboardMarkup - self.input_message_content = input_message_content # flags.1?InputMessageContent diff --git a/pyrogram/client/types/inline_mode/todo/inline_query_result_cached_video.py b/pyrogram/client/types/inline_mode/todo/inline_query_result_cached_video.py deleted file mode 100644 index 77dcd6dd..00000000 --- a/pyrogram/client/types/inline_mode/todo/inline_query_result_cached_video.py +++ /dev/null @@ -1,69 +0,0 @@ -# Pyrogram - Telegram MTProto API Client Library for Python -# Copyright (C) 2017-2018 Dan Tès -# -# This file is part of Pyrogram. -# -# Pyrogram is free software: you can redistribute it and/or modify -# it under the terms of the GNU Lesser General Public License as published -# by the Free Software Foundation, either version 3 of the License, or -# (at your option) any later version. -# -# Pyrogram is distributed in the hope that it will be useful, -# but WITHOUT ANY WARRANTY; without even the implied warranty of -# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the -# GNU Lesser General Public License for more details. -# -# You should have received a copy of the GNU Lesser General Public License -# along with Pyrogram. If not, see . - -from pyrogram.client.types.object import Object - - -class InlineQueryResultCachedVideo(Object): - """Represents a link to a video file stored on the Telegram servers. By default, this video file will be sent by the user with an optional caption. Alternatively, you can use input_message_content to send a message with the specified content instead of the video. - - Attributes: - ID: ``0xb0700016`` - - Parameters: - type (``str``): - Type of the result, must be video. - - id (``str``): - Unique identifier for this result, 1-64 bytes. - - video_file_id (``str``): - A valid file identifier for the video file. - - title (``str``): - Title for the result. - - description (``str``, optional): - Short description of the result. - - caption (``str``, optional): - Caption of the video to be sent, 0-200 characters. - - parse_mode (``str``, optional): - Send Markdown or HTML, if you want Telegram apps to show bold, italic, fixed-width text or inline URLs in the media caption. - - reply_markup (:obj:`InlineKeyboardMarkup `, optional): - Inline keyboard attached to the message. - - input_message_content (:obj:`InputMessageContent `, optional): - Content of the message to be sent instead of the video. - - """ - ID = 0xb0700016 - - def __init__(self, type: str, id: str, video_file_id: str, title: str, description: str = None, caption: str = None, - parse_mode: str = None, reply_markup=None, input_message_content=None): - self.type = type # string - self.id = id # string - self.video_file_id = video_file_id # string - self.title = title # string - self.description = description # flags.0?string - self.caption = caption # flags.1?string - self.parse_mode = parse_mode # flags.2?string - self.reply_markup = reply_markup # flags.3?InlineKeyboardMarkup - self.input_message_content = input_message_content # flags.4?InputMessageContent diff --git a/pyrogram/client/types/inline_mode/todo/inline_query_result_cached_voice.py b/pyrogram/client/types/inline_mode/todo/inline_query_result_cached_voice.py deleted file mode 100644 index a80d5a20..00000000 --- a/pyrogram/client/types/inline_mode/todo/inline_query_result_cached_voice.py +++ /dev/null @@ -1,65 +0,0 @@ -# Pyrogram - Telegram MTProto API Client Library for Python -# Copyright (C) 2017-2018 Dan Tès -# -# This file is part of Pyrogram. -# -# Pyrogram is free software: you can redistribute it and/or modify -# it under the terms of the GNU Lesser General Public License as published -# by the Free Software Foundation, either version 3 of the License, or -# (at your option) any later version. -# -# Pyrogram is distributed in the hope that it will be useful, -# but WITHOUT ANY WARRANTY; without even the implied warranty of -# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the -# GNU Lesser General Public License for more details. -# -# You should have received a copy of the GNU Lesser General Public License -# along with Pyrogram. If not, see . - -from pyrogram.client.types.object import Object - - -class InlineQueryResultCachedVoice(Object): - """Represents a link to a voice message stored on the Telegram servers. By default, this voice message will be sent by the user. Alternatively, you can use input_message_content to send a message with the specified content instead of the voice message. - - Attributes: - ID: ``0xb0700017`` - - Parameters: - type (``str``): - Type of the result, must be voice. - - id (``str``): - Unique identifier for this result, 1-64 bytes. - - voice_file_id (``str``): - A valid file identifier for the voice message. - - title (``str``): - Voice message title. - - caption (``str``, optional): - Caption, 0-200 characters. - - parse_mode (``str``, optional): - Send Markdown or HTML, if you want Telegram apps to show bold, italic, fixed-width text or inline URLs in the media caption. - - reply_markup (:obj:`InlineKeyboardMarkup`, optional): - Inline keyboard attached to the message. - - input_message_content (:obj:`InputMessageContent`, optional): - Content of the message to be sent instead of the voice message. - - """ - ID = 0xb0700017 - - def __init__(self, type: str, id: str, voice_file_id: str, title: str, caption: str = None, parse_mode: str = None, - reply_markup=None, input_message_content=None): - self.type = type # string - self.id = id # string - self.voice_file_id = voice_file_id # string - self.title = title # string - self.caption = caption # flags.0?string - self.parse_mode = parse_mode # flags.1?string - self.reply_markup = reply_markup # flags.2?InlineKeyboardMarkup - self.input_message_content = input_message_content # flags.3?InputMessageContent diff --git a/pyrogram/client/types/inline_mode/todo/inline_query_result_contact.py b/pyrogram/client/types/inline_mode/todo/inline_query_result_contact.py deleted file mode 100644 index afddb9ec..00000000 --- a/pyrogram/client/types/inline_mode/todo/inline_query_result_contact.py +++ /dev/null @@ -1,78 +0,0 @@ -# Pyrogram - Telegram MTProto API Client Library for Python -# Copyright (C) 2017-2018 Dan Tès -# -# This file is part of Pyrogram. -# -# Pyrogram is free software: you can redistribute it and/or modify -# it under the terms of the GNU Lesser General Public License as published -# by the Free Software Foundation, either version 3 of the License, or -# (at your option) any later version. -# -# Pyrogram is distributed in the hope that it will be useful, -# but WITHOUT ANY WARRANTY; without even the implied warranty of -# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the -# GNU Lesser General Public License for more details. -# -# You should have received a copy of the GNU Lesser General Public License -# along with Pyrogram. If not, see . - -from pyrogram.client.types.object import Object - - -class InlineQueryResultContact(Object): - """Represents a contact with a phone number. By default, this contact will be sent by the user. Alternatively, you can use input_message_content to send a message with the specified content instead of the contact. - - Attributes: - ID: ``0xb0700009`` - - Parameters: - type (``str``): - Type of the result, must be contact. - - id (``str``): - Unique identifier for this result, 1-64 Bytes. - - phone_number (``str``): - Contact's phone number. - - first_name (``str``): - Contact's first name. - - last_name (``str``, optional): - Contact's last name. - - vcard (``str``, optional): - Additional data about the contact in the form of a vCard, 0-2048 bytes. - - reply_markup (:obj:`InlineKeyboardMarkup `, optional): - Inline keyboard attached to the message. - - input_message_content (:obj:`InputMessageContent `, optional): - Content of the message to be sent instead of the contact. - - thumb_url (``str``, optional): - Url of the thumbnail for the result. - - thumb_width (``int`` ``32-bit``, optional): - Thumbnail width. - - thumb_height (``int`` ``32-bit``, optional): - Thumbnail height. - - """ - ID = 0xb0700009 - - def __init__(self, type: str, id: str, phone_number: str, first_name: str, last_name: str = None, vcard: str = None, - reply_markup=None, input_message_content=None, thumb_url: str = None, thumb_width: int = None, - thumb_height: int = None): - self.type = type # string - self.id = id # string - self.phone_number = phone_number # string - self.first_name = first_name # string - self.last_name = last_name # flags.0?string - self.vcard = vcard # flags.1?string - self.reply_markup = reply_markup # flags.2?InlineKeyboardMarkup - self.input_message_content = input_message_content # flags.3?InputMessageContent - self.thumb_url = thumb_url # flags.4?string - self.thumb_width = thumb_width # flags.5?int - self.thumb_height = thumb_height # flags.6?int diff --git a/pyrogram/client/types/inline_mode/todo/inline_query_result_document.py b/pyrogram/client/types/inline_mode/todo/inline_query_result_document.py deleted file mode 100644 index 370dc3c6..00000000 --- a/pyrogram/client/types/inline_mode/todo/inline_query_result_document.py +++ /dev/null @@ -1,86 +0,0 @@ -# Pyrogram - Telegram MTProto API Client Library for Python -# Copyright (C) 2017-2018 Dan Tès -# -# This file is part of Pyrogram. -# -# Pyrogram is free software: you can redistribute it and/or modify -# it under the terms of the GNU Lesser General Public License as published -# by the Free Software Foundation, either version 3 of the License, or -# (at your option) any later version. -# -# Pyrogram is distributed in the hope that it will be useful, -# but WITHOUT ANY WARRANTY; without even the implied warranty of -# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the -# GNU Lesser General Public License for more details. -# -# You should have received a copy of the GNU Lesser General Public License -# along with Pyrogram. If not, see . - -from pyrogram.client.types.object import Object - - -class InlineQueryResultDocument(Object): - """Represents a link to a file. By default, this file will be sent by the user with an optional caption. Alternatively, you can use input_message_content to send a message with the specified content instead of the file. Currently, only .PDF and .ZIP files can be sent using this method. - - Attributes: - ID: ``0xb0700006`` - - Parameters: - type (``str``): - Type of the result, must be document. - - id (``str``): - Unique identifier for this result, 1-64 bytes. - - title (``str``): - Title for the result. - - document_url (``str``, optional): - Caption of the document to be sent, 0-200 characters. - - mime_type (``str``, optional): - Send Markdown or HTML, if you want Telegram apps to show bold, italic, fixed-width text or inline URLs in the media caption. - - caption (``str``): - A valid URL for the file. - - parse_mode (``str``): - Mime type of the content of the file, either "application/pdf" or "application/zip". - - description (``str``, optional): - Short description of the result. - - reply_markup (:obj:`InlineKeyboardMarkup`, optional): - Inline keyboard attached to the message. - - input_message_content (:obj:`InputMessageContent`, optional): - Content of the message to be sent instead of the file. - - thumb_url (``str``, optional): - URL of the thumbnail (jpeg only) for the file. - - thumb_width (``int`` ``32-bit``, optional): - Thumbnail width. - - thumb_height (``int`` ``32-bit``, optional): - Thumbnail height. - - """ - ID = 0xb0700006 - - def __init__(self, type: str, id: str, title: str, document_url: str, mime_type: str, caption: str = None, - parse_mode: str = None, description: str = None, reply_markup=None, input_message_content=None, - thumb_url: str = None, thumb_width: int = None, thumb_height: int = None): - self.type = type # string - self.id = id # string - self.title = title # string - self.caption = caption # flags.0?string - self.parse_mode = parse_mode # flags.1?string - self.document_url = document_url # string - self.mime_type = mime_type # string - self.description = description # flags.2?string - self.reply_markup = reply_markup # flags.3?InlineKeyboardMarkup - self.input_message_content = input_message_content # flags.4?InputMessageContent - self.thumb_url = thumb_url # flags.5?string - self.thumb_width = thumb_width # flags.6?int - self.thumb_height = thumb_height # flags.7?int diff --git a/pyrogram/client/types/inline_mode/todo/inline_query_result_game.py b/pyrogram/client/types/inline_mode/todo/inline_query_result_game.py deleted file mode 100644 index bd6f25d2..00000000 --- a/pyrogram/client/types/inline_mode/todo/inline_query_result_game.py +++ /dev/null @@ -1,48 +0,0 @@ -# Pyrogram - Telegram MTProto API Client Library for Python -# Copyright (C) 2017-2018 Dan Tès -# -# This file is part of Pyrogram. -# -# Pyrogram is free software: you can redistribute it and/or modify -# it under the terms of the GNU Lesser General Public License as published -# by the Free Software Foundation, either version 3 of the License, or -# (at your option) any later version. -# -# Pyrogram is distributed in the hope that it will be useful, -# but WITHOUT ANY WARRANTY; without even the implied warranty of -# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the -# GNU Lesser General Public License for more details. -# -# You should have received a copy of the GNU Lesser General Public License -# along with Pyrogram. If not, see . - -from pyrogram.client.types.object import Object - - -class InlineQueryResultGame(Object): - """Represents a Game. - - Attributes: - ID: ``0xb0700010`` - - Parameters: - type (``str``): - Type of the result, must be game. - - id (``str``): - Unique identifier for this result, 1-64 bytes. - - game_short_name (``str``): - Short name of the game. - - reply_markup (:obj:`InlineKeyboardMarkup`, optional): - Inline keyboard attached to the message. - - """ - ID = 0xb0700010 - - def __init__(self, type: str, id: str, game_short_name: str, reply_markup=None): - self.type = type # string - self.id = id # string - self.game_short_name = game_short_name # string - self.reply_markup = reply_markup # flags.0?InlineKeyboardMarkup diff --git a/pyrogram/client/types/inline_mode/todo/inline_query_result_gif.py b/pyrogram/client/types/inline_mode/todo/inline_query_result_gif.py deleted file mode 100644 index 56817d76..00000000 --- a/pyrogram/client/types/inline_mode/todo/inline_query_result_gif.py +++ /dev/null @@ -1,82 +0,0 @@ -# Pyrogram - Telegram MTProto API Client Library for Python -# Copyright (C) 2017-2018 Dan Tès -# -# This file is part of Pyrogram. -# -# Pyrogram is free software: you can redistribute it and/or modify -# it under the terms of the GNU Lesser General Public License as published -# by the Free Software Foundation, either version 3 of the License, or -# (at your option) any later version. -# -# Pyrogram is distributed in the hope that it will be useful, -# but WITHOUT ANY WARRANTY; without even the implied warranty of -# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the -# GNU Lesser General Public License for more details. -# -# You should have received a copy of the GNU Lesser General Public License -# along with Pyrogram. If not, see . - -from pyrogram.client.types.object import Object - - -class InlineQueryResultGif(Object): - """Represents a link to an animated GIF file. By default, this animated GIF file will be sent by the user with optional caption. Alternatively, you can use input_message_content to send a message with the specified content instead of the animation. - - Attributes: - ID: ``0xb0700001`` - - Parameters: - type (``str``): - Type of the result, must be gif. - - id (``str``): - Unique identifier for this result, 1-64 bytes. - - gif_url (``str``): - A valid URL for the GIF file. File size must not exceed 1MB. - - thumb_url (``str``, optional): - Width of the GIF. - - gif_width (``int`` ``32-bit``, optional): - Height of the GIF. - - gif_height (``int`` ``32-bit``, optional): - Duration of the GIF. - - gif_duration (``int`` ``32-bit``): - URL of the static thumbnail for the result (jpeg or gif). - - title (``str``, optional): - Title for the result. - - caption (``str``, optional): - Caption of the GIF file to be sent, 0-200 characters. - - parse_mode (``str``, optional): - Send Markdown or HTML, if you want Telegram apps to show bold, italic, fixed-width text or inline URLs in the media caption. - - reply_markup (:obj:`InlineKeyboardMarkup `, optional): - Inline keyboard attached to the message. - - input_message_content (:obj:`InputMessageContent `, optional): - Content of the message to be sent instead of the GIF animation. - - """ - ID = 0xb0700001 - - def __init__(self, type: str, id: str, gif_url: str, thumb_url: str, gif_width: int = None, gif_height: int = None, - gif_duration: int = None, title: str = None, caption: str = None, parse_mode: str = None, - reply_markup=None, input_message_content=None): - self.type = type # string - self.id = id # string - self.gif_url = gif_url # string - self.gif_width = gif_width # flags.0?int - self.gif_height = gif_height # flags.1?int - self.gif_duration = gif_duration # flags.2?int - self.thumb_url = thumb_url # string - self.title = title # flags.3?string - self.caption = caption # flags.4?string - self.parse_mode = parse_mode # flags.5?string - self.reply_markup = reply_markup # flags.6?InlineKeyboardMarkup - self.input_message_content = input_message_content # flags.7?InputMessageContent diff --git a/pyrogram/client/types/inline_mode/todo/inline_query_result_location.py b/pyrogram/client/types/inline_mode/todo/inline_query_result_location.py deleted file mode 100644 index 74c63ede..00000000 --- a/pyrogram/client/types/inline_mode/todo/inline_query_result_location.py +++ /dev/null @@ -1,78 +0,0 @@ -# Pyrogram - Telegram MTProto API Client Library for Python -# Copyright (C) 2017-2018 Dan Tès -# -# This file is part of Pyrogram. -# -# Pyrogram is free software: you can redistribute it and/or modify -# it under the terms of the GNU Lesser General Public License as published -# by the Free Software Foundation, either version 3 of the License, or -# (at your option) any later version. -# -# Pyrogram is distributed in the hope that it will be useful, -# but WITHOUT ANY WARRANTY; without even the implied warranty of -# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the -# GNU Lesser General Public License for more details. -# -# You should have received a copy of the GNU Lesser General Public License -# along with Pyrogram. If not, see . - -from pyrogram.client.types.object import Object - - -class InlineQueryResultLocation(Object): - """Represents a location on a map. By default, the location will be sent by the user. Alternatively, you can use input_message_content to send a message with the specified content instead of the location. - - Attributes: - ID: ``0xb0700007`` - - Parameters: - type (``str``): - Type of the result, must be location. - - id (``str``): - Unique identifier for this result, 1-64 Bytes. - - latitude (``float`` ``64-bit``): - Location latitude in degrees. - - longitude (``float`` ``64-bit``): - Location longitude in degrees. - - title (``str``): - Location title. - - live_period (``int`` ``32-bit``, optional): - Period in seconds for which the location can be updated, should be between 60 and 86400. - - reply_markup (:obj:`InlineKeyboardMarkup `, optional): - Inline keyboard attached to the message. - - input_message_content (:obj:`InputMessageContent `, optional): - Content of the message to be sent instead of the location. - - thumb_url (``str``, optional): - Url of the thumbnail for the result. - - thumb_width (``int`` ``32-bit``, optional): - Thumbnail width. - - thumb_height (``int`` ``32-bit``, optional): - Thumbnail height. - - """ - ID = 0xb0700007 - - def __init__(self, type: str, id: str, latitude: float, longitude: float, title: str, live_period: int = None, - reply_markup=None, input_message_content=None, thumb_url: str = None, thumb_width: int = None, - thumb_height: int = None): - self.type = type # string - self.id = id # string - self.latitude = latitude # double - self.longitude = longitude # double - self.title = title # string - self.live_period = live_period # flags.0?int - self.reply_markup = reply_markup # flags.1?InlineKeyboardMarkup - self.input_message_content = input_message_content # flags.2?InputMessageContent - self.thumb_url = thumb_url # flags.3?string - self.thumb_width = thumb_width # flags.4?int - self.thumb_height = thumb_height # flags.5?int diff --git a/pyrogram/client/types/inline_mode/todo/inline_query_result_mpeg4_gif.py b/pyrogram/client/types/inline_mode/todo/inline_query_result_mpeg4_gif.py deleted file mode 100644 index e4da6b89..00000000 --- a/pyrogram/client/types/inline_mode/todo/inline_query_result_mpeg4_gif.py +++ /dev/null @@ -1,82 +0,0 @@ -# Pyrogram - Telegram MTProto API Client Library for Python -# Copyright (C) 2017-2018 Dan Tès -# -# This file is part of Pyrogram. -# -# Pyrogram is free software: you can redistribute it and/or modify -# it under the terms of the GNU Lesser General Public License as published -# by the Free Software Foundation, either version 3 of the License, or -# (at your option) any later version. -# -# Pyrogram is distributed in the hope that it will be useful, -# but WITHOUT ANY WARRANTY; without even the implied warranty of -# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the -# GNU Lesser General Public License for more details. -# -# You should have received a copy of the GNU Lesser General Public License -# along with Pyrogram. If not, see . - -from pyrogram.client.types.object import Object - - -class InlineQueryResultMpeg4Gif(Object): - """Represents a link to a video animation (H.264/MPEG-4 AVC video without sound). By default, this animated MPEG-4 file will be sent by the user with optional caption. Alternatively, you can use input_message_content to send a message with the specified content instead of the animation. - - Attributes: - ID: ``0xb0700002`` - - Parameters: - type (``str``): - Type of the result, must be mpeg4_gif. - - id (``str``): - Unique identifier for this result, 1-64 bytes. - - mpeg4_url (``str``): - A valid URL for the MP4 file. File size must not exceed 1MB. - - thumb_url (``str``, optional): - Video width. - - mpeg4_width (``int`` ``32-bit``, optional): - Video height. - - mpeg4_height (``int`` ``32-bit``, optional): - Video duration. - - mpeg4_duration (``int`` ``32-bit``): - URL of the static thumbnail (jpeg or gif) for the result. - - title (``str``, optional): - Title for the result. - - caption (``str``, optional): - Caption of the MPEG-4 file to be sent, 0-200 characters. - - parse_mode (``str``, optional): - Send Markdown or HTML, if you want Telegram apps to show bold, italic, fixed-width text or inline URLs in the media caption. - - reply_markup (:obj:`InlineKeyboardMarkup `, optional): - Inline keyboard attached to the message. - - input_message_content (:obj:`InputMessageContent `, optional): - Content of the message to be sent instead of the video animation. - - """ - ID = 0xb0700002 - - def __init__(self, type: str, id: str, mpeg4_url: str, thumb_url: str, mpeg4_width: int = None, - mpeg4_height: int = None, mpeg4_duration: int = None, title: str = None, caption: str = None, - parse_mode: str = None, reply_markup=None, input_message_content=None): - self.type = type # string - self.id = id # string - self.mpeg4_url = mpeg4_url # string - self.mpeg4_width = mpeg4_width # flags.0?int - self.mpeg4_height = mpeg4_height # flags.1?int - self.mpeg4_duration = mpeg4_duration # flags.2?int - self.thumb_url = thumb_url # string - self.title = title # flags.3?string - self.caption = caption # flags.4?string - self.parse_mode = parse_mode # flags.5?string - self.reply_markup = reply_markup # flags.6?InlineKeyboardMarkup - self.input_message_content = input_message_content # flags.7?InputMessageContent diff --git a/pyrogram/client/types/inline_mode/todo/inline_query_result_photo.py b/pyrogram/client/types/inline_mode/todo/inline_query_result_photo.py deleted file mode 100644 index 570bd55d..00000000 --- a/pyrogram/client/types/inline_mode/todo/inline_query_result_photo.py +++ /dev/null @@ -1,126 +0,0 @@ -# Pyrogram - Telegram MTProto API Client Library for Python -# Copyright (C) 2017-2018 Dan Tès -# -# This file is part of Pyrogram. -# -# Pyrogram is free software: you can redistribute it and/or modify -# it under the terms of the GNU Lesser General Public License as published -# by the Free Software Foundation, either version 3 of the License, or -# (at your option) any later version. -# -# Pyrogram is distributed in the hope that it will be useful, -# but WITHOUT ANY WARRANTY; without even the implied warranty of -# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the -# GNU Lesser General Public License for more details. -# -# You should have received a copy of the GNU Lesser General Public License -# along with Pyrogram. If not, see . - -from pyrogram.api import types -from pyrogram.client.style import HTML, Markdown -from pyrogram.client.types.object import Object - - -class InlineQueryResultPhoto(Object): - """Represents a link to a photo. By default, this photo will be sent by the user with optional caption. - Alternatively, you can use input_message_content to send a message with the specified content instead of the photo. - - Parameters: - id (``str``): - Unique identifier for this result, 1-64 bytes. - - photo_url (``str``): - A valid URL of the photo. Photo must be in jpeg format. Photo size must not exceed 5MB. - - thumb_url (``str``): - URL of the thumbnail for the photo. - - photo_width (``int``, *optional*): - Width of the photo. - - photo_height (``int``, *optional*): - Height of the photo. - - title (``str``, *optional*): - Title for the result. - - description (``str``, *optional*): - Short description of the result. - - caption (``str``, *optional*): - Caption of the photo to be sent, 0-200 characters. - - parse_mode (``str``, *optional*): - Send Markdown or HTML, if you want Telegram apps to show bold, italic, fixed-width text or inline URLs in - the media caption. - - reply_markup (:obj:`InlineKeyboardMarkup`, *optional*): - Inline keyboard attached to the message. - - input_message_content (:obj:`InputMessageContent`, *optional*): - Content of the message to be sent instead of the photo. - - """ - - def __init__( - self, - id: str, - photo_url: str, - thumb_url: str, - photo_width: int = 0, - photo_height: int = 0, - title: str = None, - description: str = None, - caption: str = "", - parse_mode: str = "", - reply_markup=None, - input_message_content=None - ): - self.id = id # string - self.photo_url = photo_url # string - self.thumb_url = thumb_url # string - self.photo_width = photo_width # flags.0?int - self.photo_height = photo_height # flags.1?int - self.title = title # flags.2?string - self.description = description # flags.3?string - self.caption = caption # flags.4?string - self.parse_mode = parse_mode # flags.5?string - self.reply_markup = reply_markup # flags.6?InlineKeyboardMarkup - self.input_message_content = input_message_content # flags.7?InputMessageContent - - self.style = HTML() if parse_mode.lower() == "html" else Markdown() - - def write(self): - return types.InputBotInlineResult( - id=self.id, - type="photo", - send_message=types.InputBotInlineMessageMediaAuto( - reply_markup=self.reply_markup.write() if self.reply_markup else None, - **self.style.parse(self.caption) - ), - title=self.title, - description=self.description, - url=self.photo_url, - thumb=types.InputWebDocument( - url=self.thumb_url, - size=0, - mime_type="image/jpeg", - attributes=[ - types.DocumentAttributeImageSize( - w=0, - h=0 - ) - ] - ), - content=types.InputWebDocument( - url=self.thumb_url, - size=0, - mime_type="image/jpeg", - attributes=[ - types.DocumentAttributeImageSize( - w=self.photo_width, - h=self.photo_height - ) - ] - ) - ) diff --git a/pyrogram/client/types/inline_mode/todo/inline_query_result_venue.py b/pyrogram/client/types/inline_mode/todo/inline_query_result_venue.py deleted file mode 100644 index 29eb86a6..00000000 --- a/pyrogram/client/types/inline_mode/todo/inline_query_result_venue.py +++ /dev/null @@ -1,86 +0,0 @@ -# Pyrogram - Telegram MTProto API Client Library for Python -# Copyright (C) 2017-2018 Dan Tès -# -# This file is part of Pyrogram. -# -# Pyrogram is free software: you can redistribute it and/or modify -# it under the terms of the GNU Lesser General Public License as published -# by the Free Software Foundation, either version 3 of the License, or -# (at your option) any later version. -# -# Pyrogram is distributed in the hope that it will be useful, -# but WITHOUT ANY WARRANTY; without even the implied warranty of -# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the -# GNU Lesser General Public License for more details. -# -# You should have received a copy of the GNU Lesser General Public License -# along with Pyrogram. If not, see . - -from pyrogram.client.types.object import Object - - -class InlineQueryResultVenue(Object): - """Represents a venue. By default, the venue will be sent by the user. Alternatively, you can use input_message_content to send a message with the specified content instead of the venue. - - Attributes: - ID: ``0xb0700008`` - - Parameters: - type (``str``): - Type of the result, must be venue. - - id (``str``): - Unique identifier for this result, 1-64 Bytes. - - latitude (``float`` ``64-bit``): - Latitude of the venue location in degrees. - - longitude (``float`` ``64-bit``): - Longitude of the venue location in degrees. - - title (``str``): - Title of the venue. - - address (``str``): - Address of the venue. - - foursquare_id (``str``, optional): - Foursquare identifier of the venue if known. - - foursquare_type (``str``, optional): - Foursquare type of the venue, if known. (For example, "arts_entertainment/default", "arts_entertainment/aquarium" or "food/icecream".). - - reply_markup (:obj:`InlineKeyboardMarkup`, optional): - Inline keyboard attached to the message. - - input_message_content (:obj:`InputMessageContent`, optional): - Content of the message to be sent instead of the venue. - - thumb_url (``str``, optional): - Url of the thumbnail for the result. - - thumb_width (``int`` ``32-bit``, optional): - Thumbnail width. - - thumb_height (``int`` ``32-bit``, optional): - Thumbnail height. - - """ - ID = 0xb0700008 - - def __init__(self, type: str, id: str, latitude: float, longitude: float, title: str, address: str, - foursquare_id: str = None, foursquare_type: str = None, reply_markup=None, input_message_content=None, - thumb_url: str = None, thumb_width: int = None, thumb_height: int = None): - self.type = type # string - self.id = id # string - self.latitude = latitude # double - self.longitude = longitude # double - self.title = title # string - self.address = address # string - self.foursquare_id = foursquare_id # flags.0?string - self.foursquare_type = foursquare_type # flags.1?string - self.reply_markup = reply_markup # flags.2?InlineKeyboardMarkup - self.input_message_content = input_message_content # flags.3?InputMessageContent - self.thumb_url = thumb_url # flags.4?string - self.thumb_width = thumb_width # flags.5?int - self.thumb_height = thumb_height # flags.6?int diff --git a/pyrogram/client/types/inline_mode/todo/inline_query_result_video.py b/pyrogram/client/types/inline_mode/todo/inline_query_result_video.py deleted file mode 100644 index 61984d48..00000000 --- a/pyrogram/client/types/inline_mode/todo/inline_query_result_video.py +++ /dev/null @@ -1,90 +0,0 @@ -# Pyrogram - Telegram MTProto API Client Library for Python -# Copyright (C) 2017-2018 Dan Tès -# -# This file is part of Pyrogram. -# -# Pyrogram is free software: you can redistribute it and/or modify -# it under the terms of the GNU Lesser General Public License as published -# by the Free Software Foundation, either version 3 of the License, or -# (at your option) any later version. -# -# Pyrogram is distributed in the hope that it will be useful, -# but WITHOUT ANY WARRANTY; without even the implied warranty of -# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the -# GNU Lesser General Public License for more details. -# -# You should have received a copy of the GNU Lesser General Public License -# along with Pyrogram. If not, see . - -from pyrogram.client.types.object import Object - - -class InlineQueryResultVideo(Object): - """Represents a link to a page containing an embedded video player or a video file. By default, this video file will be sent by the user with an optional caption. Alternatively, you can use input_message_content to send a message with the specified content instead of the video. - - Attributes: - ID: ``0xb0700003`` - - Parameters: - type (``str``): - Type of the result, must be video. - - id (``str``): - Unique identifier for this result, 1-64 bytes. - - video_url (``str``): - A valid URL for the embedded video player or video file. - - mime_type (``str``): - Mime type of the content of video url, "text/html" or "video/mp4". - - thumb_url (``str``): - URL of the thumbnail (jpeg only) for the video. - - title (``str``): - Title for the result. - - caption (``str``, optional): - Caption of the video to be sent, 0-200 characters. - - parse_mode (``str``, optional): - Send Markdown or HTML, if you want Telegram apps to show bold, italic, fixed-width text or inline URLs in the media caption. - - video_width (``int`` ``32-bit``, optional): - Video width. - - video_height (``int`` ``32-bit``, optional): - Video height. - - video_duration (``int`` ``32-bit``, optional): - Video duration in seconds. - - description (``str``, optional): - Short description of the result. - - reply_markup (:obj:`InlineKeyboardMarkup`, optional): - Inline keyboard attached to the message. - - input_message_content (:obj:`InputMessageContent`, optional): - Content of the message to be sent instead of the video. This field is required if InlineQueryResultVideo is used to send an HTML-page as a result (e.g., a YouTube video). - - """ - ID = 0xb0700003 - - def __init__(self, type: str, id: str, video_url: str, mime_type: str, thumb_url: str, title: str, - caption: str = None, parse_mode: str = None, video_width: int = None, video_height: int = None, - video_duration: int = None, description: str = None, reply_markup=None, input_message_content=None): - self.type = type # string - self.id = id # string - self.video_url = video_url # string - self.mime_type = mime_type # string - self.thumb_url = thumb_url # string - self.title = title # string - self.caption = caption # flags.0?string - self.parse_mode = parse_mode # flags.1?string - self.video_width = video_width # flags.2?int - self.video_height = video_height # flags.3?int - self.video_duration = video_duration # flags.4?int - self.description = description # flags.5?string - self.reply_markup = reply_markup # flags.6?InlineKeyboardMarkup - self.input_message_content = input_message_content # flags.7?InputMessageContent diff --git a/pyrogram/client/types/inline_mode/todo/inline_query_result_voice.py b/pyrogram/client/types/inline_mode/todo/inline_query_result_voice.py deleted file mode 100644 index 7a5f3cd1..00000000 --- a/pyrogram/client/types/inline_mode/todo/inline_query_result_voice.py +++ /dev/null @@ -1,69 +0,0 @@ -# Pyrogram - Telegram MTProto API Client Library for Python -# Copyright (C) 2017-2018 Dan Tès -# -# This file is part of Pyrogram. -# -# Pyrogram is free software: you can redistribute it and/or modify -# it under the terms of the GNU Lesser General Public License as published -# by the Free Software Foundation, either version 3 of the License, or -# (at your option) any later version. -# -# Pyrogram is distributed in the hope that it will be useful, -# but WITHOUT ANY WARRANTY; without even the implied warranty of -# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the -# GNU Lesser General Public License for more details. -# -# You should have received a copy of the GNU Lesser General Public License -# along with Pyrogram. If not, see . - -from pyrogram.client.types.object import Object - - -class InlineQueryResultVoice(Object): - """Represents a link to a voice recording in an .ogg container encoded with OPUS. By default, this voice recording will be sent by the user. Alternatively, you can use input_message_content to send a message with the specified content instead of the the voice message. - - Attributes: - ID: ``0xb0700005`` - - Parameters: - type (``str``): - Type of the result, must be voice. - - id (``str``): - Unique identifier for this result, 1-64 bytes. - - voice_url (``str``): - A valid URL for the voice recording. - - title (``str``): - Recording title. - - caption (``str``, optional): - Caption, 0-200 characters. - - parse_mode (``str``, optional): - Send Markdown or HTML, if you want Telegram apps to show bold, italic, fixed-width text or inline URLs in the media caption. - - voice_duration (``int`` ``32-bit``, optional): - Recording duration in seconds. - - reply_markup (:obj:`InlineKeyboardMarkup`, optional): - Inline keyboard attached to the message. - - input_message_content (:obj:`InputMessageContent`, optional): - Content of the message to be sent instead of the voice recording. - - """ - ID = 0xb0700005 - - def __init__(self, type: str, id: str, voice_url: str, title: str, caption: str = None, parse_mode: str = None, - voice_duration: int = None, reply_markup=None, input_message_content=None): - self.type = type # string - self.id = id # string - self.voice_url = voice_url # string - self.title = title # string - self.caption = caption # flags.0?string - self.parse_mode = parse_mode # flags.1?string - self.voice_duration = voice_duration # flags.2?int - self.reply_markup = reply_markup # flags.3?InlineKeyboardMarkup - self.input_message_content = input_message_content # flags.4?InputMessageContent From 8d852cb47ee10863de67033a87648cb1daa82aeb Mon Sep 17 00:00:00 2001 From: Dan <14043624+delivrance@users.noreply.github.com> Date: Wed, 26 Jun 2019 16:05:09 +0200 Subject: [PATCH 2/7] Implement strict and loose markdown parsing This is enabled by default: - strict: only markdown syntax is parsed - loose: both markdown and html syntax are parsed --- pyrogram/client/{style => parser}/markdown.py | 93 +++++++++---------- 1 file changed, 43 insertions(+), 50 deletions(-) rename pyrogram/client/{style => parser}/markdown.py (66%) diff --git a/pyrogram/client/style/markdown.py b/pyrogram/client/parser/markdown.py similarity index 66% rename from pyrogram/client/style/markdown.py rename to pyrogram/client/parser/markdown.py index 93d8fc9a..74d06e97 100644 --- a/pyrogram/client/style/markdown.py +++ b/pyrogram/client/parser/markdown.py @@ -18,6 +18,7 @@ import html import re +from typing import Union import pyrogram from . import utils @@ -30,42 +31,52 @@ STRIKE_DELIM = "~~" CODE_DELIM = "`" PRE_DELIM = "```" +MARKDOWN_RE = re.compile(r"({d})|\[(.+?)\]\((.+?)\)".format( + d="|".join( + ["".join(i) for i in [ + [r"\{}".format(j) for j in i] + for i in [ + PRE_DELIM, + CODE_DELIM, + STRIKE_DELIM, + UNDERLINE_DELIM, + ITALIC_DELIM, + BOLD_DELIM + ] + ]] + ))) + +OPENING_TAG = "<{}>" +CLOSING_TAG = "" +URL_MARKUP = '{}' +FIXED_WIDTH_DELIMS = [CODE_DELIM, PRE_DELIM] + class Markdown: - MARKDOWN_RE = re.compile(r"({d})".format( - d="|".join( - ["".join(i) for i in [ - [r"\{}".format(j) for j in i] - for i in [ - PRE_DELIM, - CODE_DELIM, - STRIKE_DELIM, - UNDERLINE_DELIM, - ITALIC_DELIM, - BOLD_DELIM - ] - ]] - ))) - - URL_RE = re.compile(r"\[([^[]+)]\(([^(]+)\)") - - OPENING_TAG = "<{}>" - CLOSING_TAG = "" - URL_MARKUP = '{}' - FIXED_WIDTH_DELIMS = [CODE_DELIM, PRE_DELIM] - - def __init__(self, client: "pyrogram.BaseClient"): + def __init__(self, client: Union["pyrogram.BaseClient", None]): self.html = HTML(client) - def parse(self, text: str): - text = html.escape(text) + def parse(self, text: str, strict: bool = False): + if strict: + text = html.escape(text) - offset = 0 delims = set() + is_fixed_width = False - for i, match in enumerate(re.finditer(Markdown.MARKDOWN_RE, text)): - start, stop = match.span() - delim = match.group(1) + for i, match in enumerate(re.finditer(MARKDOWN_RE, text)): + start, _ = match.span() + delim, text_url, url = match.groups() + full = match.group(0) + + if delim in FIXED_WIDTH_DELIMS: + is_fixed_width = not is_fixed_width + + if is_fixed_width and delim not in FIXED_WIDTH_DELIMS: + continue + + if text_url: + text = utils.replace_once(text, full, URL_MARKUP.format(url, text_url), start) + continue if delim == BOLD_DELIM: tag = "b" @@ -82,32 +93,14 @@ class Markdown: else: continue - if delim not in Markdown.FIXED_WIDTH_DELIMS and any(x in delims for x in Markdown.FIXED_WIDTH_DELIMS): - continue - if delim not in delims: delims.add(delim) - tag = Markdown.OPENING_TAG.format(tag) + tag = OPENING_TAG.format(tag) else: delims.remove(delim) - tag = Markdown.CLOSING_TAG.format(tag) + tag = CLOSING_TAG.format(tag) - text = text[:start + offset] + tag + text[stop + offset:] - - offset += len(tag) - len(delim) - - offset = 0 - - for match in re.finditer(Markdown.URL_RE, text): - start, stop = match.span() - full = match.group(0) - - body, url = match.groups() - replace = Markdown.URL_MARKUP.format(url, body) - - text = text[:start + offset] + replace + text[stop + offset:] - - offset += len(replace) - len(full) + text = utils.replace_once(text, delim, tag, start) return self.html.parse(text) From be5f0c95298fdf6b19c51f301a1adf856ee5743e Mon Sep 17 00:00:00 2001 From: Dan <14043624+delivrance@users.noreply.github.com> Date: Wed, 26 Jun 2019 16:06:50 +0200 Subject: [PATCH 3/7] Parser's client can be None In that case, check if is None and don't parse user mentions. This happens only in text content for inline results --- pyrogram/client/{style => parser}/html.py | 8 +++++--- 1 file changed, 5 insertions(+), 3 deletions(-) rename pyrogram/client/{style => parser}/html.py (95%) diff --git a/pyrogram/client/style/html.py b/pyrogram/client/parser/html.py similarity index 95% rename from pyrogram/client/style/html.py rename to pyrogram/client/parser/html.py index 5617cb54..16c5922a 100644 --- a/pyrogram/client/style/html.py +++ b/pyrogram/client/parser/html.py @@ -20,6 +20,7 @@ import html import re from collections import OrderedDict from html.parser import HTMLParser +from typing import Union import pyrogram from pyrogram.api import types @@ -103,7 +104,7 @@ class Parser(HTMLParser): class HTML: - def __init__(self, client: "pyrogram.BaseClient" = None): + def __init__(self, client: Union["pyrogram.BaseClient", None]): self.client = client def parse(self, text: str): @@ -126,7 +127,8 @@ class HTML: for entity in parser.entities: if isinstance(entity, types.InputMessageEntityMentionName): try: - entity.user_id = self.client.resolve_peer(entity.user_id) + if self.client is not None: + entity.user_id = self.client.resolve_peer(entity.user_id) except PeerIdInvalid: continue @@ -135,7 +137,7 @@ class HTML: # TODO: OrderedDict to be removed in Python 3.6 return OrderedDict([ ("message", utils.remove_surrogates(parser.text)), - ("entities", entities) + ("entities", sorted(entities, key=lambda e: e.offset)) ]) @staticmethod From e61bf9262740996ccce04c90e49bab633ef59060 Mon Sep 17 00:00:00 2001 From: Dan <14043624+delivrance@users.noreply.github.com> Date: Wed, 26 Jun 2019 16:07:27 +0200 Subject: [PATCH 4/7] Add Parser package Revamped from HTML/Markdown --- pyrogram/client/{style => parser}/__init__.py | 3 +- pyrogram/client/parser/parser.py | 56 +++++++++++++++++++ pyrogram/client/{style => parser}/utils.py | 4 ++ 3 files changed, 61 insertions(+), 2 deletions(-) rename pyrogram/client/{style => parser}/__init__.py (93%) create mode 100644 pyrogram/client/parser/parser.py rename pyrogram/client/{style => parser}/utils.py (91%) diff --git a/pyrogram/client/style/__init__.py b/pyrogram/client/parser/__init__.py similarity index 93% rename from pyrogram/client/style/__init__.py rename to pyrogram/client/parser/__init__.py index 768cee7b..4769038d 100644 --- a/pyrogram/client/style/__init__.py +++ b/pyrogram/client/parser/__init__.py @@ -16,5 +16,4 @@ # You should have received a copy of the GNU Lesser General Public License # along with Pyrogram. If not, see . -from .html import HTML -from .markdown import Markdown +from .parser import Parser \ No newline at end of file diff --git a/pyrogram/client/parser/parser.py b/pyrogram/client/parser/parser.py new file mode 100644 index 00000000..afb7ecaa --- /dev/null +++ b/pyrogram/client/parser/parser.py @@ -0,0 +1,56 @@ +# Pyrogram - Telegram MTProto API Client Library for Python +# Copyright (C) 2017-2019 Dan Tès +# +# This file is part of Pyrogram. +# +# Pyrogram is free software: you can redistribute it and/or modify +# it under the terms of the GNU Lesser General Public License as published +# by the Free Software Foundation, either version 3 of the License, or +# (at your option) any later version. +# +# Pyrogram is distributed in the hope that it will be useful, +# but WITHOUT ANY WARRANTY; without even the implied warranty of +# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the +# GNU Lesser General Public License for more details. +# +# You should have received a copy of the GNU Lesser General Public License +# along with Pyrogram. If not, see . + +from collections import OrderedDict +from typing import Union + + +import pyrogram +from .html import HTML +from .markdown import Markdown + + +class Parser: + def __init__(self, client: Union["pyrogram.BaseClient", None]): + self.html = HTML(client) + self.markdown = Markdown(client) + + def parse(self, text: str, mode: str = ""): + if mode is None: + return OrderedDict([ + ("message", text), + ("entities", []) + ]) + + mode = mode.lower() + + if mode == "": + return self.markdown.parse(text) + + if mode in ["markdown", "md"]: + return self.markdown.parse(text, True) + + if mode == "html": + return self.html.parse(text) + + @staticmethod + def unparse(text: str, entities: list, is_html: bool): + if is_html: + return HTML.unparse(text, entities) + else: + return Markdown.unparse(text, entities) diff --git a/pyrogram/client/style/utils.py b/pyrogram/client/parser/utils.py similarity index 91% rename from pyrogram/client/style/utils.py rename to pyrogram/client/parser/utils.py index b001f1cf..1fce419f 100644 --- a/pyrogram/client/style/utils.py +++ b/pyrogram/client/parser/utils.py @@ -35,3 +35,7 @@ def add_surrogates(text): def remove_surrogates(text): # Replace each surrogate pair with a SMP code point return text.encode("utf-16", "surrogatepass").decode("utf-16") + + +def replace_once(source: str, old: str, new: str, start: int): + return source[:start] + source[start:].replace(old, new, 1) From f05e79e0f4a7f6ebcba8be9158f7ecd868293926 Mon Sep 17 00:00:00 2001 From: Dan <14043624+delivrance@users.noreply.github.com> Date: Wed, 26 Jun 2019 16:08:24 +0200 Subject: [PATCH 5/7] Update usages of Parser all around the library --- pyrogram/client/ext/base_client.py | 5 ++--- pyrogram/client/methods/messages/edit_inline_text.py | 7 ++++--- pyrogram/client/methods/messages/edit_message_text.py | 5 ++--- pyrogram/client/methods/messages/send_animation.py | 5 ++--- pyrogram/client/methods/messages/send_audio.py | 5 ++--- pyrogram/client/methods/messages/send_cached_media.py | 5 ++--- pyrogram/client/methods/messages/send_document.py | 5 ++--- pyrogram/client/methods/messages/send_message.py | 5 ++--- pyrogram/client/methods/messages/send_photo.py | 5 ++--- pyrogram/client/methods/messages/send_video.py | 5 ++--- pyrogram/client/methods/messages/send_voice.py | 5 ++--- .../input_message_content/input_text_message_content.py | 8 +++++--- pyrogram/client/types/messages_and_media/message.py | 6 +++--- 13 files changed, 32 insertions(+), 39 deletions(-) diff --git a/pyrogram/client/ext/base_client.py b/pyrogram/client/ext/base_client.py index 88623f4a..b5be089b 100644 --- a/pyrogram/client/ext/base_client.py +++ b/pyrogram/client/ext/base_client.py @@ -25,7 +25,7 @@ from queue import Queue from threading import Lock from pyrogram import __version__ -from ..style import Markdown, HTML +from ..parser import Parser from ...session.internals import MsgId @@ -92,8 +92,7 @@ class BaseClient: self.rnd_id = MsgId - self.markdown = Markdown(self) - self.html = HTML(self) + self.parser = Parser(self) self.session = None self.media_sessions = {} diff --git a/pyrogram/client/methods/messages/edit_inline_text.py b/pyrogram/client/methods/messages/edit_inline_text.py index 927fd80f..349e3e35 100644 --- a/pyrogram/client/methods/messages/edit_inline_text.py +++ b/pyrogram/client/methods/messages/edit_inline_text.py @@ -16,6 +16,8 @@ # You should have received a copy of the GNU Lesser General Public License # along with Pyrogram. If not, see . +from typing import Union + import pyrogram from pyrogram.api import functions from pyrogram.client.ext import BaseClient, utils @@ -26,7 +28,7 @@ class EditInlineText(BaseClient): self, inline_message_id: str, text: str, - parse_mode: str = "", + parse_mode: Union[str, None] = "", disable_web_page_preview: bool = None, reply_markup: "pyrogram.InlineKeyboardMarkup" = None ) -> bool: @@ -55,13 +57,12 @@ class EditInlineText(BaseClient): Raises: RPCError: In case of a Telegram RPC error. """ - style = self.html if parse_mode.lower() == "html" else self.markdown return self.send( functions.messages.EditInlineBotMessage( id=utils.unpack_inline_message_id(inline_message_id), no_webpage=disable_web_page_preview or None, reply_markup=reply_markup.write() if reply_markup else None, - **style.parse(text) + **self.parser.parse(text, parse_mode) ) ) diff --git a/pyrogram/client/methods/messages/edit_message_text.py b/pyrogram/client/methods/messages/edit_message_text.py index 7e4345c6..e30afdfc 100644 --- a/pyrogram/client/methods/messages/edit_message_text.py +++ b/pyrogram/client/methods/messages/edit_message_text.py @@ -29,7 +29,7 @@ class EditMessageText(BaseClient): chat_id: Union[int, str], message_id: int, text: str, - parse_mode: str = "", + parse_mode: Union[str, None] = "", disable_web_page_preview: bool = None, reply_markup: "pyrogram.InlineKeyboardMarkup" = None ) -> "pyrogram.Message": @@ -63,7 +63,6 @@ class EditMessageText(BaseClient): Raises: RPCError: In case of a Telegram RPC error. """ - style = self.html if parse_mode.lower() == "html" else self.markdown r = self.send( functions.messages.EditMessage( @@ -71,7 +70,7 @@ class EditMessageText(BaseClient): id=message_id, no_webpage=disable_web_page_preview or None, reply_markup=reply_markup.write() if reply_markup else None, - **style.parse(text) + **self.parser.parse(text, parse_mode) ) ) diff --git a/pyrogram/client/methods/messages/send_animation.py b/pyrogram/client/methods/messages/send_animation.py index 0c4649dd..cff80af5 100644 --- a/pyrogram/client/methods/messages/send_animation.py +++ b/pyrogram/client/methods/messages/send_animation.py @@ -32,7 +32,7 @@ class SendAnimation(BaseClient): animation: str, caption: str = "", unsave: bool = False, - parse_mode: str = "", + parse_mode: Union[str, None] = "", duration: int = 0, width: int = 0, height: int = 0, @@ -130,7 +130,6 @@ class SendAnimation(BaseClient): RPCError: In case of a Telegram RPC error. """ file = None - style = self.html if parse_mode.lower() == "html" else self.markdown try: if os.path.exists(animation): @@ -168,7 +167,7 @@ class SendAnimation(BaseClient): reply_to_msg_id=reply_to_message_id, random_id=self.rnd_id(), reply_markup=reply_markup.write() if reply_markup else None, - **style.parse(caption) + **self.parser.parse(caption, parse_mode) ) ) except FilePartMissing as e: diff --git a/pyrogram/client/methods/messages/send_audio.py b/pyrogram/client/methods/messages/send_audio.py index 7b218a66..5cd9fc8d 100644 --- a/pyrogram/client/methods/messages/send_audio.py +++ b/pyrogram/client/methods/messages/send_audio.py @@ -31,7 +31,7 @@ class SendAudio(BaseClient): chat_id: Union[int, str], audio: str, caption: str = "", - parse_mode: str = "", + parse_mode: Union[str, None] = "", duration: int = 0, performer: str = None, title: str = None, @@ -127,7 +127,6 @@ class SendAudio(BaseClient): RPCError: In case of a Telegram RPC error. """ file = None - style = self.html if parse_mode.lower() == "html" else self.markdown try: if os.path.exists(audio): @@ -163,7 +162,7 @@ class SendAudio(BaseClient): reply_to_msg_id=reply_to_message_id, random_id=self.rnd_id(), reply_markup=reply_markup.write() if reply_markup else None, - **style.parse(caption) + **self.parser.parse(caption, parse_mode) ) ) except FilePartMissing as e: diff --git a/pyrogram/client/methods/messages/send_cached_media.py b/pyrogram/client/methods/messages/send_cached_media.py index 99961ca1..1c5aad7b 100644 --- a/pyrogram/client/methods/messages/send_cached_media.py +++ b/pyrogram/client/methods/messages/send_cached_media.py @@ -29,7 +29,7 @@ class SendCachedMedia(BaseClient): chat_id: Union[int, str], file_id: str, caption: str = "", - parse_mode: str = "", + parse_mode: Union[str, None] = "", disable_notification: bool = None, reply_to_message_id: int = None, reply_markup: Union[ @@ -79,7 +79,6 @@ class SendCachedMedia(BaseClient): Raises: RPCError: In case of a Telegram RPC error. """ - style = self.html if parse_mode.lower() == "html" else self.markdown r = self.send( functions.messages.SendMedia( @@ -89,7 +88,7 @@ class SendCachedMedia(BaseClient): reply_to_msg_id=reply_to_message_id, random_id=self.rnd_id(), reply_markup=reply_markup.write() if reply_markup else None, - **style.parse(caption) + **self.parser.parse(caption, parse_mode) ) ) diff --git a/pyrogram/client/methods/messages/send_document.py b/pyrogram/client/methods/messages/send_document.py index da012b2c..55ab53af 100644 --- a/pyrogram/client/methods/messages/send_document.py +++ b/pyrogram/client/methods/messages/send_document.py @@ -32,7 +32,7 @@ class SendDocument(BaseClient): document: str, thumb: str = None, caption: str = "", - parse_mode: str = "", + parse_mode: Union[str, None] = "", disable_notification: bool = None, reply_to_message_id: int = None, reply_markup: Union[ @@ -113,7 +113,6 @@ class SendDocument(BaseClient): RPCError: In case of a Telegram RPC error. """ file = None - style = self.html if parse_mode.lower() == "html" else self.markdown try: if os.path.exists(document): @@ -144,7 +143,7 @@ class SendDocument(BaseClient): reply_to_msg_id=reply_to_message_id, random_id=self.rnd_id(), reply_markup=reply_markup.write() if reply_markup else None, - **style.parse(caption) + **self.parser(caption, parse_mode) ) ) except FilePartMissing as e: diff --git a/pyrogram/client/methods/messages/send_message.py b/pyrogram/client/methods/messages/send_message.py index f8caa081..959cf9b9 100644 --- a/pyrogram/client/methods/messages/send_message.py +++ b/pyrogram/client/methods/messages/send_message.py @@ -28,7 +28,7 @@ class SendMessage(BaseClient): self, chat_id: Union[int, str], text: str, - parse_mode: str = "", + parse_mode: Union[str, None] = "", disable_web_page_preview: bool = None, disable_notification: bool = None, reply_to_message_id: int = None, @@ -74,8 +74,7 @@ class SendMessage(BaseClient): Raises: RPCError: In case of a Telegram RPC error. """ - style = self.html if parse_mode.lower() == "html" else self.markdown - message, entities = style.parse(text).values() + message, entities = self.parser.parse(text, parse_mode).values() r = self.send( functions.messages.SendMessage( diff --git a/pyrogram/client/methods/messages/send_photo.py b/pyrogram/client/methods/messages/send_photo.py index c1fd33d8..8ebb2761 100644 --- a/pyrogram/client/methods/messages/send_photo.py +++ b/pyrogram/client/methods/messages/send_photo.py @@ -31,7 +31,7 @@ class SendPhoto(BaseClient): chat_id: Union[int, str], photo: str, caption: str = "", - parse_mode: str = "", + parse_mode: Union[str, None] = "", ttl_seconds: int = None, disable_notification: bool = None, reply_to_message_id: int = None, @@ -112,7 +112,6 @@ class SendPhoto(BaseClient): RPCError: In case of a Telegram RPC error. """ file = None - style = self.html if parse_mode.lower() == "html" else self.markdown try: if os.path.exists(photo): @@ -139,7 +138,7 @@ class SendPhoto(BaseClient): reply_to_msg_id=reply_to_message_id, random_id=self.rnd_id(), reply_markup=reply_markup.write() if reply_markup else None, - **style.parse(caption) + **self.parser.parse(caption, parse_mode) ) ) except FilePartMissing as e: diff --git a/pyrogram/client/methods/messages/send_video.py b/pyrogram/client/methods/messages/send_video.py index 4e1201fc..0785056d 100644 --- a/pyrogram/client/methods/messages/send_video.py +++ b/pyrogram/client/methods/messages/send_video.py @@ -31,7 +31,7 @@ class SendVideo(BaseClient): chat_id: Union[int, str], video: str, caption: str = "", - parse_mode: str = "", + parse_mode: Union[str, None] = "", duration: int = 0, width: int = 0, height: int = 0, @@ -129,7 +129,6 @@ class SendVideo(BaseClient): RPCError: In case of a Telegram RPC error. """ file = None - style = self.html if parse_mode.lower() == "html" else self.markdown try: if os.path.exists(video): @@ -166,7 +165,7 @@ class SendVideo(BaseClient): reply_to_msg_id=reply_to_message_id, random_id=self.rnd_id(), reply_markup=reply_markup.write() if reply_markup else None, - **style.parse(caption) + **self.parser.parse(caption, parse_mode) ) ) except FilePartMissing as e: diff --git a/pyrogram/client/methods/messages/send_voice.py b/pyrogram/client/methods/messages/send_voice.py index 9dace1e0..45dfa45b 100644 --- a/pyrogram/client/methods/messages/send_voice.py +++ b/pyrogram/client/methods/messages/send_voice.py @@ -31,7 +31,7 @@ class SendVoice(BaseClient): chat_id: Union[int, str], voice: str, caption: str = "", - parse_mode: str = "", + parse_mode: Union[str, None] = "", duration: int = 0, disable_notification: bool = None, reply_to_message_id: int = None, @@ -110,7 +110,6 @@ class SendVoice(BaseClient): RPCError: In case of a Telegram RPC error. """ file = None - style = self.html if parse_mode.lower() == "html" else self.markdown try: if os.path.exists(voice): @@ -142,7 +141,7 @@ class SendVoice(BaseClient): reply_to_msg_id=reply_to_message_id, random_id=self.rnd_id(), reply_markup=reply_markup.write() if reply_markup else None, - **style.parse(caption) + **self.parser.parse(caption, parse_mode) ) ) except FilePartMissing as e: diff --git a/pyrogram/client/types/input_message_content/input_text_message_content.py b/pyrogram/client/types/input_message_content/input_text_message_content.py index 4b294aab..7db2069d 100644 --- a/pyrogram/client/types/input_message_content/input_text_message_content.py +++ b/pyrogram/client/types/input_message_content/input_text_message_content.py @@ -16,9 +16,11 @@ # You should have received a copy of the GNU Lesser General Public License # along with Pyrogram. If not, see . +from typing import Union + from pyrogram.api import types from .input_message_content import InputMessageContent -from ...style import HTML, Markdown +from ...parser import Parser class InputTextMessageContent(InputMessageContent): @@ -38,7 +40,7 @@ class InputTextMessageContent(InputMessageContent): __slots__ = ["message_text", "parse_mode", "disable_web_page_preview"] - def __init__(self, message_text: str, parse_mode: str = "", disable_web_page_preview: bool = None): + def __init__(self, message_text: str, parse_mode: Union[str, None] = "", disable_web_page_preview: bool = None): super().__init__() self.message_text = message_text @@ -49,5 +51,5 @@ class InputTextMessageContent(InputMessageContent): return types.InputBotInlineMessageText( no_webpage=self.disable_web_page_preview or None, reply_markup=reply_markup.write() if reply_markup else None, - **(HTML() if self.parse_mode.lower() == "html" else Markdown()).parse(self.message_text) + **(Parser(None)).parse(self.message_text, self.parse_mode) ) diff --git a/pyrogram/client/types/messages_and_media/message.py b/pyrogram/client/types/messages_and_media/message.py index 16726a47..549d6f09 100644 --- a/pyrogram/client/types/messages_and_media/message.py +++ b/pyrogram/client/types/messages_and_media/message.py @@ -31,7 +31,7 @@ from ..object import Object from ..update import Update from ..user_and_chats.chat import Chat from ..user_and_chats.user import User -from ...style import utils, Markdown, HTML +from ...parser import utils, Parser class Str(str): @@ -47,11 +47,11 @@ class Str(str): @property def markdown(self): - return Markdown.unparse(self, self.entities) + return Parser.unparse(self, self.entities, False) @property def html(self): - return HTML.unparse(self, self.entities) + return Parser.unparse(self, self.entities, True) def __getitem__(self, item): return utils.remove_surrogates(utils.add_surrogates(self)[item]) From 197cf5506ce7cbeb03db10b2b979e29040cf9119 Mon Sep 17 00:00:00 2001 From: Dan <14043624+delivrance@users.noreply.github.com> Date: Wed, 26 Jun 2019 16:36:00 +0200 Subject: [PATCH 6/7] Only allow either "markdown" or "html" as text style parse mode --- pyrogram/client/parser/parser.py | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/pyrogram/client/parser/parser.py b/pyrogram/client/parser/parser.py index afb7ecaa..f685c942 100644 --- a/pyrogram/client/parser/parser.py +++ b/pyrogram/client/parser/parser.py @@ -42,7 +42,7 @@ class Parser: if mode == "": return self.markdown.parse(text) - if mode in ["markdown", "md"]: + if mode in "markdown": return self.markdown.parse(text, True) if mode == "html": From 39e25147bd66c1b82f5654b8595f020eb5a7c719 Mon Sep 17 00:00:00 2001 From: Dan <14043624+delivrance@users.noreply.github.com> Date: Wed, 26 Jun 2019 16:36:24 +0200 Subject: [PATCH 7/7] Update parse_mode parameter docstrings --- .../methods/messages/edit_inline_caption.py | 7 +- .../methods/messages/edit_inline_text.py | 7 +- .../methods/messages/edit_message_caption.py | 7 +- .../methods/messages/edit_message_text.py | 7 +- .../client/methods/messages/send_animation.py | 7 +- .../client/methods/messages/send_audio.py | 7 +- .../methods/messages/send_cached_media.py | 7 +- .../client/methods/messages/send_document.py | 7 +- .../client/methods/messages/send_message.py | 7 +- .../client/methods/messages/send_photo.py | 7 +- .../client/methods/messages/send_video.py | 7 +- .../client/methods/messages/send_voice.py | 7 +- .../bots_and_keyboards/callback_query.py | 14 ++-- .../input_media/input_media_animation.py | 7 +- .../types/input_media/input_media_audio.py | 7 +- .../types/input_media/input_media_document.py | 7 +- .../types/input_media/input_media_photo.py | 7 +- .../types/input_media/input_media_video.py | 7 +- .../input_text_message_content.py | 7 +- .../types/messages_and_media/message.py | 70 +++++++++++++------ 20 files changed, 150 insertions(+), 60 deletions(-) diff --git a/pyrogram/client/methods/messages/edit_inline_caption.py b/pyrogram/client/methods/messages/edit_inline_caption.py index a9bbc551..aa5661dd 100644 --- a/pyrogram/client/methods/messages/edit_inline_caption.py +++ b/pyrogram/client/methods/messages/edit_inline_caption.py @@ -38,8 +38,11 @@ class EditInlineCaption(BaseClient): New caption of the media message. parse_mode (``str``, *optional*): - Pass "markdown" or "html" if you want Telegram apps to show bold, italic, fixed-width text or inline - URLs in your message. Defaults to "markdown". + By default, texts are parsed using both Markdown and HTML styles. + You can combine both syntaxes together. + Pass "markdown" to enable Markdown-style parsing only. + Pass "html" to enable HTML-style parsing only. + Pass None to completely disable style parsing. reply_markup (:obj:`InlineKeyboardMarkup`, *optional*): An InlineKeyboardMarkup object. diff --git a/pyrogram/client/methods/messages/edit_inline_text.py b/pyrogram/client/methods/messages/edit_inline_text.py index 349e3e35..3c153c3c 100644 --- a/pyrogram/client/methods/messages/edit_inline_text.py +++ b/pyrogram/client/methods/messages/edit_inline_text.py @@ -42,8 +42,11 @@ class EditInlineText(BaseClient): New text of the message. parse_mode (``str``, *optional*): - Pass "markdown" or "html" if you want Telegram apps to show bold, italic, fixed-width text or inline - URLs in your message. Defaults to "markdown". + By default, texts are parsed using both Markdown and HTML styles. + You can combine both syntaxes together. + Pass "markdown" to enable Markdown-style parsing only. + Pass "html" to enable HTML-style parsing only. + Pass None to completely disable style parsing. disable_web_page_preview (``bool``, *optional*): Disables link previews for links in this message. diff --git a/pyrogram/client/methods/messages/edit_message_caption.py b/pyrogram/client/methods/messages/edit_message_caption.py index 52c22726..3c2cd138 100644 --- a/pyrogram/client/methods/messages/edit_message_caption.py +++ b/pyrogram/client/methods/messages/edit_message_caption.py @@ -46,8 +46,11 @@ class EditMessageCaption(BaseClient): New caption of the media message. parse_mode (``str``, *optional*): - Pass "markdown" or "html" if you want Telegram apps to show bold, italic, fixed-width text or inline - URLs in your message. Defaults to "markdown". + By default, texts are parsed using both Markdown and HTML styles. + You can combine both syntaxes together. + Pass "markdown" to enable Markdown-style parsing only. + Pass "html" to enable HTML-style parsing only. + Pass None to completely disable style parsing. reply_markup (:obj:`InlineKeyboardMarkup`, *optional*): An InlineKeyboardMarkup object. diff --git a/pyrogram/client/methods/messages/edit_message_text.py b/pyrogram/client/methods/messages/edit_message_text.py index e30afdfc..9a7a1a09 100644 --- a/pyrogram/client/methods/messages/edit_message_text.py +++ b/pyrogram/client/methods/messages/edit_message_text.py @@ -48,8 +48,11 @@ class EditMessageText(BaseClient): New text of the message. parse_mode (``str``, *optional*): - Pass "markdown" or "html" if you want Telegram apps to show bold, italic, fixed-width text or inline - URLs in your message. Defaults to "markdown". + By default, texts are parsed using both Markdown and HTML styles. + You can combine both syntaxes together. + Pass "markdown" to enable Markdown-style parsing only. + Pass "html" to enable HTML-style parsing only. + Pass None to completely disable style parsing. disable_web_page_preview (``bool``, *optional*): Disables link previews for links in this message. diff --git a/pyrogram/client/methods/messages/send_animation.py b/pyrogram/client/methods/messages/send_animation.py index cff80af5..c0c57059 100644 --- a/pyrogram/client/methods/messages/send_animation.py +++ b/pyrogram/client/methods/messages/send_animation.py @@ -70,8 +70,11 @@ class SendAnimation(BaseClient): Pass True to automatically unsave the sent animation. Defaults to False. parse_mode (``str``, *optional*): - Pass "markdown" or "html" if you want Telegram apps to show bold, italic, fixed-width text or inline - URLs in your caption. Defaults to "markdown". + By default, texts are parsed using both Markdown and HTML styles. + You can combine both syntaxes together. + Pass "markdown" to enable Markdown-style parsing only. + Pass "html" to enable HTML-style parsing only. + Pass None to completely disable style parsing. duration (``int``, *optional*): Duration of sent animation in seconds. diff --git a/pyrogram/client/methods/messages/send_audio.py b/pyrogram/client/methods/messages/send_audio.py index 5cd9fc8d..7759a6e9 100644 --- a/pyrogram/client/methods/messages/send_audio.py +++ b/pyrogram/client/methods/messages/send_audio.py @@ -67,8 +67,11 @@ class SendAudio(BaseClient): Audio caption, 0-1024 characters. parse_mode (``str``, *optional*): - Pass "markdown" or "html" if you want Telegram apps to show bold, italic, fixed-width text or inline - URLs in your caption. Defaults to "markdown". + By default, texts are parsed using both Markdown and HTML styles. + You can combine both syntaxes together. + Pass "markdown" to enable Markdown-style parsing only. + Pass "html" to enable HTML-style parsing only. + Pass None to completely disable style parsing. duration (``int``, *optional*): Duration of the audio in seconds. diff --git a/pyrogram/client/methods/messages/send_cached_media.py b/pyrogram/client/methods/messages/send_cached_media.py index 1c5aad7b..6c947d96 100644 --- a/pyrogram/client/methods/messages/send_cached_media.py +++ b/pyrogram/client/methods/messages/send_cached_media.py @@ -59,8 +59,11 @@ class SendCachedMedia(BaseClient): Media caption, 0-1024 characters. parse_mode (``str``, *optional*): - Pass "markdown" or "html" if you want Telegram apps to show bold, italic, fixed-width text or inline - URLs in your caption. Defaults to "markdown". + By default, texts are parsed using both Markdown and HTML styles. + You can combine both syntaxes together. + Pass "markdown" to enable Markdown-style parsing only. + Pass "html" to enable HTML-style parsing only. + Pass None to completely disable style parsing. disable_notification (``bool``, *optional*): Sends the message silently. diff --git a/pyrogram/client/methods/messages/send_document.py b/pyrogram/client/methods/messages/send_document.py index 55ab53af..06132688 100644 --- a/pyrogram/client/methods/messages/send_document.py +++ b/pyrogram/client/methods/messages/send_document.py @@ -68,8 +68,11 @@ class SendDocument(BaseClient): Document caption, 0-1024 characters. parse_mode (``str``, *optional*): - Pass "markdown" or "html" if you want Telegram apps to show bold, italic, fixed-width text or inline - URLs in your caption. Defaults to "markdown". + By default, texts are parsed using both Markdown and HTML styles. + You can combine both syntaxes together. + Pass "markdown" to enable Markdown-style parsing only. + Pass "html" to enable HTML-style parsing only. + Pass None to completely disable style parsing. disable_notification (``bool``, *optional*): Sends the message silently. diff --git a/pyrogram/client/methods/messages/send_message.py b/pyrogram/client/methods/messages/send_message.py index 959cf9b9..67861f3f 100644 --- a/pyrogram/client/methods/messages/send_message.py +++ b/pyrogram/client/methods/messages/send_message.py @@ -51,8 +51,11 @@ class SendMessage(BaseClient): Text of the message to be sent. parse_mode (``str``, *optional*): - Pass "markdown" or "html" if you want Telegram apps to show bold, italic, fixed-width text or inline - URLs in your message. Defaults to "markdown". + By default, texts are parsed using both Markdown and HTML styles. + You can combine both syntaxes together. + Pass "markdown" to enable Markdown-style parsing only. + Pass "html" to enable HTML-style parsing only. + Pass None to completely disable style parsing. disable_web_page_preview (``bool``, *optional*): Disables link previews for links in this message. diff --git a/pyrogram/client/methods/messages/send_photo.py b/pyrogram/client/methods/messages/send_photo.py index 8ebb2761..93178f26 100644 --- a/pyrogram/client/methods/messages/send_photo.py +++ b/pyrogram/client/methods/messages/send_photo.py @@ -62,8 +62,11 @@ class SendPhoto(BaseClient): Photo caption, 0-1024 characters. parse_mode (``str``, *optional*): - Pass "markdown" or "html" if you want Telegram apps to show bold, italic, fixed-width text or inline - URLs in your caption. Defaults to "markdown". + By default, texts are parsed using both Markdown and HTML styles. + You can combine both syntaxes together. + Pass "markdown" to enable Markdown-style parsing only. + Pass "html" to enable HTML-style parsing only. + Pass None to completely disable style parsing. ttl_seconds (``int``, *optional*): Self-Destruct Timer. diff --git a/pyrogram/client/methods/messages/send_video.py b/pyrogram/client/methods/messages/send_video.py index 0785056d..feacf5c7 100644 --- a/pyrogram/client/methods/messages/send_video.py +++ b/pyrogram/client/methods/messages/send_video.py @@ -66,8 +66,11 @@ class SendVideo(BaseClient): Video caption, 0-1024 characters. parse_mode (``str``, *optional*): - Pass "markdown" or "html" if you want Telegram apps to show bold, italic, fixed-width text or inline - URLs in your caption. Defaults to "markdown". + By default, texts are parsed using both Markdown and HTML styles. + You can combine both syntaxes together. + Pass "markdown" to enable Markdown-style parsing only. + Pass "html" to enable HTML-style parsing only. + Pass None to completely disable style parsing. duration (``int``, *optional*): Duration of sent video in seconds. diff --git a/pyrogram/client/methods/messages/send_voice.py b/pyrogram/client/methods/messages/send_voice.py index 45dfa45b..ffed409e 100644 --- a/pyrogram/client/methods/messages/send_voice.py +++ b/pyrogram/client/methods/messages/send_voice.py @@ -62,8 +62,11 @@ class SendVoice(BaseClient): Voice message caption, 0-1024 characters. parse_mode (``str``, *optional*): - Pass "markdown" or "html" if you want Telegram apps to show bold, italic, fixed-width text or inline - URLs in your caption. Defaults to "markdown". + By default, texts are parsed using both Markdown and HTML styles. + You can combine both syntaxes together. + Pass "markdown" to enable Markdown-style parsing only. + Pass "html" to enable HTML-style parsing only. + Pass None to completely disable style parsing. duration (``int``, *optional*): Duration of the voice message in seconds. diff --git a/pyrogram/client/types/bots_and_keyboards/callback_query.py b/pyrogram/client/types/bots_and_keyboards/callback_query.py index 6a717489..f631db45 100644 --- a/pyrogram/client/types/bots_and_keyboards/callback_query.py +++ b/pyrogram/client/types/bots_and_keyboards/callback_query.py @@ -189,8 +189,11 @@ class CallbackQuery(Object, Update): New text of the message. parse_mode (``str``, *optional*): - Pass "markdown" or "html" if you want Telegram apps to show bold, italic, fixed-width text or inline - URLs in your message. Defaults to "markdown". + By default, texts are parsed using both Markdown and HTML styles. + You can combine both syntaxes together. + Pass "markdown" to enable Markdown-style parsing only. + Pass "html" to enable HTML-style parsing only. + Pass None to completely disable style parsing. disable_web_page_preview (``bool``, *optional*): Disables link previews for links in this message. @@ -238,8 +241,11 @@ class CallbackQuery(Object, Update): New caption of the message. parse_mode (``str``, *optional*): - Pass "markdown" or "html" if you want Telegram apps to show bold, italic, fixed-width text or inline - URLs in your message. Defaults to "markdown". + By default, texts are parsed using both Markdown and HTML styles. + You can combine both syntaxes together. + Pass "markdown" to enable Markdown-style parsing only. + Pass "html" to enable HTML-style parsing only. + Pass None to completely disable style parsing. reply_markup (:obj:`InlineKeyboardMarkup`, *optional*): An InlineKeyboardMarkup object. diff --git a/pyrogram/client/types/input_media/input_media_animation.py b/pyrogram/client/types/input_media/input_media_animation.py index 23fcb967..e5b8edb4 100644 --- a/pyrogram/client/types/input_media/input_media_animation.py +++ b/pyrogram/client/types/input_media/input_media_animation.py @@ -38,8 +38,11 @@ class InputMediaAnimation(InputMedia): Caption of the animation to be sent, 0-1024 characters parse_mode (``str``, *optional*): - Pass "markdown" or "html" if you want Telegram apps to show bold, italic, fixed-width text or inline URLs - in your caption. Defaults to "markdown". + By default, texts are parsed using both Markdown and HTML styles. + You can combine both syntaxes together. + Pass "markdown" to enable Markdown-style parsing only. + Pass "html" to enable HTML-style parsing only. + Pass None to completely disable style parsing. width (``int``, *optional*): Animation width. diff --git a/pyrogram/client/types/input_media/input_media_audio.py b/pyrogram/client/types/input_media/input_media_audio.py index 3fb45d8f..02299a12 100644 --- a/pyrogram/client/types/input_media/input_media_audio.py +++ b/pyrogram/client/types/input_media/input_media_audio.py @@ -40,8 +40,11 @@ class InputMediaAudio(InputMedia): Caption of the audio to be sent, 0-1024 characters parse_mode (``str``, *optional*): - Pass "markdown" or "html" if you want Telegram apps to show bold, italic, fixed-width text or inline URLs - in your caption. Defaults to "markdown". + By default, texts are parsed using both Markdown and HTML styles. + You can combine both syntaxes together. + Pass "markdown" to enable Markdown-style parsing only. + Pass "html" to enable HTML-style parsing only. + Pass None to completely disable style parsing. duration (``int``, *optional*): Duration of the audio in seconds diff --git a/pyrogram/client/types/input_media/input_media_document.py b/pyrogram/client/types/input_media/input_media_document.py index 0de8dedf..46a5b446 100644 --- a/pyrogram/client/types/input_media/input_media_document.py +++ b/pyrogram/client/types/input_media/input_media_document.py @@ -38,8 +38,11 @@ class InputMediaDocument(InputMedia): Caption of the document to be sent, 0-1024 characters parse_mode (``str``, *optional*): - Pass "markdown" or "html" if you want Telegram apps to show bold, italic, fixed-width text or inline URLs - in your caption. Defaults to "markdown". + By default, texts are parsed using both Markdown and HTML styles. + You can combine both syntaxes together. + Pass "markdown" to enable Markdown-style parsing only. + Pass "html" to enable HTML-style parsing only. + Pass None to completely disable style parsing. """ __slots__ = ["thumb"] diff --git a/pyrogram/client/types/input_media/input_media_photo.py b/pyrogram/client/types/input_media/input_media_photo.py index ce134af2..064065e3 100644 --- a/pyrogram/client/types/input_media/input_media_photo.py +++ b/pyrogram/client/types/input_media/input_media_photo.py @@ -34,8 +34,11 @@ class InputMediaPhoto(InputMedia): Caption of the photo to be sent, 0-1024 characters parse_mode (``str``, *optional*): - Pass "markdown" or "html" if you want Telegram apps to show bold, italic, fixed-width text or inline URLs - in your caption. Defaults to "markdown". + By default, texts are parsed using both Markdown and HTML styles. + You can combine both syntaxes together. + Pass "markdown" to enable Markdown-style parsing only. + Pass "html" to enable HTML-style parsing only. + Pass None to completely disable style parsing. """ __slots__ = [] diff --git a/pyrogram/client/types/input_media/input_media_video.py b/pyrogram/client/types/input_media/input_media_video.py index 9764dd1a..4584ffbe 100644 --- a/pyrogram/client/types/input_media/input_media_video.py +++ b/pyrogram/client/types/input_media/input_media_video.py @@ -40,8 +40,11 @@ class InputMediaVideo(InputMedia): Caption of the video to be sent, 0-1024 characters parse_mode (``str``, *optional*): - Pass "markdown" or "html" if you want Telegram apps to show bold, italic, fixed-width text or inline URLs - in your caption. Defaults to "markdown". + By default, texts are parsed using both Markdown and HTML styles. + You can combine both syntaxes together. + Pass "markdown" to enable Markdown-style parsing only. + Pass "html" to enable HTML-style parsing only. + Pass None to completely disable style parsing. width (``int``, *optional*): Video width. diff --git a/pyrogram/client/types/input_message_content/input_text_message_content.py b/pyrogram/client/types/input_message_content/input_text_message_content.py index 7db2069d..f1c24631 100644 --- a/pyrogram/client/types/input_message_content/input_text_message_content.py +++ b/pyrogram/client/types/input_message_content/input_text_message_content.py @@ -31,8 +31,11 @@ class InputTextMessageContent(InputMessageContent): Text of the message to be sent, 1-4096 characters. parse_mode (``str``, *optional*): - Pass "markdown" or "html" if you want Telegram apps to show bold, italic, fixed-width text or inline URLs - in your message. Defaults to "markdown". + By default, texts are parsed using both Markdown and HTML styles. + You can combine both syntaxes together. + Pass "markdown" to enable Markdown-style parsing only. + Pass "html" to enable HTML-style parsing only. + Pass None to completely disable style parsing. disable_web_page_preview (``bool``, *optional*): Disables link previews for links in this message. diff --git a/pyrogram/client/types/messages_and_media/message.py b/pyrogram/client/types/messages_and_media/message.py index 549d6f09..39fd24fa 100644 --- a/pyrogram/client/types/messages_and_media/message.py +++ b/pyrogram/client/types/messages_and_media/message.py @@ -686,8 +686,11 @@ class Message(Object, Update): Defaults to ``True`` in group chats and ``False`` in private chats. parse_mode (``str``, *optional*): - Pass "markdown" or "html" if you want Telegram apps to show bold, italic, fixed-width text or inline - URLs in your message. Defaults to "markdown". + By default, texts are parsed using both Markdown and HTML styles. + You can combine both syntaxes together. + Pass "markdown" to enable Markdown-style parsing only. + Pass "html" to enable HTML-style parsing only. + Pass None to completely disable style parsing. disable_web_page_preview (``bool``, *optional*): Disables link previews for links in this message. @@ -780,8 +783,11 @@ class Message(Object, Update): Animation caption, 0-1024 characters. parse_mode (``str``, *optional*): - Pass "markdown" or "html" if you want Telegram apps to show bold, italic, fixed-width text or inline - URLs in your caption. Defaults to "markdown". + By default, texts are parsed using both Markdown and HTML styles. + You can combine both syntaxes together. + Pass "markdown" to enable Markdown-style parsing only. + Pass "html" to enable HTML-style parsing only. + Pass None to completely disable style parsing. duration (``int``, *optional*): Duration of sent animation in seconds. @@ -914,8 +920,11 @@ class Message(Object, Update): Audio caption, 0-1024 characters. parse_mode (``str``, *optional*): - Pass "markdown" or "html" if you want Telegram apps to show bold, italic, fixed-width text or inline - URLs in your caption. Defaults to "markdown". + By default, texts are parsed using both Markdown and HTML styles. + You can combine both syntaxes together. + Pass "markdown" to enable Markdown-style parsing only. + Pass "html" to enable HTML-style parsing only. + Pass None to completely disable style parsing. duration (``int``, *optional*): Duration of the audio in seconds. @@ -1040,8 +1049,11 @@ class Message(Object, Update): Media caption, 0-1024 characters. parse_mode (``str``, *optional*): - Pass "markdown" or "html" if you want Telegram apps to show bold, italic, fixed-width text or inline - URLs in your caption. Defaults to "markdown". + By default, texts are parsed using both Markdown and HTML styles. + You can combine both syntaxes together. + Pass "markdown" to enable Markdown-style parsing only. + Pass "html" to enable HTML-style parsing only. + Pass None to completely disable style parsing. disable_notification (``bool``, *optional*): Sends the message silently. @@ -1255,8 +1267,11 @@ class Message(Object, Update): Document caption, 0-1024 characters. parse_mode (``str``, *optional*): - Pass "markdown" or "html" if you want Telegram apps to show bold, italic, fixed-width text or inline - URLs in your caption. Defaults to "markdown". + By default, texts are parsed using both Markdown and HTML styles. + You can combine both syntaxes together. + Pass "markdown" to enable Markdown-style parsing only. + Pass "html" to enable HTML-style parsing only. + Pass None to completely disable style parsing. disable_notification (``bool``, *optional*): Sends the message silently. @@ -1642,8 +1657,11 @@ class Message(Object, Update): Photo caption, 0-1024 characters. parse_mode (``str``, *optional*): - Pass "markdown" or "html" if you want Telegram apps to show bold, italic, fixed-width text or inline - URLs in your caption. Defaults to "markdown". + By default, texts are parsed using both Markdown and HTML styles. + You can combine both syntaxes together. + Pass "markdown" to enable Markdown-style parsing only. + Pass "html" to enable HTML-style parsing only. + Pass None to completely disable style parsing. ttl_seconds (``int``, *optional*): Self-Destruct Timer. @@ -2037,8 +2055,11 @@ class Message(Object, Update): Video caption, 0-1024 characters. parse_mode (``str``, *optional*): - Pass "markdown" or "html" if you want Telegram apps to show bold, italic, fixed-width text or inline - URLs in your caption. Defaults to "markdown". + By default, texts are parsed using both Markdown and HTML styles. + You can combine both syntaxes together. + Pass "markdown" to enable Markdown-style parsing only. + Pass "html" to enable HTML-style parsing only. + Pass None to completely disable style parsing. duration (``int``, *optional*): Duration of sent video in seconds. @@ -2290,8 +2311,11 @@ class Message(Object, Update): Voice message caption, 0-1024 characters. parse_mode (``str``, *optional*): - Pass "markdown" or "html" if you want Telegram apps to show bold, italic, fixed-width text or inline - URLs in your caption. Defaults to "markdown". + By default, texts are parsed using both Markdown and HTML styles. + You can combine both syntaxes together. + Pass "markdown" to enable Markdown-style parsing only. + Pass "html" to enable HTML-style parsing only. + Pass None to completely disable style parsing. duration (``int``, *optional*): Duration of the voice message in seconds. @@ -2385,8 +2409,11 @@ class Message(Object, Update): New text of the message. parse_mode (``str``, *optional*): - Pass "markdown" or "html" if you want Telegram apps to show bold, italic, fixed-width text or inline - URLs in your message. Defaults to "markdown". + By default, texts are parsed using both Markdown and HTML styles. + You can combine both syntaxes together. + Pass "markdown" to enable Markdown-style parsing only. + Pass "html" to enable HTML-style parsing only. + Pass None to completely disable style parsing. disable_web_page_preview (``bool``, *optional*): Disables link previews for links in this message. @@ -2439,8 +2466,11 @@ class Message(Object, Update): New caption of the message. parse_mode (``str``, *optional*): - Pass "markdown" or "html" if you want Telegram apps to show bold, italic, fixed-width text or inline - URLs in your message. Defaults to "markdown". + By default, texts are parsed using both Markdown and HTML styles. + You can combine both syntaxes together. + Pass "markdown" to enable Markdown-style parsing only. + Pass "html" to enable HTML-style parsing only. + Pass None to completely disable style parsing. reply_markup (:obj:`InlineKeyboardMarkup`, *optional*): An InlineKeyboardMarkup object.