Queer European MD passionate about IT
Browse Source

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

Davte 3 years ago
parent
commit
d77c416ea6
2 changed files with 5 additions and 2 deletions
  1. 1 1
      davtelepot/__init__.py
  2. 4 1
      davtelepot/bot.py

+ 1 - 1
davtelepot/__init__.py

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

+ 4 - 1
davtelepot/bot.py

@@ -1896,7 +1896,7 @@ class Bot(TelegramBot, ObjectWithDatabase, MultiLanguageObject):
                 )
         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,
                             caption: str = None,
                             parse_mode: str = None,
@@ -1937,6 +1937,9 @@ class Bot(TelegramBot, ObjectWithDatabase, MultiLanguageObject):
             update = update['message']
         if chat_id is None and 'chat' in 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:
             reply_to_message_id = update['message_id']
         if chat_id > 0: