darknet-lantern/simpleP/main.py
SovereigntyIsNotFreedom cec230796c added readme
2025-03-03 18:40:15 +00:00

26 lines
822 B
Python

from websockets.sync.client import connect
import json
import random
def is_simplex_link_valid(simplex_link: str) -> bool:
"""
Connects to the group using the `simplex_link`. If the response contains error False will be returned else True.
"""
with connect("ws://localhost:3030") as websocket:
query = f"/c {simplex_link}"
command = {
'corrId': f"id{random.randint(0,999999)}",
'cmd': query,
}
websocket.send(json.dumps(command))
message = websocket.recv()
response = json.loads(message)
repsonse_type = response['resp']['type']
# print(response)
if 'error' in repsonse_type.lower():
return False
elif 'deleted' in repsonse_type.lower():
return False
return True