mirror of
http://git.nowherejezfoltodf4jiyl6r56jnzintap5vyjlia7fkirfsnfizflqd.onion/nihilist/darknet-lantern.git
synced 2025-05-17 04:36:57 +00:00
26 lines
822 B
Python
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
|