mirror of
http://git.nowherejezfoltodf4jiyl6r56jnzintap5vyjlia7fkirfsnfizflqd.onion/nihilist/darknet-lantern.git
synced 2025-05-16 20:26:58 +00:00
modified funs
This commit is contained in:
parent
760ee9d1b9
commit
cd55c1754b
1 changed files with 51 additions and 6 deletions
|
@ -1,6 +1,19 @@
|
|||
from websockets.sync.client import connect
|
||||
import json
|
||||
import random
|
||||
import sys
|
||||
|
||||
sxclink='https://simplex.chat/contact#/?v=2-7&smp=smp%3A%2F%2FBD4qkVq8lJUgjHt0kUaxeQBYsKaxDejeecxm6-2vOwI%3D%40b6geeakpwskovltbesvy3b6ah3ewxfmnhnshojndmpp7wcv2df7bnead.onion%2F4woLIDlpkvXRvZmaAiWA802OwiyxekdJ%23%2F%3Fv%3D1-3%26dh%3DMCowBQYDK2VuAyEAzIAoE-OWDqFJXMqgunIWHPpE_u7e52Wtu8TioPc1QwI%253D&data=%7B%22groupLinkId%22%3A%22Srr1_MNob7WfPTQIY-ug5Q%3D%3D%22%7D'
|
||||
# print(response['resp']['groups'][0][0]['groupProfile']['displayName']) # Name of the group
|
||||
# response['resp']['groups'][0][0]['groupProfile']['description'] group description
|
||||
# response['resp']['groups'][0][0]['chatTs'] time stamp
|
||||
|
||||
|
||||
arguments = sys.argv
|
||||
simplex_link = sys.argv[1]
|
||||
socket = "ws://localhost:3030"
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
@ -8,7 +21,7 @@ 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:
|
||||
with connect(socket) as websocket:
|
||||
query = f"/c incognito {simplex_link}"
|
||||
command = {
|
||||
'corrId': f"id{random.randint(0,999999)}",
|
||||
|
@ -18,15 +31,47 @@ def is_simplex_link_valid(simplex_link: str) -> bool:
|
|||
message = websocket.recv()
|
||||
response = json.loads(message)
|
||||
response_type = response['resp']['type']
|
||||
# print(response)
|
||||
if 'error' in response_type.lower():
|
||||
print(f"Connection to this group {simplex_link} failed. Try again.")
|
||||
return False
|
||||
elif 'deleted' in response_type.lower():
|
||||
print(f"Connection to this group {simplex_link} failed. Try again.")
|
||||
return False
|
||||
|
||||
print('[+] Success!',response_type)
|
||||
return True
|
||||
|
||||
if __name__ == '__main__':
|
||||
sxclink='https://simplex.chat/contact#/?v=2-7&smp=smp%3A%2F%2FBD4qkVq8lJUgjHt0kUaxeQBYsKaxDejeecxm6-2vOwI%3D%40b6geeakpwskovltbesvy3b6ah3ewxfmnhnshojndmpp7wcv2df7bnead.onion%2F4woLIDlpkvXRvZmaAiWA802OwiyxekdJ%23%2F%3Fv%3D1-3%26dh%3DMCowBQYDK2VuAyEAzIAoE-OWDqFJXMqgunIWHPpE_u7e52Wtu8TioPc1QwI%253D&data=%7B%22groupLinkId%22%3A%22Srr1_MNob7WfPTQIY-ug5Q%3D%3D%22%7D'
|
||||
is_simplex_link_valid(sxclink)
|
||||
def check_groups_validity():
|
||||
"""
|
||||
Lists all the group the bot is in.
|
||||
"""
|
||||
with connect(socket) as websocket:
|
||||
query = f"/groups"
|
||||
command = {
|
||||
'corrId': f"id{random.randint(0,999999)}",
|
||||
'cmd': query
|
||||
}
|
||||
websocket.send(json.dumps(command))
|
||||
message = websocket.recv()
|
||||
response = json.loads(message)
|
||||
for i in range(0,len(response['resp']['groups'])):
|
||||
group_name = response['resp']['groups'][i][0]['groupProfile']['displayName']
|
||||
# Description key sometimes are not supplied with .get() KeyError will occur
|
||||
group_descr = response['resp']['groups'][i][0]['groupProfile'].get('description', "No description")
|
||||
last_message_sent = response['resp']['groups'][i][0]['chatTs']
|
||||
# Do something with this data
|
||||
print(f"{group_name}")
|
||||
print(group_descr)
|
||||
print(f"{last_message_sent}\n")
|
||||
# Only date
|
||||
print(last_message_sent.split('T')[0])
|
||||
|
||||
|
||||
|
||||
if len(arguments) == 1:
|
||||
check_groups_validity()
|
||||
elif len(arguments) == 2:
|
||||
if is_simplex_link_valid(simplex_link):
|
||||
check_groups_validity()
|
||||
else:
|
||||
# Later will be changed to usage/hint text
|
||||
raise Exception("Use me properly")
|
Loading…
Add table
Add a link
Reference in a new issue