feat: Gotify module

This commit is contained in:
leko
2024-08-14 01:40:59 +08:00
committed by GitHub
parent 36647bb85b
commit 5f6920f8df
5 changed files with 60 additions and 0 deletions

View File

@@ -17,6 +17,7 @@ from TwitchChannelPointsMiner.classes.Matrix import Matrix
from TwitchChannelPointsMiner.classes.Settings import Events
from TwitchChannelPointsMiner.classes.Telegram import Telegram
from TwitchChannelPointsMiner.classes.Pushover import Pushover
from TwitchChannelPointsMiner.classes.Gotify import Gotify
from TwitchChannelPointsMiner.utils import remove_emoji
@@ -79,6 +80,7 @@ class LoggerSettings:
"webhook",
"matrix",
"pushover",
"gotify",
"username"
]
@@ -99,6 +101,7 @@ class LoggerSettings:
webhook: Webhook or None = None,
matrix: Matrix or None = None,
pushover: Pushover or None = None,
gotify: Gotify or None = None,
username: str or None = None
):
self.save = save
@@ -116,6 +119,7 @@ class LoggerSettings:
self.webhook = webhook
self.matrix = matrix
self.pushover = pushover
self.gotify = gotify
self.username = username
@@ -192,6 +196,7 @@ class GlobalFormatter(logging.Formatter):
self.webhook(record)
self.matrix(record)
self.pushover(record)
self.gotify(gotify)
if self.settings.colored is True:
record.msg = (
@@ -259,6 +264,18 @@ class GlobalFormatter(logging.Formatter):
):
self.settings.pushover.send(record.msg, record.event)
def gotify(self, record):
skip_gotify = False if hasattr(
record, "skip_gotify") is False else True
if (
self.settings.gotify is not None
and skip_gotify is False
and self.settings.gotify.endpoint
!= "https://example.com/message?token=TOKEN"
):
self.settings.gotify.send(record.msg, record.event)
def configure_loggers(username, settings):
if settings.colored is True: