Add discord notification

This commit is contained in:
Dryusdan 2020-12-11 13:11:28 +01:00
parent 3ac53d76d0
commit 20b42fee2c
3 changed files with 12 additions and 5 deletions

2
.gitignore vendored
View File

@ -130,5 +130,5 @@ dmypy.json
.pyre/ .pyre/
# Ignore config # Ignore config
conf/kimsufi.yaml config/kimsufi.yaml
db.sqlite db.sqlite

View File

@ -34,4 +34,7 @@ notifications:
host: domain.tld host: domain.tld
thumbnail: True thumbnail: True
room_id: !12546789:domain.tld room_id: !12546789:domain.tld
discord:
webhookid: 123
webhooktoken: 567
db: db.sqlite db: db.sqlite

View File

@ -35,8 +35,8 @@ class Notifications:
def run(self, server, datacenter): def run(self, server, datacenter):
refOfServer = Settings().get("config/refToName.yml") refOfServer = Settings().get("config/refToName.yml")
self.apprise.notify( self.apprise.notify(
body="{} is available {}".format(refOfServer[server], datacenter), body="",
title="{} is available \o/".format(refOfServer[server], datacenter), title="Le serveur {} disponible au datacenter de {}".format(refOfServer[server], datacenter),
notify_type=apprise.NotifyType.INFO, notify_type=apprise.NotifyType.INFO,
) )
@ -77,7 +77,12 @@ class Notifications:
) )
def _addDiscord(self): def _addDiscord(self):
return True self.apprise.add(
"discord://{}/{}/".format(
self.config["discord"]["webhookid"],
self.config["discord"]["webhooktoken"],
)
)
def _addMatrix(self): def _addMatrix(self):
self.apprise.add( self.apprise.add(
@ -88,4 +93,3 @@ class Notifications:
self.config["matrix"]["room_id"], self.config["matrix"]["room_id"],
) )
) )
return True