Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- import requests
- from conf import staticConfigs
- class DiscordNotifier:
- def __init__(self):
- self.configs = staticConfigs()
- self.webhook_url = self.configs.discord_webhook_url
- self.bot_username = "Notifier"
- self.data_struct = {
- "content": "",
- "username": self.bot_username
- }
- def _PostToWebhook(self):
- res = requests.post(self.webhook_url, json=self.data_struct)
- try:
- res.raise_for_status()
- except Exception as e:
- return False
- else:
- return True
- def Notify(self, message):
- self.data_struct["content"] = message
- return self._PostToWebhook()
Advertisement
Add Comment
Please, Sign In to add comment