Compare commits
	
		
			3 Commits
		
	
	
		
			6ad1a9f957
			...
			20ede6e02a
		
	
	| Author | SHA1 | Date | |
|---|---|---|---|
| 
						 | 
					20ede6e02a | ||
| 
						 | 
					6650f0e042 | ||
| 
						 | 
					e16f678338 | 
							
								
								
									
										2
									
								
								.gitignore
									
									
									
									
										vendored
									
									
								
							
							
						
						
									
										2
									
								
								.gitignore
									
									
									
									
										vendored
									
									
								
							@ -60,3 +60,5 @@ target/
 | 
				
			|||||||
 | 
					
 | 
				
			||||||
# Node
 | 
					# Node
 | 
				
			||||||
node_modules/
 | 
					node_modules/
 | 
				
			||||||
 | 
					client/node_modules/
 | 
				
			||||||
 | 
					server/node_modules/
 | 
				
			||||||
 | 
				
			|||||||
							
								
								
									
										4
									
								
								client/src/config.json.dist
									
									
									
									
									
										Normal file
									
								
							
							
						
						
									
										4
									
								
								client/src/config.json.dist
									
									
									
									
									
										Normal file
									
								
							@ -0,0 +1,4 @@
 | 
				
			|||||||
 | 
					{
 | 
				
			||||||
 | 
						"url": "",
 | 
				
			||||||
 | 
						"webhook": ""
 | 
				
			||||||
 | 
					}
 | 
				
			||||||
@ -26,9 +26,9 @@ def sendmessage(message):
 | 
				
			|||||||
        urllib3.disable_warnings()
 | 
					        urllib3.disable_warnings()
 | 
				
			||||||
        # http_client.HTTPConnection.debuglevel = 1
 | 
					        # http_client.HTTPConnection.debuglevel = 1
 | 
				
			||||||
 | 
					
 | 
				
			||||||
        url = ("%s/skill/tellops/%s" % (baseurl, webhook))
 | 
					        url = ("%s/webhook/%s" % (baseurl, webhook))
 | 
				
			||||||
 | 
					
 | 
				
			||||||
        r = requests.post(url, json = { 'message': mymessage, 'notify': notify, 'tts': args.tts })
 | 
					        r = requests.post(url, json = { 'message': mymessage })
 | 
				
			||||||
        if r.status_code == 200:
 | 
					        if r.status_code == 200:
 | 
				
			||||||
            print("Message has been sent successfully")
 | 
					            print("Message has been sent successfully")
 | 
				
			||||||
            # print(message)
 | 
					            # print(message)
 | 
				
			||||||
@ -39,7 +39,7 @@ def sendmessage(message):
 | 
				
			|||||||
        ran = True
 | 
					        ran = True
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					
 | 
				
			||||||
__version__ = "1.3.1"
 | 
					__version__ = "1.4.0"
 | 
				
			||||||
versionstring='TellMe v' + __version__
 | 
					versionstring='TellMe v' + __version__
 | 
				
			||||||
 | 
					
 | 
				
			||||||
signal.signal(signal.SIGINT, signal_handler)
 | 
					signal.signal(signal.SIGINT, signal_handler)
 | 
				
			||||||
@ -49,10 +49,8 @@ home=os.getenv("HOME")
 | 
				
			|||||||
 | 
					
 | 
				
			||||||
parser = argparse.ArgumentParser(description='TellMe command line client')
 | 
					parser = argparse.ArgumentParser(description='TellMe command line client')
 | 
				
			||||||
parser.add_argument("-m", "--message", default="Your process finished", help="Message to send")
 | 
					parser.add_argument("-m", "--message", default="Your process finished", help="Message to send")
 | 
				
			||||||
parser.add_argument('-t', '--tts', default=False, action='store_true', help="Send message to TTS")
 | 
					 | 
				
			||||||
parser.add_argument('-v', '--version', action='version', version=versionstring)
 | 
					parser.add_argument('-v', '--version', action='version', version=versionstring)
 | 
				
			||||||
parser.add_argument('-p', '--pid', action="store", dest="pid", type=int, default=0)
 | 
					parser.add_argument('-p', '--pid', action="store", dest="pid", type=int, default=0)
 | 
				
			||||||
parser.add_argument('-n', '--notify', action="store", dest="notify", default=None, help="Notify specific id")
 | 
					 | 
				
			||||||
parser.add_argument('-i', '--interval', action="store", dest="interval", type=int, default=5, help="Set the interval of commands like watch that use it")
 | 
					parser.add_argument('-i', '--interval', action="store", dest="interval", type=int, default=5, help="Set the interval of commands like watch that use it")
 | 
				
			||||||
parser.add_argument('-w', '--watch', action="store", dest="watchcommand", help="Run the given command every n or 5 minutes")
 | 
					parser.add_argument('-w', '--watch', action="store", dest="watchcommand", help="Run the given command every n or 5 minutes")
 | 
				
			||||||
parser.add_argument('-c', '--config', default=home +"/.config/tellme/config.json" ,help="Path to config file")
 | 
					parser.add_argument('-c', '--config', default=home +"/.config/tellme/config.json" ,help="Path to config file")
 | 
				
			||||||
							
								
								
									
										14
									
								
								package.json
									
									
									
									
									
								
							
							
						
						
									
										14
									
								
								package.json
									
									
									
									
									
								
							@ -1,14 +0,0 @@
 | 
				
			|||||||
{
 | 
					 | 
				
			||||||
  "name": "TellMe",
 | 
					 | 
				
			||||||
  "version": "1.3.0",
 | 
					 | 
				
			||||||
  "description": "TellMe CLI",
 | 
					 | 
				
			||||||
  "scripts": {
 | 
					 | 
				
			||||||
    "dev": "webpack-dev-server --inline --hot"
 | 
					 | 
				
			||||||
  },
 | 
					 | 
				
			||||||
  "author": "Guy Van Sanden <guy@taurix.net>",
 | 
					 | 
				
			||||||
  "license": "AGPL",
 | 
					 | 
				
			||||||
  "dependencies": {
 | 
					 | 
				
			||||||
    "grunt": "~0.4.5",
 | 
					 | 
				
			||||||
    "grunt-version": "~1.1.0"
 | 
					 | 
				
			||||||
  }
 | 
					 | 
				
			||||||
}
 | 
					 | 
				
			||||||
							
								
								
									
										49
									
								
								server/src/tellmesrv.py
									
									
									
									
									
										Normal file
									
								
							
							
						
						
									
										49
									
								
								server/src/tellmesrv.py
									
									
									
									
									
										Normal file
									
								
							@ -0,0 +1,49 @@
 | 
				
			|||||||
 | 
					#!/bin/env python3
 | 
				
			||||||
 | 
					from flask import Flask, request, jsonify
 | 
				
			||||||
 | 
					# import asyncio
 | 
				
			||||||
 | 
					import websocket
 | 
				
			||||||
 | 
					import json
 | 
				
			||||||
 | 
					import random
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					app = Flask(__name__)
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					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))
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					    # 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 """
 | 
				
			||||||
 | 
					    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)
 | 
				
			||||||
 | 
					    return response
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					@app.route("/webhook/<id>", methods=['POST'])
 | 
				
			||||||
 | 
					def webhook_receiver(id):
 | 
				
			||||||
 | 
					    print("Webhook id %s" % (id))
 | 
				
			||||||
 | 
					    data = request.json  # Get the JSON data from the incoming request
 | 
				
			||||||
 | 
					    # Process the data and perform actions based on the event
 | 
				
			||||||
 | 
					    print("Received webhook data:", data)
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					    target = hooks.get(id)
 | 
				
			||||||
 | 
					    print(target)
 | 
				
			||||||
 | 
					    sendmessage(target, data.get('message'))
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					    return jsonify({'message': 'Webhook received successfully'}), 200
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					if __name__ == '__main__':
 | 
				
			||||||
 | 
					    app.run(debug=True)
 | 
				
			||||||
@ -1,5 +0,0 @@
 | 
				
			|||||||
{
 | 
					 | 
				
			||||||
	"url": "",
 | 
					 | 
				
			||||||
	"webhook": "",
 | 
					 | 
				
			||||||
	"notify": "",
 | 
					 | 
				
			||||||
}
 | 
					 | 
				
			||||||
		Loading…
	
	
			
			x
			
			
		
	
		Reference in New Issue
	
	Block a user