Remove print statements

This commit is contained in:
2023-01-17 01:38:07 +01:00
parent 202c0b1212
commit ace8d238bf
4 changed files with 0 additions and 16 deletions

View File

@ -21,9 +21,6 @@ def try_to_replace(custom_message: str, template: str, replace_with: str) -> str
if not replace_with:
return custom_message
try:
print(f"custom_message: {custom_message}")
print(f"template: {template}")
print(f"replace_with: {replace_with}")
return custom_message.replace(template, replace_with)
except TypeError:
return custom_message
@ -81,8 +78,6 @@ def replace_tags(feed: Feed, entry: Entry) -> str:
for replacement in list_of_replacements:
for template, replace_with in replacement.items():
custom_message = try_to_replace(custom_message, template, replace_with)
print(f"custom_message: {custom_message}")
return custom_message

View File

@ -45,23 +45,19 @@ def send_to_discord(custom_reader: Reader | None = None, feed: Feed | None = Non
webhook_message: str = f"{entry.title}\n{entry.link}"
if not webhook_url:
print(f"Error: No webhook found for feed: {entry.feed.title}")
continue
webhook: DiscordWebhook = DiscordWebhook(url=webhook_url, content=webhook_message, rate_limit_retry=True)
if custom_message.get_custom_message(reader, entry.feed) != "":
print("Custom message found, replacing tags.")
webhook.content = custom_message.replace_tags(entry=entry, feed=entry.feed)
print(f"Webhook content: {webhook.content}")
if feed is not None and has_white_tags(reader, feed):
# Only send the entry if it is whitelisted, otherwise, mark it as read and continue.
if should_be_sent(reader, entry):
response: Response = webhook.execute()
reader.set_entry_read(entry, True)
if not response.ok:
print(f"Error sending to Discord: {response.text}")
reader.set_entry_read(entry, False)
else:
reader.set_entry_read(entry, True)
@ -69,14 +65,12 @@ def send_to_discord(custom_reader: Reader | None = None, feed: Feed | None = Non
# Check if the entry is blacklisted, if it is, mark it as read and continue.
if should_be_skipped(reader, entry):
print(f"Blacklisted entry: {entry.title}, not sending to Discord.")
reader.set_entry_read(entry, True)
continue
# It was not blacklisted, and not forced through whitelist, so we will send it to Discord.
response: Response = webhook.execute()
if not response.ok:
print(f"Error sending to Discord: {response.text}")
reader.set_entry_read(entry, False)
# If we only want to send one entry, we will break the loop. This is used when testing this function.

View File

@ -92,8 +92,6 @@ async def delete_webhook(webhook_url=Form()):
# Add the new webhook to the list of webhooks.
webhooks.remove(webhook)
print(f"Removed webhook {webhook['name']}.")
# Add our new list of webhooks to the database.
reader.set_tag((), "webhooks", webhooks) # type: ignore
@ -324,9 +322,7 @@ async def set_custom(custom_message=Form(""), feed_url=Form()):
# Add the custom_message to the feed.
if custom_message:
reader.set_tag(feed_url, "custom_message", custom_message)
print(f"Set custom message for {feed_url} to {custom_message}")
else:
print(f"Removing custom message for {feed_url}")
reader.delete_tag(feed_url, "custom_message", missing_ok=True)
# Clean URL is used to redirect to the feed page.

View File

@ -30,7 +30,6 @@ def get_webhook_for_entry(custom_reader: Reader, entry: Entry) -> str:
try:
webhook_url = str(reader.get_tag(entry.feed_url, "webhook"))
except TagNotFoundError:
print(f"Webhook not found for feed {entry.feed_url}")
webhook_url = ""
return webhook_url