Compare commits

..

No commits in common. "38d9e87393283c6340e1856e2e6b11e823875ac5" and "4801b74405702a953cf546747037d777b0516854" have entirely different histories.

View File

@ -18,25 +18,25 @@ with open(r'/etc/tellme/hooks.yml') as hooksfile:
def sendmessage(target, message):
print("Sendmessage %s called to %s" % (message, target))
msg = ("%s %s" % (target, message))
with lock:
msg = ("%s %s" % (target, message))
# Create a unique correlation ID
command = {
"corrId": f"id{random.randint(0, 999999)}",
"cmd": msg,
}
json_command = json.dumps(command)
# Create a unique correlation ID
command = {
"corrId": f"id{random.randint(0, 999999)}",
"cmd": msg,
}
json_command = json.dumps(command)
""" Connects to WebSocket server, sends a message, and returns the response """
uri = "ws://localhost:5080"
ws = websocket.create_connection(uri) # Blocking WebSocket connection
ws.send(json_command) # Send message to WebSocket
response = ws.recv() # Receive response
print("Message %s sent over websocket to %s" % (message, target))
# ws.close() # Close WebSocket connection
# print(response)
ws.close()
return response
""" Connects to WebSocket server, sends a message, and returns the response """
uri = "ws://localhost:5080"
ws = websocket.create_connection(uri) # Blocking WebSocket connection
ws.send(json_command) # Send message to WebSocket
response = ws.recv() # Receive response
# ws.close() # Close WebSocket connection
# print(response)
ws.close()
return response
@app.route("/webhook/<id>", methods=['POST'])
def webhook_receiver(id):
@ -52,8 +52,7 @@ def webhook_receiver(id):
if target is not None:
print(target)
with lock:
sendmessage(target, data.get('message'))
sendmessage(target, data.get('message'))
else:
print("No target found, dropping message")