mirror of
https://github.com/PC-Admin/matrix-moderation-tool.git
synced 2024-12-28 02:40:29 -05:00
add new find_account_with_threepid function. fix new dynamic rdlist location sections i missed.
This commit is contained in:
parent
2f186dffc9
commit
a38e042b33
@ -56,6 +56,7 @@ while pass_token == False:
|
|||||||
print("18) Delete rate limit of a user account.\t67) Get blocked status for room.")
|
print("18) Delete rate limit of a user account.\t67) Get blocked status for room.")
|
||||||
print("19) Check if user account exists.\t\t68) Block a room.")
|
print("19) Check if user account exists.\t\t68) Block a room.")
|
||||||
print("20) Shadow ban a user.\t\t\t\t69) Unblock a room.")
|
print("20) Shadow ban a user.\t\t\t\t69) Unblock a room.")
|
||||||
|
print("21) Find a user by their 3PID.")
|
||||||
print("\n#### Server Commands ####\t\t\t\t\t#### Report Generation ####")
|
print("\n#### Server Commands ####\t\t\t\t\t#### Report Generation ####")
|
||||||
print("100) Delete and block a specific media.\t\t\t\t150) Generate user report.")
|
print("100) Delete and block a specific media.\t\t\t\t150) Generate user report.")
|
||||||
print("101) Purge remote media repository up to a certain date.\t151) Lookup homeserver admin contact details.")
|
print("101) Purge remote media repository up to a certain date.\t151) Lookup homeserver admin contact details.")
|
||||||
@ -129,6 +130,9 @@ while pass_token == False:
|
|||||||
elif menu_input == "20":
|
elif menu_input == "20":
|
||||||
shadow_ban_dict = user_commands.shadow_ban_account('')
|
shadow_ban_dict = user_commands.shadow_ban_account('')
|
||||||
print(json.dumps(shadow_ban_dict, indent=4, sort_keys=True))
|
print(json.dumps(shadow_ban_dict, indent=4, sort_keys=True))
|
||||||
|
elif menu_input == "21":
|
||||||
|
user_dict = user_commands.find_account_with_threepid()
|
||||||
|
print(f"\n{json.dumps(user_dict, indent=4, sort_keys=True)}")
|
||||||
elif menu_input == "50":
|
elif menu_input == "50":
|
||||||
room_details_dict = room_commands.get_room_details('')
|
room_details_dict = room_commands.get_room_details('')
|
||||||
print(json.dumps(room_details_dict, indent=4, sort_keys=True))
|
print(json.dumps(room_details_dict, indent=4, sort_keys=True))
|
||||||
|
@ -43,8 +43,9 @@ def get_rdlist_tags(preset_internal_ID):
|
|||||||
# Git clone the rdlist repo to specified directory
|
# Git clone the rdlist repo to specified directory
|
||||||
sync_rdlist()
|
sync_rdlist()
|
||||||
|
|
||||||
# Load the summaries JSON file
|
# Expand the user in the path and load the summaries JSON file
|
||||||
summaries_path = os.path.join("rdlist", "dist", "summaries.json")
|
summaries_dir = os.path.expanduser(hardcoded_variables.rdlist_dir)
|
||||||
|
summaries_path = os.path.join(summaries_dir, "dist", "summaries.json")
|
||||||
with open(summaries_path, 'r') as file:
|
with open(summaries_path, 'r') as file:
|
||||||
data = json.load(file)
|
data = json.load(file)
|
||||||
|
|
||||||
|
@ -537,3 +537,28 @@ def shadow_ban_account(preset_username):
|
|||||||
|
|
||||||
# Example:
|
# Example:
|
||||||
# curl -XPOST -H "Content-Type: application/json" 'https://matrix.perthchat.org/_synapse/admin/v1/users/@dogpoo:perthchat.org/shadow_ban?access_token=ACCESS_TOKEN'
|
# curl -XPOST -H "Content-Type: application/json" 'https://matrix.perthchat.org/_synapse/admin/v1/users/@dogpoo:perthchat.org/shadow_ban?access_token=ACCESS_TOKEN'
|
||||||
|
|
||||||
|
def find_account_with_threepid(medium="", address=""):
|
||||||
|
# prompt user to enter values if they're not provided
|
||||||
|
if medium == "":
|
||||||
|
print("\nPlease enter the medium (either 'email' or 'msisdn' for mobile number): ")
|
||||||
|
medium = input()
|
||||||
|
if address == "":
|
||||||
|
print("\nPlease enter the address (the email or mobile number): ")
|
||||||
|
address = input()
|
||||||
|
|
||||||
|
url = f"https://{hardcoded_variables.homeserver_url}/_synapse/admin/v1/threepid/{medium}/users/{address}?access_token={hardcoded_variables.access_token}"
|
||||||
|
|
||||||
|
response = requests.get(url, verify=True)
|
||||||
|
|
||||||
|
if response.status_code == 200:
|
||||||
|
# User exists
|
||||||
|
return response.json()
|
||||||
|
elif response.status_code == 404:
|
||||||
|
# User not found
|
||||||
|
return {"errcode":"M_NOT_FOUND", "error":"User not found"}
|
||||||
|
else:
|
||||||
|
print(f"Error querying account: {response.status_code}, {response.text}")
|
||||||
|
|
||||||
|
# Example:
|
||||||
|
# $ curl -X GET 'https://matrix.perthchat.org/_synapse/admin/v1/threepid/email/users/dogpoo@protonmail.com?access_token=ACCESS_TOKEN'
|
||||||
|
Loading…
Reference in New Issue
Block a user