diff --git a/pyrogram/__init__.py b/pyrogram/__init__.py index d6005bd8..a290ca0f 100644 --- a/pyrogram/__init__.py +++ b/pyrogram/__init__.py @@ -23,3 +23,4 @@ __version__ = "0.4.2" from .api.errors import Error from .client import ChatAction from .client import Client +from .client import ParseMode diff --git a/pyrogram/client/__init__.py b/pyrogram/client/__init__.py index 99c4337f..380f0cb4 100644 --- a/pyrogram/client/__init__.py +++ b/pyrogram/client/__init__.py @@ -18,3 +18,4 @@ from .chat_action import ChatAction from .client import Client +from .parse_mode import ParseMode diff --git a/pyrogram/client/client.py b/pyrogram/client/client.py index 8aa8dd64..860b18d1 100644 --- a/pyrogram/client/client.py +++ b/pyrogram/client/client.py @@ -488,8 +488,9 @@ class Client: Text of the message to be sent. parse_mode (:obj:`str`): - Use "Markdown" or "HTML" if you want Telegram apps to show bold, italic, fixed-width text or - inline URLs in your message. Defaults to "Markdown". + Use :obj:`pyrogram.ParseMode.MARKDOWN` or :obj:`pyrogram.ParseMode.HTML` if you want Telegram apps + to show bold, italic, fixed-width text or inline URLs in your message. + Defaults to MARKDOWN. disable_web_page_preview (:obj:`bool`, optional): Disables link previews for links in this message. @@ -585,8 +586,9 @@ class Client: Photo caption, 0-200 characters. parse_mode (:obj:`str`): - Use "Markdown" or "HTML" if you want Telegram apps to show bold, italic, fixed-width text or - inline URLs in your caption. Defaults to "Markdown". + Use :obj:`pyrogram.ParseMode.MARKDOWN` or :obj:`pyrogram.ParseMode.HTML` if you want Telegram apps + to show bold, italic, fixed-width text or inline URLs in your caption. + Defaults to MARKDOWN. ttl_seconds (:obj:`int`, optional): Self-Destruct Timer. @@ -657,8 +659,9 @@ class Client: Audio caption, 0-200 characters. parse_mode (:obj:`str`): - Use "Markdown" or "HTML" if you want Telegram apps to show bold, italic, fixed-width text or - inline URLs in your caption. Defaults to "Markdown". + Use :obj:`pyrogram.ParseMode.MARKDOWN` or :obj:`pyrogram.ParseMode.HTML` if you want Telegram apps + to show bold, italic, fixed-width text or inline URLs in your caption. + Defaults to MARKDOWN. duration (:obj:`int`, optional): Duration of the audio in seconds. @@ -736,8 +739,9 @@ class Client: Document caption, 0-200 characters. parse_mode (:obj:`str`): - Use "Markdown" or "HTML" if you want Telegram apps to show bold, italic, fixed-width text or - inline URLs in your caption. Defaults to "Markdown". + Use :obj:`pyrogram.ParseMode.MARKDOWN` or :obj:`pyrogram.ParseMode.HTML` if you want Telegram apps + to show bold, italic, fixed-width text or inline URLs in your caption. + Defaults to MARKDOWN. disable_notification (:obj:`bool`, optional): Sends the message silently. @@ -804,8 +808,9 @@ class Client: Video caption, 0-200 characters. parse_mode (:obj:`str`): - Use "Markdown" or "HTML" if you want Telegram apps to show bold, italic, fixed-width text or - inline URLs in your caption. Defaults to "Markdown". + Use :obj:`pyrogram.ParseMode.MARKDOWN` or :obj:`pyrogram.ParseMode.HTML` if you want Telegram apps + to show bold, italic, fixed-width text or inline URLs in your caption. + Defaults to MARKDOWN. duration (:obj:`int`, optional): Duration of sent video in seconds. @@ -883,8 +888,9 @@ class Client: Voice message caption, 0-200 characters. parse_mode (:obj:`str`): - Use "Markdown" or "HTML" if you want Telegram apps to show bold, italic, fixed-width text or - inline URLs in your caption. Defaults to "Markdown". + Use :obj:`pyrogram.ParseMode.MARKDOWN` or :obj:`pyrogram.ParseMode.HTML` if you want Telegram apps + to show bold, italic, fixed-width text or inline URLs in your caption. + Defaults to MARKDOWN. duration (:obj:`int`, optional): Duration of the voice message in seconds. @@ -1247,8 +1253,9 @@ class Client: New text of the message. parse_mode (:obj:`str`): - Use "Markdown" or "HTML" if you want Telegram apps to show bold, italic, fixed-width text or - inline URLs in your message. Defaults to "Markdown". + Use :obj:`pyrogram.ParseMode.MARKDOWN` or :obj:`pyrogram.ParseMode.HTML` if you want Telegram apps + to show bold, italic, fixed-width text or inline URLs in your message. + Defaults to MARKDOWN. disable_web_page_preview (:obj:`bool`, optional): Disables link previews for links in this message. @@ -1287,8 +1294,9 @@ class Client: New caption of the message. parse_mode (:obj:`str`): - Use "Markdown" or "HTML" if you want Telegram apps to show bold, italic, fixed-width text or - inline URLs in your caption. Defaults to "Markdown". + Use :obj:`pyrogram.ParseMode.MARKDOWN` or :obj:`pyrogram.ParseMode.HTML` if you want Telegram apps + to show bold, italic, fixed-width text or inline URLs in your caption. + Defaults to MARKDOWN. Raises: :class:`pyrogram.Error` diff --git a/pyrogram/client/parse_mode.py b/pyrogram/client/parse_mode.py new file mode 100644 index 00000000..668bb9c8 --- /dev/null +++ b/pyrogram/client/parse_mode.py @@ -0,0 +1,29 @@ +# 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 . + + +class ParseMode: + """This class provides a convenient access to parse modes. + It is intended to be used with any method that accepts the optional argument **parse_mode** + """ + + HTML = "html" + """Set the parse mode to HTML style""" + + MARKDOWN = "markdown" + """Set the parse mode to Markdown style"""