Push latest
This commit is contained in:
@@ -1,6 +1,5 @@
|
||||
#!/bin/env python3
|
||||
from flask import Flask, request, jsonify
|
||||
# import asyncio
|
||||
import websocket
|
||||
import json
|
||||
import yaml
|
||||
@@ -9,14 +8,11 @@ import random
|
||||
app = Flask(__name__)
|
||||
|
||||
hooks = {}
|
||||
with open(r'hooks.yml') as hooksfile:
|
||||
with open(r'/etc/tellme/hooks.yml') as hooksfile:
|
||||
hooks = yaml.load(hooksfile, Loader=yaml.FullLoader)
|
||||
print(hooks)
|
||||
#hooks['2345555XE'] = '#Bottest'
|
||||
|
||||
def sendmessage(target, message):
|
||||
print("Sendmessage %s called to %s" % (message, target))
|
||||
uri = "ws://localhost:5080"
|
||||
#message = "#Bottest Hello, world!"
|
||||
msg = ("%s %s" % (target, message))
|
||||
|
||||
@@ -28,10 +24,10 @@ def sendmessage(target, message):
|
||||
json_command = json.dumps(command)
|
||||
|
||||
""" Connects to WebSocket server, sends a message, and returns the response """
|
||||
ws = websocket.create_connection(uri) # Blocking WebSocket connection
|
||||
# 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
|
||||
# ws.close() # Close WebSocket connection
|
||||
print(response)
|
||||
return response
|
||||
|
||||
@@ -50,4 +46,6 @@ def webhook_receiver(id):
|
||||
|
||||
|
||||
if __name__ == '__main__':
|
||||
uri = "ws://localhost:5080"
|
||||
ws = websocket.create_connection(uri)
|
||||
app.run(debug=True)
|
||||
|
||||
Reference in New Issue
Block a user