send_document method should not require a chat_id since it can be passed an update object

This commit is contained in:
Davte 2020-12-20 20:30:49 +01:00
parent e487764aad
commit d77c416ea6
Signed by: Davte
GPG Key ID: 209AE674A0007425
2 changed files with 5 additions and 2 deletions

View File

@ -11,7 +11,7 @@ __author__ = "Davide Testa"
__email__ = "davide@davte.it" __email__ = "davide@davte.it"
__credits__ = ["Marco Origlia", "Nick Lee @Nickoala"] __credits__ = ["Marco Origlia", "Nick Lee @Nickoala"]
__license__ = "GNU General Public License v3.0" __license__ = "GNU General Public License v3.0"
__version__ = "2.7.5" __version__ = "2.7.6"
__maintainer__ = "Davide Testa" __maintainer__ = "Davide Testa"
__contact__ = "t.me/davte" __contact__ = "t.me/davte"

View File

@ -1896,7 +1896,7 @@ class Bot(TelegramBot, ObjectWithDatabase, MultiLanguageObject):
) )
return sent_update return sent_update
async def send_document(self, chat_id: Union[int, str], document=None, async def send_document(self, chat_id: Union[int, str] = None, document=None,
thumb=None, thumb=None,
caption: str = None, caption: str = None,
parse_mode: str = None, parse_mode: str = None,
@ -1937,6 +1937,9 @@ class Bot(TelegramBot, ObjectWithDatabase, MultiLanguageObject):
update = update['message'] update = update['message']
if chat_id is None and 'chat' in update: if chat_id is None and 'chat' in update:
chat_id = self.get_chat_id(update) chat_id = self.get_chat_id(update)
if chat_id is None:
logging.error("Attempt to send document without providing a chat_id")
return
if reply_to_update and 'message_id' in update: if reply_to_update and 'message_id' in update:
reply_to_message_id = update['message_id'] reply_to_message_id = update['message_id']
if chat_id > 0: if chat_id > 0: