2023-07-08 05:55:48 -04:00
import user_commands
import room_commands
import server_commands
import rdlist_commands
import hardcoded_variables
# check if homeserver url is hard coded, if not set it
if hardcoded_variables . homeserver_url == " matrix.example.org " :
homeserver_url = input ( " What is the URL of your server? Eg: matrix.example.org " )
# check if base url is hard coded, if not set it
if hardcoded_variables . base_url == " example.org " :
base_url = input ( " What is the URL of your server? Eg: example.org " )
# check if access token is hard coded, if not set it
length_access_token = len ( hardcoded_variables . access_token )
if length_access_token == 0 :
access_token = input ( " Please enter access token for server admin account: " )
# loop menu for various moderation actions
pass_token = False
while pass_token == False :
2023-07-14 11:18:31 -04:00
menu_input = input ( ' \n Please select one of the following options: \n #### User Account Commands #### \n 1) Deactivate a user account. \n 2) Deactivate multiple user accounts. \n 3) Create a user account. \n 4) Create multiple user accounts. \n 5) Reset a users password. \n 6) Whois user account. \n 7) Whois multiple user accounts. \n 8) Query user account. \n 9) Query multiple user accounts. \n 10) List room memberships of user. \n 11) Promote a user to server admin. \n 12) List all user accounts. \n 13) Quarantine all media a users uploaded. \n #### Room Commands #### \n 14) List details of a room. \n 15) Export the state events of a target room. \n 16) List rooms in public directory. \n 17) Remove a room from the public directory. \n 18) Remove multiple rooms from the public directory. \n 19) Redact a room event. (Like abusive avatars or display names.) \n 20) List/Download all media in a room. \n 21) Download media from multiple rooms. \n 22) Quarantine all media in a room. \n 23) Shutdown a room. \n 24) Shutdown multiple rooms. \n 25) Delete a room. \n 26) Delete multiple rooms. \n 27) Purge the event history of a room to a specific timestamp. \n 28) Purge the event history of multiple rooms to a specific timestamp. \n #### Server Commands #### \n 29) Delete and block a specific media. (Like an abusive avatar.) \n 30) Purge remote media repository up to a certain date. \n 31) Prepare database for copying events of multiple rooms. \n #### rdlist #### \n 32) Block all rooms with specific rdlist tags. \n 34) Block all rooms with recommended rdlist tags. \n #### ipinfo.io #### \n 40) Analyse a users country of origin. \n 41) Analyse multiple users country of origin. \n ( \' q \' or \' e \' ) Exit. \n \n ' )
2023-07-08 05:55:48 -04:00
if menu_input == " 1 " :
user_commands . deactivate_account ( ' ' )
elif menu_input == " 2 " :
2023-07-09 16:48:14 -04:00
user_commands . deactivate_multiple_accounts ( )
2023-07-08 05:55:48 -04:00
elif menu_input == " 3 " :
2023-07-09 16:48:14 -04:00
user_commands . create_account ( ' ' , ' ' )
2023-07-08 05:55:48 -04:00
elif menu_input == " 4 " :
2023-07-09 16:48:14 -04:00
user_commands . create_multiple_accounts ( )
2023-07-14 11:18:31 -04:00
elif menu_input == " 5 " :
2023-07-09 16:48:14 -04:00
user_commands . reset_password ( ' ' , ' ' )
2023-07-08 05:55:48 -04:00
elif menu_input == " 6 " :
2023-07-09 16:48:14 -04:00
user_commands . whois_account ( ' ' )
2023-07-08 05:55:48 -04:00
elif menu_input == " 7 " :
2023-07-09 16:48:14 -04:00
user_commands . whois_multiple_accounts ( )
2023-07-08 05:55:48 -04:00
elif menu_input == " 8 " :
2023-07-14 11:18:31 -04:00
user_commands . query_account ( )
2023-07-08 05:55:48 -04:00
elif menu_input == " 9 " :
2023-07-14 11:18:31 -04:00
user_commands . query_multiple_accounts ( )
2023-07-08 05:55:48 -04:00
elif menu_input == " 10 " :
2023-07-14 11:18:31 -04:00
user_commands . list_joined_rooms ( ' ' )
2023-07-08 05:55:48 -04:00
elif menu_input == " 11 " :
2023-07-14 11:18:31 -04:00
user_commands . set_user_server_admin ( ' ' )
2023-07-08 05:55:48 -04:00
elif menu_input == " 12 " :
2023-07-14 11:18:31 -04:00
user_commands . list_accounts ( )
2023-07-08 05:55:48 -04:00
elif menu_input == " 13 " :
2023-07-14 11:18:31 -04:00
user_commands . quarantine_users_media ( )
2023-07-08 05:55:48 -04:00
elif menu_input == " 14 " :
2023-07-14 11:18:31 -04:00
room_commands . list_room_details ( ' ' )
2023-07-08 05:55:48 -04:00
elif menu_input == " 15 " :
2023-07-14 11:18:31 -04:00
room_commands . export_room_state ( ' ' )
2023-07-08 05:55:48 -04:00
elif menu_input == " 16 " :
2023-07-14 11:18:31 -04:00
room_commands . list_directory_rooms ( )
2023-07-08 05:55:48 -04:00
elif menu_input == " 17 " :
2023-07-14 11:18:31 -04:00
room_commands . remove_room_from_directory ( ' ' )
2023-07-08 05:55:48 -04:00
elif menu_input == " 18 " :
2023-07-14 11:18:31 -04:00
room_commands . remove_multiple_rooms_from_directory ( )
2023-07-08 05:55:48 -04:00
elif menu_input == " 19 " :
2023-07-14 11:18:31 -04:00
room_commands . redact_room_event ( )
2023-07-08 05:55:48 -04:00
elif menu_input == " 20 " :
2023-07-14 11:18:31 -04:00
room_commands . list_and_download_media_in_room ( ' ' , ' ' , ' ' , ' ./ ' )
2023-07-08 05:55:48 -04:00
elif menu_input == " 21 " :
2023-07-14 11:18:31 -04:00
room_commands . download_media_from_multiple_rooms ( )
2023-07-08 05:55:48 -04:00
elif menu_input == " 22 " :
2023-07-14 11:18:31 -04:00
room_commands . quarantine_media_in_room ( )
2023-07-08 05:55:48 -04:00
elif menu_input == " 23 " :
2023-07-14 11:18:31 -04:00
room_commands . shutdown_room ( ' ' , ' ' , ' ' , ' ' , ' ' , ' ' )
2023-07-08 05:55:48 -04:00
elif menu_input == " 24 " :
2023-07-14 11:18:31 -04:00
room_commands . shutdown_multiple_rooms ( )
2023-07-08 05:55:48 -04:00
elif menu_input == " 25 " :
2023-07-14 11:18:31 -04:00
room_commands . delete_room ( ' ' )
2023-07-08 05:55:48 -04:00
elif menu_input == " 26 " :
2023-07-14 11:18:31 -04:00
room_commands . delete_multiple_rooms ( )
2023-07-08 05:55:48 -04:00
elif menu_input == " 27 " :
2023-07-14 11:18:31 -04:00
room_commands . purge_room_to_timestamp ( ' ' , ' ' )
2023-07-08 05:55:48 -04:00
elif menu_input == " 28 " :
2023-07-14 11:18:31 -04:00
room_commands . purge_multiple_rooms_to_timestamp ( )
2023-07-08 05:55:48 -04:00
elif menu_input == " 29 " :
2023-07-14 11:18:31 -04:00
server_commands . delete_block_media ( )
2023-07-08 05:55:48 -04:00
elif menu_input == " 30 " :
2023-07-14 11:18:31 -04:00
server_commands . purge_remote_media_repo ( )
elif menu_input == " 31 " :
server_commands . prepare_database_copy_of_multiple_rooms ( )
elif menu_input == " 32 " :
2023-07-08 05:55:48 -04:00
rdlist_commands . block_all_rooms_with_rdlist_tags ( False , ' ' , ' ' , ' ' , ' ' , ' ' )
elif menu_input == " 34 " :
rdlist_commands . block_recommended_rdlist_tags ( )
2023-07-14 11:18:31 -04:00
elif menu_input == " 40 " :
user_commands . analyse_account_ip ( ' ' )
elif menu_input == " 41 " :
user_commands . analyse_multiple_account_ips ( )
2023-07-08 05:55:48 -04:00
elif menu_input == " q " or menu_input == " Q " or menu_input == " e " or menu_input == " E " :
print ( " \n Exiting... \n " )
pass_token = True
else :
2023-07-14 16:55:59 -04:00
print ( " \n Incorrect input detected, please select a number from 1 to 41! \n " )
2023-07-08 05:55:48 -04:00