From 7a524989391939cb99faa0d277c2ff6ba8dd4e73 Mon Sep 17 00:00:00 2001 From: Davte Date: Wed, 28 Nov 2018 19:07:01 +0100 Subject: [PATCH] Allow auto-naming of pictures --- davtelepot/__init__.py | 2 +- davtelepot/custombot.py | 4 +++- 2 files changed, 4 insertions(+), 2 deletions(-) diff --git a/davtelepot/__init__.py b/davtelepot/__init__.py index 6478280..c9feb86 100644 --- a/davtelepot/__init__.py +++ b/davtelepot/__init__.py @@ -7,7 +7,7 @@ __author__ = "Davide Testa" __email__ = "davte@libero.it" __credits__ = "Marco Origlia" __license__ = "GNU General Public License v3.0" -__version__ = "1.4.20" +__version__ = "1.4.21" __maintainer__ = "Davide Testa" __contact__ = "t.me/davte" diff --git a/davtelepot/custombot.py b/davtelepot/custombot.py index 541b1f4..92c4a33 100644 --- a/davtelepot/custombot.py +++ b/davtelepot/custombot.py @@ -1740,7 +1740,7 @@ class Bot(telepot.aio.Bot, Gettable): self.to_be_obscured.remove(inline_message_id) return - async def save_picture(self, update, file_name, path='img/', + async def save_picture(self, update, file_name=None, path='img/', extension='jpg'): """Store `update` picture as `path`/`file_name`.`extension`.""" if not path.endswith('/'): @@ -1751,6 +1751,8 @@ class Bot(telepot.aio.Bot, Gettable): path = '{path}/img/'.format( path=self.path ) + if file_name is None: + file_name = get_secure_key(length=6) if file_name.endswith('.'): file_name = file_name[:-1] complete_file_name = '{path}{name}.{ext}'.format(