scan multiple files at once to simplify deletion of multiple rooms, deduplicate the final list of rooms that is generated

This commit is contained in:
PC-Admin 2023-05-15 23:26:23 +08:00
parent fdb1b7ed8f
commit 26920f7325

View File

@ -539,22 +539,27 @@ def shutdown_multiple_rooms():
preset_purge_choice = input("\n Do you want to purge these rooms? (This deletes all the room history from your database.) y/n? ") preset_purge_choice = input("\n Do you want to purge these rooms? (This deletes all the room history from your database.) y/n? ")
preset_block_choice = input("\n Do you want to block these rooms? (This prevents your server users re-entering the room.) y/n? ") preset_block_choice = input("\n Do you want to block these rooms? (This prevents your server users re-entering the room.) y/n? ")
# Get the directory of the current script # Get the directory of the current script
script_dir = os.path.dirname(os.path.realpath(__file__)) script_dir = os.path.dirname(os.path.realpath(__file__))
room_list_data = []
for file in file_list: for file in file_list:
print("Processing file: " + file)
# Change the current working directory # Change the current working directory
os.chdir(script_dir) os.chdir(script_dir)
with open(file, newline='') as f: with open(file, newline='') as f:
reader = csv.reader(f) reader = csv.reader(f)
data = list(reader) data = list(reader)
shutdown_confirmation = input("\n" + str(data) + "\n\nAre you sure you want to shutdown these rooms? y/n? ") room_list_data = room_list_data + data
if shutdown_confirmation.lower() in ["y", "yes"]: # Deduplicate the room_list_data
for room_id in data: room_list_data = [list(item) for item in set(tuple(row) for row in room_list_data)]
shutdown_room(room_id[0], preset_user_ID, preset_new_room_name, preset_message, preset_purge_choice, preset_block_choice) shutdown_confirmation = input("\n" + str(room_list_data) + "\n\nNumber of rooms being shutdown: " + str(len(room_list_data)) + "\n\nAre you sure you want to shutdown these rooms? y/n? ")
time.sleep(10) if shutdown_confirmation.lower() in ["y", "yes"]:
elif shutdown_confirmation.lower() in ["n", "no"]: for room_id in room_list_data:
print("\nSkipping this file...\n") shutdown_room(room_id[0], preset_user_ID, preset_new_room_name, preset_message, preset_purge_choice, preset_block_choice)
else: time.sleep(10)
print("\nInvalid input, skipping this file...\n") elif shutdown_confirmation.lower() in ["n", "no"]:
print("\nSkipping these files...\n")
else:
print("\nInvalid input, skipping these files...\n")
# Example: # Example:
# See shutdown_room() # See shutdown_room()