Send one Fluxer webhook message per alert
Post each alert as its own webhook message instead of batching multiple embeds into a single message.
This commit is contained in:
parent
dc831b430b
commit
73b6d38113
1 changed files with 2 additions and 4 deletions
|
|
@ -7,7 +7,6 @@ import requests
|
||||||
|
|
||||||
from .base import Message, Notifier, NotifierError
|
from .base import Message, Notifier, NotifierError
|
||||||
|
|
||||||
EMBEDS_PER_MESSAGE = 10
|
|
||||||
COLOR_URGENT = 0xE74C3C
|
COLOR_URGENT = 0xE74C3C
|
||||||
COLOR_NORMAL = 0x3498DB
|
COLOR_NORMAL = 0x3498DB
|
||||||
USERNAME = "Admin Alerts"
|
USERNAME = "Admin Alerts"
|
||||||
|
|
@ -19,9 +18,8 @@ class FluxerWebhookNotifier(Notifier):
|
||||||
self._timeout = timeout
|
self._timeout = timeout
|
||||||
|
|
||||||
def send(self, messages: Sequence[Message]) -> None:
|
def send(self, messages: Sequence[Message]) -> None:
|
||||||
for start in range(0, len(messages), EMBEDS_PER_MESSAGE):
|
for message in messages:
|
||||||
batch = messages[start : start + EMBEDS_PER_MESSAGE]
|
payload = {"username": USERNAME, "embeds": [_embed(message)]}
|
||||||
payload = {"username": USERNAME, "embeds": [_embed(m) for m in batch]}
|
|
||||||
try:
|
try:
|
||||||
resp = requests.post(self._url, json=payload, timeout=self._timeout)
|
resp = requests.post(self._url, json=payload, timeout=self._timeout)
|
||||||
except requests.RequestException as exc:
|
except requests.RequestException as exc:
|
||||||
|
|
|
||||||
Loading…
Add table
Reference in a new issue