Also use custom feed stuff if sent from send_to_discord
All checks were successful
Test and build Docker image / docker (push) Successful in 2m18s
All checks were successful
Test and build Docker image / docker (push) Successful in 2m18s
This commit is contained in:
@ -289,7 +289,7 @@ def set_entry_as_read(reader: Reader, entry: Entry) -> None:
|
|||||||
logger.exception("Error setting entry to read: %s", entry.id)
|
logger.exception("Error setting entry to read: %s", entry.id)
|
||||||
|
|
||||||
|
|
||||||
def send_to_discord(custom_reader: Reader | None = None, feed: Feed | None = None, *, do_once: bool = False) -> None:
|
def send_to_discord(custom_reader: Reader | None = None, feed: Feed | None = None, *, do_once: bool = False) -> None: # noqa: PLR0912
|
||||||
"""Send entries to Discord.
|
"""Send entries to Discord.
|
||||||
|
|
||||||
If response was not ok, we will log the error and mark the entry as unread, so it will be sent again next time.
|
If response was not ok, we will log the error and mark the entry as unread, so it will be sent again next time.
|
||||||
@ -320,6 +320,11 @@ def send_to_discord(custom_reader: Reader | None = None, feed: Feed | None = Non
|
|||||||
continue
|
continue
|
||||||
|
|
||||||
should_send_embed: bool = should_send_embed_check(reader, entry)
|
should_send_embed: bool = should_send_embed_check(reader, entry)
|
||||||
|
|
||||||
|
# Youtube feeds only need to send the link
|
||||||
|
if is_youtube_feed(entry.feed.url):
|
||||||
|
should_send_embed = False
|
||||||
|
|
||||||
if should_send_embed:
|
if should_send_embed:
|
||||||
webhook = create_embed_webhook(webhook_url, entry)
|
webhook = create_embed_webhook(webhook_url, entry)
|
||||||
else:
|
else:
|
||||||
@ -341,11 +346,27 @@ def send_to_discord(custom_reader: Reader | None = None, feed: Feed | None = Non
|
|||||||
continue
|
continue
|
||||||
|
|
||||||
# Check if the feed has a whitelist, and if it does, check if the entry is whitelisted.
|
# Check if the feed has a whitelist, and if it does, check if the entry is whitelisted.
|
||||||
if has_white_tags(reader, entry.feed):
|
if has_white_tags(reader, entry.feed) and not should_be_sent(reader, entry):
|
||||||
if should_be_sent(reader, entry):
|
logger.info("Entry was not whitelisted: %s", entry.id)
|
||||||
|
continue
|
||||||
|
|
||||||
|
# Use a custom webhook for Hoyolab feeds.
|
||||||
|
if is_c3kay_feed(entry.feed.url):
|
||||||
|
entry_link: str | None = entry.link
|
||||||
|
if entry_link:
|
||||||
|
post_id: str | None = extract_post_id_from_hoyolab_url(entry_link)
|
||||||
|
if post_id:
|
||||||
|
post_data: dict[str, Any] | None = fetch_hoyolab_post(post_id)
|
||||||
|
if post_data:
|
||||||
|
webhook = create_hoyolab_webhook(webhook_url, entry, post_data)
|
||||||
execute_webhook(webhook, entry)
|
execute_webhook(webhook, entry)
|
||||||
return
|
return
|
||||||
continue
|
logger.warning(
|
||||||
|
"Failed to create Hoyolab webhook for feed %s, falling back to regular processing",
|
||||||
|
entry.feed.url,
|
||||||
|
)
|
||||||
|
else:
|
||||||
|
logger.warning("No entry link found for feed %s, falling back to regular processing", entry.feed.url)
|
||||||
|
|
||||||
# Send the entry to Discord as it is not blacklisted or feed has a whitelist.
|
# Send the entry to Discord as it is not blacklisted or feed has a whitelist.
|
||||||
execute_webhook(webhook, entry)
|
execute_webhook(webhook, entry)
|
||||||
|
Reference in New Issue
Block a user