make robot filenames unique

This commit is contained in:
bakatrouble 2021-03-17 12:55:54 +03:00
parent 4806bf8fe0
commit 178310d844

View File

@ -1,5 +1,6 @@
import logging
import os
import time
from tempfile import TemporaryDirectory
import boto3
@ -42,7 +43,7 @@ class RobotBotModuleConfig(TelegramBotModuleConfig):
return
file = ctx.bot.get_file(file_id)
filename = os.path.basename(file.file_path)
filename = str(int(time.time())) + '-' + os.path.basename(file.file_path)
with TemporaryDirectory() as d:
file_path = os.path.join(d, filename)
file.download(file_path)