From 421bd7c9e3b1c49f7e2b205682379fb4f183eb7a Mon Sep 17 00:00:00 2001 From: Sergey Date: Sun, 4 Oct 2020 17:53:15 +0300 Subject: [PATCH] Fixes --- set_env.py | 1 + telegram.py | 10 ++++++++-- 2 files changed, 9 insertions(+), 2 deletions(-) diff --git a/set_env.py b/set_env.py index 9838197..9c2a1e2 100644 --- a/set_env.py +++ b/set_env.py @@ -5,6 +5,7 @@ from urllib.parse import urlencode ENV_FILE_TEMPLATE = """ POSTGRES_DB=tgvkbot +POSTGRES_PASSWORD=postgres BOT_TOKEN=%(tg_token)s VK_APP_ID=%(vk_app_id)s """ diff --git a/telegram.py b/telegram.py index eee5cb5..973a0ea 100644 --- a/telegram.py +++ b/telegram.py @@ -192,7 +192,10 @@ async def upload_attachment(msg, vk_user, file_id, peer_id, attachment_type, upl file_on_server = ujson.loads(await upload.text()) if msg.content_type != 'sticker': content['content'].close() - os.remove(os.path.join(content['temp_path'], content['file_name'] + content['custom_ext'])) + try: + os.remove(os.path.join(content['temp_path'], content['file_name'] + content['custom_ext'])) + except: + pass if attachment_type == 'photo': save_options = {'server': file_on_server['server'], on_server_field: file_on_server[on_server_field], 'hash': file_on_server['hash']} @@ -452,7 +455,10 @@ async def set_info(call: types.CallbackQuery): content = await get_content(dialog_info['photo']) await bot.set_chat_photo(call.message.chat.id, content['content']) content['content'].close() - os.remove(os.path.join(content['temp_path'], content['file_name'] + content['custom_ext'])) + try: + os.remove(os.path.join(content['temp_path'], content['file_name'] + content['custom_ext'])) + except: + pass if dialog_info['type'] == 'user': dialog_info = await get_dialog_info(api, vk_chat_id, name_case='ins')