log send exception

This commit is contained in:
bakatrouble 2023-03-22 19:28:33 +03:00
parent c30cf4b950
commit 547132d5d6

31
main.py
View File

@ -5,7 +5,7 @@ import os
import redis.asyncio as aioredis
from aiogram import Bot, Dispatcher
from aiogram.types import Message
from aiogram.utils import executor
from aiogram.utils import executor, exceptions
import dotenv
from e621 import E621
@ -38,19 +38,22 @@ async def check_updates():
f'Character: {" ".join(post.tags.character)}\n\n' \
f'https://e621.net/posts/{post.id}'
if post.file.url:
logging.warning(post.file.url)
if post.file.ext == 'webm':
await bot.send_video(int(os.environ['SEND_CHAT']),
post.file.url,
width=post.file.width,
height=post.file.height,
thumb=post.preview.url,
caption=caption)
else:
await bot.send_photo(int(os.environ['SEND_CHAT']),
post.file.url,
caption=caption)
await redis.sadd('e621:sent', post.id)
try:
logging.warning(post.file.url)
if post.file.ext == 'webm':
await bot.send_video(int(os.environ['SEND_CHAT']),
post.file.url,
width=post.file.width,
height=post.file.height,
thumb=post.preview.url,
caption=caption)
else:
await bot.send_photo(int(os.environ['SEND_CHAT']),
post.file.url,
caption=caption)
await redis.sadd('e621:sent', post.id)
except exceptions.TelegramAPIError as e:
logging.exception(e)
@dp.message_handler(commands=['add'])