-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathdapnet_send.py
executable file
·37 lines (29 loc) · 1016 Bytes
/
dapnet_send.py
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
#!/usr/bin/env python
# -*- coding: utf-8 -*-
import requests
import sys
dapnet_user = "nocall"
dapnet_pass = "nopass"
dapnet_txgroup = "f-all"
dapnet_emergency = "false"
def debug():
if ((len(sys.argv)>3) and (str(sys.argv[3]) == "debug")):
return True
else:
return False
if (len(sys.argv)<3):
print ("dapnet_send.py - version 1.0 - by Johan Denoyer ([email protected])")
print ("Usage : ")
print (sys.argv[0]+" destination_call \"message\" [debug]")
print ("debug is optionnal (that's why it's between [])")
exit(0)
destination = str(sys.argv[1])
message = str(sys.argv[2])
headers = {
'Content-Type': 'application/json',
}
data = '{ "text": "'+dapnet_user.upper()+': '+message+'", "callSignNames": ["'+destination+'"], "transmitterGroupNames": ["'+dapnet_txgroup+'"], "emergency": '+dapnet_emergency+' }'
response = requests.post('http://www.hampager.de:8080/calls', headers=headers, data=data, auth=(dapnet_user, dapnet_pass))
if (debug()):
print ("DEBUG : "+str(response.text))
exit(0)