From d6c0e614568ca62ff7e3dc88a13ec50e763395d0 Mon Sep 17 00:00:00 2001 From: Dan <14043624+delivrance@users.noreply.github.com> Date: Mon, 15 Oct 2018 14:24:33 +0200 Subject: [PATCH] Add InputTextMessageContent type --- pyrogram/client/types/input_media/__init__.py | 1 + .../input_media/input_text_message_content.py | 35 +++++++++++++++++++ 2 files changed, 36 insertions(+) create mode 100644 pyrogram/client/types/input_media/input_text_message_content.py diff --git a/pyrogram/client/types/input_media/__init__.py b/pyrogram/client/types/input_media/__init__.py index 5f5be30d..3a8f9b16 100644 --- a/pyrogram/client/types/input_media/__init__.py +++ b/pyrogram/client/types/input_media/__init__.py @@ -23,3 +23,4 @@ from .input_media_document import InputMediaDocument from .input_media_photo import InputMediaPhoto from .input_media_video import InputMediaVideo from .input_phone_contact import InputPhoneContact +from .input_text_message_content import InputTextMessageContent diff --git a/pyrogram/client/types/input_media/input_text_message_content.py b/pyrogram/client/types/input_media/input_text_message_content.py new file mode 100644 index 00000000..b6c3435f --- /dev/null +++ b/pyrogram/client/types/input_media/input_text_message_content.py @@ -0,0 +1,35 @@ +# 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 + + +class InputTextMessageContent: + def __init__(self, message_text: str, parse_mode: str = "", disable_web_page_preview: bool = None): + self.message_text = message_text + self.parse_mode = parse_mode + self.disable_web_page_preview = disable_web_page_preview + + self.style = HTML() if parse_mode.lower() == "html" else Markdown() + + def write(self): + return types.InputBotInlineMessageText( + no_webpage=self.disable_web_page_preview or None, + **self.style.parse(self.message_text) + )