Full support for GoAlert

This commit is contained in:
2026-04-21 08:31:25 +02:00
parent b95b776418
commit 6bf58f8510
6 changed files with 34 additions and 10 deletions

View File

@@ -1,3 +1,6 @@
TellMe Server (2.1.0)
* Added support for GoAlert messages
TellMe Server (2.0.0b2)
* Add logging

View File

@@ -1,6 +1,6 @@
{
"name": "TellMe",
"version": "2.0.0b1",
"version": "2.1.0",
"description": "TellMe CLI",
"scripts": {
"dev": "webpack-dev-server --inline --hot"

View File

@@ -28,7 +28,7 @@ def sendmessage(message):
url = ("%s/webhook/%s" % (baseurl, webhook))
r = requests.post(url, json = { 'message': mymessage })
r = requests.post(url, json = { 'AppName': 'TellMe', 'message': mymessage })
if r.status_code == 200:
print("Message has been sent successfully")
# print(message)

View File

@@ -1,6 +1,6 @@
{
"name": "TellMe Server",
"version": "2.0.0b2",
"version": "2.1.0",
"description": "TellMe Server",
"scripts": {
"dev": "webpack-dev-server --inline --hot"

View File

@@ -5,7 +5,7 @@ import random
import zmq
from pprint import pprint
__version__ = "2.0.0b2"
__version__ = "2.1.0"
ws = None
uri = "ws://localhost:5080"

View File

@@ -6,7 +6,7 @@ import yaml
import zmq
from pprint import pprint
__version__ = "2.0.0b2"
__version__ = "2.1.0"
versionstring='Taurix TellMe server v' + __version__
app = Flask(__name__)
@@ -40,11 +40,32 @@ def sendmessage(target, message):
@app.route("/webhook/<id>", methods=['POST'])
def webhook_receiver(id):
print("Webhook id %s" % (id))
pprint(request.json)
data = request.json # Get the JSON data from the incoming request
data = request.json
# Process the data and perform actions based on the event
print("Received webhook data:", data)
source = 'TellMe' # Support old TellMe client
if data.get('AppName') is not None:
source = data.get('AppName')
message = None
print("Message format is %s" % (source))
if source == 'TellMe':
message = data.get('message')
if source == 'GoAlert':
type = data.get('Type')
if type == 'Verification':
message = ("GoAlert verification code: %s" % (data.get('Code`')))
if type == 'Alert':
message = ("%s\n%s" % (data.get('Summary'), data.get('Details')))
if type == 'AlertStatus':
message = ("Alert %s: %s" % (data.get('AlertID'), data.get('LogEntry')))
target = None
for key, value in hooks.items():
if str(key) == str(id):
@@ -52,10 +73,10 @@ def webhook_receiver(id):
if target is not None:
print(target)
if data.get('message') is not None:
sendmessage(target, data.get('message'))
if message is not None:
sendmessage(target, message)
else:
print("No message, droppint")
print("No message, dropping")
else:
print("No target found, dropping message")