Skip to content

Commit

Permalink
bug fix/formatting change
Browse files Browse the repository at this point in the history
  • Loading branch information
Drazzilb08 committed Feb 3, 2024
1 parent 40c81bd commit b855026
Show file tree
Hide file tree
Showing 2 changed files with 13 additions and 4 deletions.
2 changes: 1 addition & 1 deletion modules/poster_renamerr.py
Original file line number Diff line number Diff line change
Expand Up @@ -574,7 +574,7 @@ def notification(output):
for key, value in discord_dict.items():
print(f"Sending message {key} of {len(discord_dict)}") # Display message sending status
# Actual function to send messages to Discord (which is currently represented by a 'print' statement)
discord(fields=value, logger=logger, script_name="Poster Renamerr", description=f"{'__**Dry Run**__' if dry_run else ''}", color=0x00ff00, content=None)
discord(fields=value, logger=logger, script_name=script_name, description=f"{'__**Dry Run**__' if dry_run else ''}", color=0x00ff00, content=None)
# Pauses for 5 seconds each 5th message
if key % 5 == 0:
print("Pausing for 5 seconds to let Discord catch up...")
Expand Down
15 changes: 12 additions & 3 deletions util/discord.py
Original file line number Diff line number Diff line change
Expand Up @@ -31,17 +31,22 @@ def get_discord_data(script_name, logger):

# Get the 'notifiarr_webhook' from the config
notifiarr_webhook = discord.get('notifiarr_webhook', None)

# Get the script-specific notification info from the config based on the script name
script_notification_info = discord.get(script_name, {})

# Get the 'channel_id' and 'discord_webhook' from the script-specific notification info
channel_id = script_notification_info.get('channel_id', None)

# Get the 'discord_webhook' from the script-specific notification info
discord_webhook = script_notification_info.get('discord_webhook', None)

# If notifiarr_webhook is missing, log an error and return
if notifiarr_webhook:
# If channel_id is missing, log an error and return
if not channel_id:
logger.error("Discord channel ID is missing. Cannot send Discord notification.")
return
return None, None
else:
return notifiarr_webhook, channel_id
else:
Expand Down Expand Up @@ -97,7 +102,10 @@ def discord_check(script_name):
# Get the script-specific notification info from the config based on the script name
script_notification_info = discord.get(script_name, {})

# Get the 'channel_id' and 'discord_webhook' from the script-specific notification info
channel_id = script_notification_info.get('channel_id', None)

# Get the 'discord_webhook' from the script-specific notification info
discord_webhook = script_notification_info.get('discord_webhook', None)

if discord_webhook or channel_id and notifiarr_webhook:
Expand Down Expand Up @@ -125,6 +133,7 @@ def discord(fields, logger, script_name, description, color, content):
"""
# Get the webhook and channel_id from the config
webhook, channel_id = get_discord_data(script_name, logger)
script_name = script_name.replace("_", " ").title()
if webhook:
# Get the random joke and timestamp
random_joke, timestamp = get_message_data(logger)
Expand All @@ -140,7 +149,7 @@ def discord(fields, logger, script_name, description, color, content):
payload = {
"notification": {
"update": False,
"name": f"{script_name.capitalize()}",
"name": f"{script_name}",
},
"discord": {
"color": f"{color}",
Expand Down

0 comments on commit b855026

Please sign in to comment.