Skip to content

Added parse_mode parameter in Updater and in Bot class #1226

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Closed
wants to merge 1 commit into from
Closed
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
8 changes: 7 additions & 1 deletion telegram/bot.py
Original file line number Diff line number Diff line change
Expand Up @@ -108,12 +108,16 @@ class Bot(TelegramObject):
:obj:`telegram.utils.request.Request`.
private_key (:obj:`bytes`, optional): Private key for decryption of telegram passport data.
private_key_password (:obj:`bytes`, optional): Password for above private key.
parse_mode (:obj:`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. See the
constants in :class:`telegram.ParseMode` for the available modes.

"""

def __init__(self, token, base_url=None, base_file_url=None, request=None, private_key=None,
private_key_password=None):
private_key_password=None, parse_mode=None):
self.token = self._validate_token(token)
self.parse_mode = parse_mode

if base_url is None:
base_url = 'https://api.telegram.org/bot'
Expand Down Expand Up @@ -256,6 +260,8 @@ def send_message(self,

if parse_mode:
data['parse_mode'] = parse_mode
elif self.parse_mode:
data['parse_mode'] = self.parse_mode
if disable_web_page_preview:
data['disable_web_page_preview'] = disable_web_page_preview

Expand Down
8 changes: 6 additions & 2 deletions telegram/ext/updater.py
Original file line number Diff line number Diff line change
Expand Up @@ -77,6 +77,9 @@ class Updater(object):
default timeouts and/or control the proxy used for http communication.
persistence (:class:`telegram.ext.BasePersistence`, optional): The persistence class to
store data that should be persistent over restarts.
parse_mode (:obj:`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. See the
constants in :class:`telegram.ParseMode` for the available modes.

Note:
You must supply either a :attr:`bot` or a :attr:`token` argument.
Expand All @@ -97,7 +100,8 @@ def __init__(self,
private_key_password=None,
user_sig_handler=None,
request_kwargs=None,
persistence=None):
persistence=None,
parse_mode=None):

if (token is None) and (bot is None):
raise ValueError('`token` or `bot` must be passed')
Expand Down Expand Up @@ -129,7 +133,7 @@ def __init__(self,
request_kwargs['con_pool_size'] = con_pool_size
self._request = Request(**request_kwargs)
self.bot = Bot(token, base_url, request=self._request, private_key=private_key,
private_key_password=private_key_password)
private_key_password=private_key_password, parse_mode=parse_mode)
self.user_sig_handler = user_sig_handler
self.update_queue = Queue()
self.job_queue = JobQueue(self.bot)
Expand Down
2 changes: 1 addition & 1 deletion telegram/vendor/ptb_urllib3