log errors but don't fail
This commit is contained in:
parent
41c1b1cdec
commit
9f446139be
1 changed files with 22 additions and 14 deletions
|
|
@ -1,3 +1,4 @@
|
|||
import logging
|
||||
import os
|
||||
import tempfile
|
||||
|
||||
|
|
@ -12,6 +13,7 @@ from ..telegrambot import rpc as telegram_rpc
|
|||
from ..celery import app
|
||||
from . import models
|
||||
|
||||
logger = logging.getLogger(__name__)
|
||||
|
||||
@app.task(queue="default", ignore_results=True)
|
||||
def announce_items():
|
||||
|
|
@ -32,21 +34,27 @@ def announce_items():
|
|||
f.close()
|
||||
image = f.name
|
||||
if getattr(settings, "SIGNAL_ANNOUNCE_GROUP"):
|
||||
r = rpc.send(
|
||||
message,
|
||||
group=settings.SIGNAL_ANNOUNCE_GROUP,
|
||||
preview_url=link,
|
||||
preview_title=item.title,
|
||||
preview_image=image,
|
||||
preview_description=description,
|
||||
)
|
||||
try:
|
||||
r = rpc.send(
|
||||
message,
|
||||
group=settings.SIGNAL_ANNOUNCE_GROUP,
|
||||
preview_url=link,
|
||||
preview_title=item.title,
|
||||
preview_image=image,
|
||||
preview_description=description,
|
||||
)
|
||||
except:
|
||||
logger.error("failed to send singal", exec_info=True)
|
||||
if getattr(settings, "TELEGRAM_ANNOUNCE_CHANNEL"):
|
||||
message = f'{item.title}\n<a href="{link}">{link}</a>'
|
||||
r = telegram_rpc.send(
|
||||
message,
|
||||
channel=settings.TELEGRAM_ANNOUNCE_CHANNEL,
|
||||
preview_image=image,
|
||||
)
|
||||
try:
|
||||
message = f'{item.title}\n<a href="{link}">{link}</a>'
|
||||
r = telegram_rpc.send(
|
||||
message,
|
||||
channel=settings.TELEGRAM_ANNOUNCE_CHANNEL,
|
||||
preview_image=image,
|
||||
)
|
||||
except:
|
||||
logger.error("failed to send telegram", exec_info=True)
|
||||
item.save()
|
||||
if image:
|
||||
os.unlink(f.name)
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue