I would like to send messages to a webhook.
Attached is my python script, could anyone help convert this to Excel VBA?
I've seen someone do it here but I'm a novice to programming
Usage is...
python c:\user\python scripts\send_message.py "Hello World"
Attached is my python script, could anyone help convert this to Excel VBA?
I've seen someone do it here but I'm a novice to programming
Rich (BB code):
import json
import requests
import sys
WEBHOOK_URI = 'webhook url'
def post_message(msg):
response = None
try:
response = requests.post(
url=WEBHOOK_URI,
json={"Content": msg})
return json.loads(response.text)
except:
return response.text
## Check for a message as runtime parameter
if len(sys.argv) != 2:
print('\n\tIncorrect usage!')
print('\n\tExample Usage:')
print('\tpython3 ' + sys.argv[0] + ' \"Hello World\"\n')
exit()
## Get the message to send as a parameter
message = sys.argv[1]
## Post the message
req_res = post_message(message)
print(json.dumps(req_res, indent=2))
Usage is...
python c:\user\python scripts\send_message.py "Hello World"