MCPcopy Create free account
hub / github.com/CryptoSignal/Crypto-Signal / WebhookNotifier

Class WebhookNotifier

app/notifiers/webhook_client.py:9–33  ·  view source on GitHub ↗

Class for handling webhook notifications

Source from the content-addressed store, hash-verified

7from notifiers.utils import NotifierUtils
8
9class WebhookNotifier(NotifierUtils):
10 """Class for handling webhook notifications
11 """
12
13 def __init__(self, url, username, password):
14 self.logger = structlog.get_logger()
15 self.url = url
16 self.username = username
17 self.password = password
18
19
20 def notify(self, message):
21 """Sends the message.
22
23 Args:
24 message (str): The message to send.
25 """
26
27 if self.username and self.password:
28 request = requests.post(self.url, json=message, auth=(self.username, self.password))
29 else:
30 request = requests.post(self.url, json=message)
31
32 if not request.status_code == requests.codes.ok:
33 self.logger.error("Request failed: %s - %s", request.status_code, request.content)

Callers 1

__init__Method · 0.90

Calls

no outgoing calls

Tested by

no test coverage detected