Allow auto-naming of pictures

This commit is contained in:
Davte 2018-11-28 19:07:01 +01:00
parent 11b319d0a5
commit 7a52498939
2 changed files with 4 additions and 2 deletions

View File

@ -7,7 +7,7 @@ __author__ = "Davide Testa"
__email__ = "davte@libero.it" __email__ = "davte@libero.it"
__credits__ = "Marco Origlia" __credits__ = "Marco Origlia"
__license__ = "GNU General Public License v3.0" __license__ = "GNU General Public License v3.0"
__version__ = "1.4.20" __version__ = "1.4.21"
__maintainer__ = "Davide Testa" __maintainer__ = "Davide Testa"
__contact__ = "t.me/davte" __contact__ = "t.me/davte"

View File

@ -1740,7 +1740,7 @@ class Bot(telepot.aio.Bot, Gettable):
self.to_be_obscured.remove(inline_message_id) self.to_be_obscured.remove(inline_message_id)
return return
async def save_picture(self, update, file_name, path='img/', async def save_picture(self, update, file_name=None, path='img/',
extension='jpg'): extension='jpg'):
"""Store `update` picture as `path`/`file_name`.`extension`.""" """Store `update` picture as `path`/`file_name`.`extension`."""
if not path.endswith('/'): if not path.endswith('/'):
@ -1751,6 +1751,8 @@ class Bot(telepot.aio.Bot, Gettable):
path = '{path}/img/'.format( path = '{path}/img/'.format(
path=self.path path=self.path
) )
if file_name is None:
file_name = get_secure_key(length=6)
if file_name.endswith('.'): if file_name.endswith('.'):
file_name = file_name[:-1] file_name = file_name[:-1]
complete_file_name = '{path}{name}.{ext}'.format( complete_file_name = '{path}{name}.{ext}'.format(