code fixes
This commit is contained in:
parent
b821efb785
commit
5c975d58ea
|
@ -3,6 +3,7 @@ import json
|
||||||
import datetime as dt
|
import datetime as dt
|
||||||
|
|
||||||
tg = [91, 98002]
|
tg = [91, 98002]
|
||||||
|
min_duration = 2
|
||||||
id = ""
|
id = ""
|
||||||
|
|
||||||
def on_connect():
|
def on_connect():
|
||||||
|
@ -18,13 +19,18 @@ def on_mqtt(*args):
|
||||||
out = ""
|
out = ""
|
||||||
global id
|
global id
|
||||||
call = json.loads(args[0]['payload'])
|
call = json.loads(args[0]['payload'])
|
||||||
if call["DestinationID"] in tg and id != call["_id"]:
|
#print(json.dumps(call,separators=(',',':'),sort_keys=True,indent=4))
|
||||||
time = dt.datetime.utcfromtimestamp(call["Start"]).strftime("%Y/%m/%d %H:%M")
|
#if call["DestinationID"] in tg and id != call["SessionID"]:
|
||||||
out += call["SourceCall"] + ' (' + call["SourceName"] + ') was active on ' + str(call["DestinationID"]) + ' (' + call["DestinationName"] + ') at ' + time
|
if call["DestinationID"] in tg and call["Stop"] > 0 and id != call["SessionID"]:
|
||||||
print(out)
|
duration = call["Stop"] - call["Start"]
|
||||||
#print(json.dumps(call,separators=(',',':'),sort_keys=True,indent=4))
|
if duration > min_duration:
|
||||||
id = call["_id"]
|
time = dt.datetime.utcfromtimestamp(call["Start"]).strftime("%Y/%m/%d %H:%M")
|
||||||
|
out += call["SourceCall"] + ' (' + call["SourceName"] + ') was active on '
|
||||||
|
out += str(call["DestinationID"]) + ' (' + call["DestinationName"] + ') at '
|
||||||
|
out += time + ' (' + str(duration) + ' seconds)'
|
||||||
|
#print(json.dumps(call,separators=(',',':'),sort_keys=True,indent=4))
|
||||||
|
id = call["SessionID"]
|
||||||
|
print(out)
|
||||||
|
|
||||||
socket = SocketIO('https://api.brandmeister.network/lh')
|
socket = SocketIO('https://api.brandmeister.network/lh')
|
||||||
socket.on('connect', on_connect)
|
socket.on('connect', on_connect)
|
||||||
|
|
Loading…
Reference in New Issue