add webhook

This commit is contained in:
Wendy Liga
2023-12-26 13:07:58 +07:00
parent 7c9920867d
commit 44e7e95a16
5 changed files with 73 additions and 1 deletions

View File

@@ -12,6 +12,7 @@ import emoji
from colorama import Fore, init
from TwitchChannelPointsMiner.classes.Discord import Discord
from TwitchChannelPointsMiner.classes.Webhook import Webhook
from TwitchChannelPointsMiner.classes.Matrix import Matrix
from TwitchChannelPointsMiner.classes.Settings import Events
from TwitchChannelPointsMiner.classes.Telegram import Telegram
@@ -75,6 +76,7 @@ class LoggerSettings:
"auto_clear",
"telegram",
"discord",
"webhook",
"matrix",
"pushover",
"username"
@@ -94,6 +96,7 @@ class LoggerSettings:
auto_clear: bool = True,
telegram: Telegram or None = None,
discord: Discord or None = None,
webhook: Webhook or None = None,
matrix: Matrix or None = None,
pushover: Pushover or None = None,
username: str or None = None
@@ -110,6 +113,7 @@ class LoggerSettings:
self.auto_clear = auto_clear
self.telegram = telegram
self.discord = discord
self.webhook = webhook
self.matrix = matrix
self.pushover = pushover
self.username = username
@@ -185,6 +189,7 @@ class GlobalFormatter(logging.Formatter):
if hasattr(record, "event"):
self.telegram(record)
self.discord(record)
self.webhook(record)
self.matrix(record)
self.pushover(record)
@@ -218,6 +223,16 @@ class GlobalFormatter(logging.Formatter):
):
self.settings.discord.send(record.msg, record.event)
def webhook(self, record):
skip_webhook = False if hasattr(
record, "skip_webhook") is False else True
if (
self.settings.webhook is not None
and skip_webhook is False
):
self.settings.webhook.send(record.msg, record.event)
def matrix(self, record):
skip_matrix = False if hasattr(
record, "skip_matrix") is False else True