Queer European MD passionate about IT
Explorar el Código

Merge branch 'develop' of ssh://davte.it:8445/Davte/davtelepot into develop

Davte hace 5 años
padre
commit
7f7ba35276
Se han modificado 1 ficheros con 3 adiciones y 1 borrados
  1. 3 1
      davtelepot/bot.py

+ 3 - 1
davtelepot/bot.py

@@ -1752,8 +1752,10 @@ class Bot(TelegramBot, ObjectWithDatabase, MultiLanguageObject):
             mode='raw'
         )
         path = path or self.path
-        if file_name is None:
+        while file_name is None:
             file_name = get_secure_key(length=10)
+            if os.path.exists(f"{path}/{file_name}"):
+                file_name = None
         try:
             with open(f"{path}/{file_name}", 'wb') as local_file:
                 local_file.write(file_bytes)