Bunch more big changes here too
This commit is contained in:
20
Dir Config/scripts/bacula_discord_webhook.py
Normal file
20
Dir Config/scripts/bacula_discord_webhook.py
Normal file
@@ -0,0 +1,20 @@
|
||||
from discord_webhook import DiscordWebhook
|
||||
import subprocess
|
||||
|
||||
webhookURL = "https://discordapp.com/api/webhooks/719690867811811348/8LExCQbqOPP0XAdNcbV8JHrVYupOSYmeLwkBJWCDCe72JoPyc4Yy_R2wzbkKSN33MPAn"
|
||||
|
||||
out = subprocess.Popen(['echo messages | bconsole'],
|
||||
stdout=subprocess.PIPE,
|
||||
stderr=subprocess.STDOUT,
|
||||
shell=True)
|
||||
|
||||
stdout,stderr = out.communicate()
|
||||
print(stdout)
|
||||
print(stderr)
|
||||
cleaned_stdout = b"```" + stdout.partition(b"\nmessages\n")[2] + b"```"
|
||||
|
||||
if (cleaned_stdout != b'```You have no messages.\n```'):
|
||||
webhook = DiscordWebhook(url=webhookURL, content=cleaned_stdout)
|
||||
response = webhook.execute()
|
||||
else:
|
||||
print("Done.")
|
||||
Reference in New Issue
Block a user