log send exception
This commit is contained in:
parent
c30cf4b950
commit
547132d5d6
31
main.py
31
main.py
@ -5,7 +5,7 @@ import os
|
|||||||
import redis.asyncio as aioredis
|
import redis.asyncio as aioredis
|
||||||
from aiogram import Bot, Dispatcher
|
from aiogram import Bot, Dispatcher
|
||||||
from aiogram.types import Message
|
from aiogram.types import Message
|
||||||
from aiogram.utils import executor
|
from aiogram.utils import executor, exceptions
|
||||||
import dotenv
|
import dotenv
|
||||||
|
|
||||||
from e621 import E621
|
from e621 import E621
|
||||||
@ -38,19 +38,22 @@ async def check_updates():
|
|||||||
f'Character: {" ".join(post.tags.character)}\n\n' \
|
f'Character: {" ".join(post.tags.character)}\n\n' \
|
||||||
f'https://e621.net/posts/{post.id}'
|
f'https://e621.net/posts/{post.id}'
|
||||||
if post.file.url:
|
if post.file.url:
|
||||||
logging.warning(post.file.url)
|
try:
|
||||||
if post.file.ext == 'webm':
|
logging.warning(post.file.url)
|
||||||
await bot.send_video(int(os.environ['SEND_CHAT']),
|
if post.file.ext == 'webm':
|
||||||
post.file.url,
|
await bot.send_video(int(os.environ['SEND_CHAT']),
|
||||||
width=post.file.width,
|
post.file.url,
|
||||||
height=post.file.height,
|
width=post.file.width,
|
||||||
thumb=post.preview.url,
|
height=post.file.height,
|
||||||
caption=caption)
|
thumb=post.preview.url,
|
||||||
else:
|
caption=caption)
|
||||||
await bot.send_photo(int(os.environ['SEND_CHAT']),
|
else:
|
||||||
post.file.url,
|
await bot.send_photo(int(os.environ['SEND_CHAT']),
|
||||||
caption=caption)
|
post.file.url,
|
||||||
await redis.sadd('e621:sent', post.id)
|
caption=caption)
|
||||||
|
await redis.sadd('e621:sent', post.id)
|
||||||
|
except exceptions.TelegramAPIError as e:
|
||||||
|
logging.exception(e)
|
||||||
|
|
||||||
|
|
||||||
@dp.message_handler(commands=['add'])
|
@dp.message_handler(commands=['add'])
|
||||||
|
Loading…
Reference in New Issue
Block a user