mirror of
https://github.com/python-telegram-bot/python-telegram-bot.git
synced 2025-01-10 20:12:52 +01:00
added parse_mode parameter in Updater and in Bot class to set a default parse mode for bot
This commit is contained in:
parent
c714a177d1
commit
446f238dd6
3 changed files with 14 additions and 4 deletions
|
@ -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'
|
||||
|
@ -256,6 +260,8 @@ class Bot(TelegramObject):
|
|||
|
||||
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
|
||||
|
||||
|
|
|
@ -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.
|
||||
|
@ -97,7 +100,8 @@ class Updater(object):
|
|||
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')
|
||||
|
@ -129,7 +133,7 @@ class Updater(object):
|
|||
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)
|
||||
|
|
2
telegram/vendor/ptb_urllib3
vendored
2
telegram/vendor/ptb_urllib3
vendored
|
@ -1 +1 @@
|
|||
Subproject commit d2403a79fc38afbdd9aba8a05d274a83dc8bb412
|
||||
Subproject commit 2c6446aa6cfeedd5968977fe5f5afae706566c2d
|
Loading…
Reference in a new issue