mirror of
https://github.com/PC-Admin/matrix-moderation-tool.git
synced 2025-04-19 10:22:36 -04:00
Compare commits
No commits in common. "master" and "v2.0.0" have entirely different histories.
@ -5,7 +5,7 @@
|
|||||||
|
|
||||||
This script can automatically load and block/purge abusive rooms from rdlist, making it **very easy** for inexperienced administrators to block this harmful content.
|
This script can automatically load and block/purge abusive rooms from rdlist, making it **very easy** for inexperienced administrators to block this harmful content.
|
||||||
|
|
||||||
If you are running a public server, please dm me at [@PC-Admin:matrix.org](https://matrix.to/#/@PC-Admin:matrix.org) and I can invite you to the 'Legion of Janitors' room.
|
If you are running a public server, please dm me at [@michael:perthchat.org](https://matrix.to/#/@michael:perthchat.org) and I can invite you to the 'Legion of Janitors' room.
|
||||||
|
|
||||||
***
|
***
|
||||||
## Collect User Reports on local users in rdlist rooms
|
## Collect User Reports on local users in rdlist rooms
|
||||||
|
@ -45,24 +45,8 @@ Process Flow:
|
|||||||
|
|
||||||
Example:
|
Example:
|
||||||
```bash
|
```bash
|
||||||
$ python3 moderation_tool.py
|
$ date --date '149 days ago' +%s
|
||||||
|
$ curl -X POST --header "Authorization: Bearer ACCESS_TOKEN" '... Matrix Synapse purge endpoint ...'
|
||||||
101
|
|
||||||
|
|
||||||
Enter the number of days to purge from: 30
|
|
||||||
|
|
||||||
Enter the number of days to purge too: -2
|
|
||||||
{"deleted":0}
|
|
||||||
{"deleted":0}
|
|
||||||
{"deleted":3}
|
|
||||||
{"deleted":360}
|
|
||||||
{"deleted":469}
|
|
||||||
...
|
|
||||||
{"deleted":1020}
|
|
||||||
{"deleted":2440}
|
|
||||||
{"deleted":0}
|
|
||||||
{"deleted":0}
|
|
||||||
Done! :)
|
|
||||||
```
|
```
|
||||||
|
|
||||||
102) **Prepare Database for Copying Events of Multiple Rooms**
|
102) **Prepare Database for Copying Events of Multiple Rooms**
|
||||||
|
@ -80,10 +80,9 @@ while pass_token == False:
|
|||||||
print("103) Show last 10 reported events.\t\t\t\t#### Report Generation ####")
|
print("103) Show last 10 reported events.\t\t\t\t#### Report Generation ####")
|
||||||
print("104) Get all reported events.\t\t\t\t\t150) Generate user report.")
|
print("104) Get all reported events.\t\t\t\t\t150) Generate user report.")
|
||||||
print("105) Get details of a reported event.\t\t\t\t151) Lookup homeserver admin contact details.")
|
print("105) Get details of a reported event.\t\t\t\t151) Lookup homeserver admin contact details.")
|
||||||
print("106) Send a server notice.\t\t\t\t\t152) Send a test email (to yourself).")
|
print("\t\t\t\t\t\t\t\t152) Send a test email (to yourself).")
|
||||||
print("\t\t\t\t\t\t\t\t\t153) Send a test Matrix message (to yourself).")
|
print("#### rdlist - General ####\t\t\t\t\t153) Send a test Matrix message (to yourself).")
|
||||||
print("\n#### rdlist - General ####\t\t\t\t\t154) Send test incident reports (to yourself).")
|
print("120) Block all rooms with specific rdlist tags.\t\t\t154) Send test incident reports (to yourself).")
|
||||||
print("120) Block all rooms with specific rdlist tags.")
|
|
||||||
print("121) Get rdlist tags for a room.")
|
print("121) Get rdlist tags for a room.")
|
||||||
print("\n#### rdlist - Recommended Tags ####")
|
print("\n#### rdlist - Recommended Tags ####")
|
||||||
print("For rdlist rooms with recommended tags, the following actions are available:")
|
print("For rdlist rooms with recommended tags, the following actions are available:")
|
||||||
@ -213,9 +212,6 @@ while pass_token == False:
|
|||||||
elif menu_input == "105":
|
elif menu_input == "105":
|
||||||
report_details = server_commands.get_event_report_details()
|
report_details = server_commands.get_event_report_details()
|
||||||
print(json.dumps(report_details, indent=4, sort_keys=True))
|
print(json.dumps(report_details, indent=4, sort_keys=True))
|
||||||
elif menu_input == "106":
|
|
||||||
server_commands.send_server_notice()
|
|
||||||
print("\nServer notice sent.\n")
|
|
||||||
elif menu_input == "120":
|
elif menu_input == "120":
|
||||||
rdlist_commands.block_all_rooms_with_rdlist_tags(False,'','','')
|
rdlist_commands.block_all_rooms_with_rdlist_tags(False,'','','')
|
||||||
elif menu_input == "121":
|
elif menu_input == "121":
|
||||||
|
@ -203,64 +203,3 @@ def get_event_report_details(preset_report_id=''):
|
|||||||
else:
|
else:
|
||||||
print(f"Error fetching event report details: {response.status_code}, {response.text}")
|
print(f"Error fetching event report details: {response.status_code}, {response.text}")
|
||||||
return None
|
return None
|
||||||
|
|
||||||
def send_server_notice(preset_user_id='', preset_message='', txnId=None, event_type="m.room.message", state_key=None):
|
|
||||||
"""
|
|
||||||
Sends a server notice to a given user.
|
|
||||||
|
|
||||||
Args:
|
|
||||||
- user_id (str): The Matrix ID of the user to send the notice to, e.g. "@target_user:server_name".
|
|
||||||
- message (str): The message to be sent as a notice.
|
|
||||||
- txnId (str, optional): A unique transaction ID. If provided, retransmissions with the same txnId will be ignored.
|
|
||||||
- event_type (str, optional): The type of event. Defaults to "m.room.message".
|
|
||||||
- state_key (str, optional): Setting this will result in a state event being sent.
|
|
||||||
|
|
||||||
Returns:
|
|
||||||
- dict: A dictionary containing the response from the server.
|
|
||||||
"""
|
|
||||||
|
|
||||||
# Take user_id from user if not provided
|
|
||||||
if preset_user_id == '':
|
|
||||||
user_id = input("\nEnter the user_id of the user you would like to send the server notice to: ")
|
|
||||||
elif preset_user_id != '':
|
|
||||||
user_id = preset_user_id
|
|
||||||
|
|
||||||
# Take message from user if not provided
|
|
||||||
if preset_message == '':
|
|
||||||
message = input("\nEnter the message you would like to send to the user: ")
|
|
||||||
elif preset_message != '':
|
|
||||||
message = preset_message
|
|
||||||
|
|
||||||
# Construct the URL based on whether a txnId is provided
|
|
||||||
if txnId:
|
|
||||||
url = f"https://{hardcoded_variables.homeserver_url}/_synapse/admin/v1/send_server_notice/{txnId}"
|
|
||||||
else:
|
|
||||||
url = f"https://{hardcoded_variables.homeserver_url}/_synapse/admin/v1/send_server_notice"
|
|
||||||
|
|
||||||
headers = {
|
|
||||||
"Content-Type": "application/json",
|
|
||||||
"Authorization": f"Bearer {hardcoded_variables.access_token}"
|
|
||||||
}
|
|
||||||
|
|
||||||
# Construct the request body
|
|
||||||
data = {
|
|
||||||
"user_id": user_id,
|
|
||||||
"content": {
|
|
||||||
"msgtype": "m.text",
|
|
||||||
"body": message
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
if event_type:
|
|
||||||
data["type"] = event_type
|
|
||||||
if state_key:
|
|
||||||
data["state_key"] = state_key
|
|
||||||
|
|
||||||
# Send the request
|
|
||||||
response = requests.put(url, headers=headers, json=data) if txnId else requests.post(url, headers=headers, json=data)
|
|
||||||
|
|
||||||
if response.status_code == 200:
|
|
||||||
return response.json()
|
|
||||||
else:
|
|
||||||
print(f"Error sending server notice: {response.status_code}, {response.text}")
|
|
||||||
return None
|
|
@ -62,7 +62,7 @@ def deactivate_multiple_accounts():
|
|||||||
return
|
return
|
||||||
#print(len(data[0]))
|
#print(len(data[0]))
|
||||||
#print(data[0][0])
|
#print(data[0][0])
|
||||||
if delete_confirmation in ["y", "Y", "yes", "Yes", "YES"]:
|
if delete_confirmation ["y", "Y", "yes", "Yes", "YES"]:
|
||||||
x = 0
|
x = 0
|
||||||
while x <= (len(data) - 1):
|
while x <= (len(data) - 1):
|
||||||
#print(data[0][x])
|
#print(data[0][x])
|
||||||
|
Loading…
x
Reference in New Issue
Block a user