add function to return rdlist tags associated with a room

This commit is contained in:
PC-Admin 2023-07-25 23:14:53 +08:00
parent b0b812f3af
commit ad87420546
2 changed files with 27 additions and 0 deletions

View File

@ -62,6 +62,7 @@ while pass_token == False:
print("#### rdlist ####\t\t\t\t\t\t74) Send test incident reports to yourself.") print("#### rdlist ####\t\t\t\t\t\t74) Send test incident reports to yourself.")
print("50) Block all rooms with specific rdlist tags.") print("50) Block all rooms with specific rdlist tags.")
print("51) Block all rooms with recommended rdlist tags.") print("51) Block all rooms with recommended rdlist tags.")
print("52) Get rdlist tags for a room.")
print("\n#### ipinfo.io ####") print("\n#### ipinfo.io ####")
print("60) Analyse a users country of origin.") print("60) Analyse a users country of origin.")
print("61) Analyse multiple users country of origin.") print("61) Analyse multiple users country of origin.")
@ -158,6 +159,9 @@ while pass_token == False:
rdlist_commands.block_all_rooms_with_rdlist_tags(False,'','','') rdlist_commands.block_all_rooms_with_rdlist_tags(False,'','','')
elif menu_input == "51": elif menu_input == "51":
rdlist_commands.block_recommended_rdlist_tags() rdlist_commands.block_recommended_rdlist_tags()
elif menu_input == "52":
rdlist_tags = rdlist_commands.get_rdlist_tags('')
print(json.dumps(rdlist_tags, indent=4, sort_keys=True))
elif menu_input == "60": elif menu_input == "60":
ipinfo_commands.analyse_account_ip('') ipinfo_commands.analyse_account_ip('')
elif menu_input == "61": elif menu_input == "61":

View File

@ -77,6 +77,29 @@ def sync_rdlist():
# # } # # }
# # } # # }
# A function to return the rdlist tags associated with a room
def get_rdlist_tags(preset_internal_ID):
if preset_internal_ID == '':
internal_ID = input("\nEnter the internal id of the room you wish to query (Example: !OLkDvaYjpNrvmwnwdj:matrix.org): ")
elif preset_internal_ID != '':
internal_ID = preset_internal_ID
# Git clone the rdlist repo to ./rdlist/
sync_rdlist()
# Load the summaries JSON file
summaries_path = os.path.join("rdlist", "dist", "summaries.json")
with open(summaries_path, 'r') as file:
data = json.load(file)
# Find the room with the given id and return its tags
for item in data:
if 'room' in item and 'room_id' in item['room'] and item['room']['room_id'] == internal_ID:
if 'report_info' in item and 'tags' in item['report_info']:
return item['report_info']['tags']
return None
def block_all_rooms_with_rdlist_tags(rdlist_use_recommended,preset_user_ID,preset_new_room_name,preset_message): def block_all_rooms_with_rdlist_tags(rdlist_use_recommended,preset_user_ID,preset_new_room_name,preset_message):
# Git clone the rdlist repo to ./rdlist/ # Git clone the rdlist repo to ./rdlist/
sync_rdlist() sync_rdlist()