diff --git a/main.py b/main.py index dc59858..ef78978 100644 --- a/main.py +++ b/main.py @@ -95,7 +95,7 @@ for master in bm_clustermasters_json: # SocketIO setup for the MQTT socket handling sio = socketio.Client(reconnection=True, reconnection_attempts=0, reconnection_delay=5, reconnection_delay_max=60) - + @sio.event def connect(): print('connected to server') @@ -103,11 +103,11 @@ def connect(): # otherwise the server keeps the connection open but sends no data. sio.emit("join", "everything") print('subscribed to LastHeard stream (join/everything)') - + @sio.event def disconnect(): print('disconnected from server, reconnecting...') - + @sio.on("mqtt") def on_mqtt(data): epoch_time = int(time.time()) @@ -120,7 +120,7 @@ def on_mqtt(data): max_old_time = epoch_time - 20 # Build the message that will be sent to Telegram - telegram_message = "Callsign: " + jsondata["SourceCall"] + " ID: " + str(jsondata["SourceID"]) + " \nName: " +jsondata["SourceName"] + " \nTalkeralias: " + jsondata["TalkerAlias"] + " \n-----------------------------------\nAccess via: " + jsondata["LinkName"] + " \nVia repeater: " + jsondata["LinkCall"] + "\nSlot: " + str(jsondata["Slot"]) + " TG: " + str(jsondata["DestinationID"]) + "\nMaster: " + str(jsondata["Master"]) + "\nRSSI: " + str(jsondata["RSSI"]) + " dBm BER: " + str(round(jsondata["BER"],2)) + "%" + telegram_message = "Callsign: " + jsondata["SourceCall"] + " ID: " + str(jsondata["SourceID"]) + " \nName: " +jsondata["SourceName"] + " \nTalkeralias: " + jsondata["TalkerAlias"] + " \n-----------------------------------\nAccess via: " + jsondata["LinkName"] + " \nVia repeater: " + jsondata["LinkCall"] + "\nSlot: " + str(jsondata["Slot"]) + " TG: " + str(jsondata["DestinationID"]) + "\nMaster: " + str(jsondata["Master"]) + "\nRSSI: " + str(jsondata["RSSI"]) + " dBm BER: " + str(round(jsondata["BER"],2)) + "%" context_id = _as_int(jsondata["ContextID"]) event_slot = _as_int(jsondata["Slot"]) @@ -159,7 +159,7 @@ def on_mqtt(data): print ("matched via Mirror-TG") send_telegram_message(telegram_message) return - + bm_url = 'https://api.brandmeister.network' bm_path = "/lh/socket.io"