diff --git a/Dir Config/scripts/LibraryFrame.png b/Dir Config/scripts/LibraryFrame.png index 37c4418..4b82956 100644 Binary files a/Dir Config/scripts/LibraryFrame.png and b/Dir Config/scripts/LibraryFrame.png differ diff --git a/Dir Config/scripts/bacula_discord_webhook.py b/Dir Config/scripts/bacula_discord_webhook.py index 7a5cdc4..31f45ea 100644 --- a/Dir Config/scripts/bacula_discord_webhook.py +++ b/Dir Config/scripts/bacula_discord_webhook.py @@ -15,27 +15,31 @@ stdout,stderr = out.communicate() # Extract the outputs #print(stdout) # Print the output print(stderr) # Print any errors -cleaned_stdout = stdout.partition(b"\nmessages\n")[2] + b"" # Trim the messages by removing timestamp and connection info +cleaned_stdout = (stdout.partition(b"\nmessages\n")[2] + b"").decode("utf-8") # Trim the messages by removing timestamp and connection info print(cleaned_stdout) # Print the cleaned output # Discord limits each message to 2000 chars, if the message is longer than that, truncate it truncated_stdout = [cleaned_stdout[i:i+maxCharPerMessage] for i in range(0, len(cleaned_stdout), maxCharPerMessage)] print (truncated_stdout) # Print the truncated message -if (truncated_stdout[0] != b'You have no messages.\n'): # If the first part of the truncated message is empty (no messages) dont send it. +if (truncated_stdout[0] != "You have no messages.\n"): # If the first part of the truncated message is empty (no messages) dont send it. vidcap = cv2.VideoCapture("rtsp://10.85.3.33:554/11") success,image = vidcap.read() print(success) if success: cv2.imwrite("LibraryFrame.png", image) - imagewebhook = DiscordWebhook(url=webhookURL, content="Live Snapshot") - with open("LibraryFrame.png", "rb") as f: - imagewebhook.add_file(file=f.read(), filename='LibraryFrame.png') - response = imagewebhook.execute() +# imagewebhook = DiscordWebhook(url=webhookURL, content="Live Snapshot") +# with open("LibraryFrame.png", "rb") as f: +# imagewebhook.add_file(file=f.read(), filename='LibraryFrame.png') +# response = imagewebhook.execute() for message_part in truncated_stdout: # For every message part in the truncated output, run this loop - message_part = b"```" + message_part + b"```" - webhook = DiscordWebhook(url=webhookURL, content=message_part) # Send the output to the webhook URL - response = webhook.execute() + message_part = "```" + message_part + "```" # Encapsulate the messsage + print(message_part) + webhook = DiscordWebhook(url=webhookURL, content=message_part) # Attach the message + if success: + with open("LibraryFrame.png", "rb") as f: + webhook.add_file(file=f.read(), filename='LibraryFrame.png') + response = webhook.execute() # Hit send else: print("Done.")