I appreciate the replies so far.
With registrations disabled for a day we were able to get our heads above water again.
@RGJ I like your idea of hoops to jump through in order to get added to a group that has posting permissions, that’s something we’re going to explore.
Using the data explorer I’ve been able to identify about 5,000 additional bot accounts that have been flying under the radar so far.
@MikeNolan I’m unsure if I have access to the rails console yet. We’re hosting directly with discourse and I wasn’t a part of the purchasing / on-boarding process, so I’m running this question up the chain trying to determine what access we have.
I imagine I can perform deletions through the API as well? I see that I can easily generate myself API credentials.
Something along the lines of:
import csv
import requests
import time
api_key = 'api_key'
api_username = 'api_username'
base_url = 'https://mydomain.com'
headers = {
'Api-Key': api_key,
'Api-Username': api_username
}
def delete_user(user_id):
delete_url = f'{base_url}/admin/users/{user_id}.json'
response = requests.delete(delete_url, headers=headers)
if response.status_code == 200:
print(f'Successfully deleted user {user_id}')
else:
print(f'Failed to delete user {user_id}. Status code: {response.status_code}, Response: {response.text}')
with open('user_ids_to_delete.csv', 'r') as csvfile:
reader = csv.reader(csvfile)
for row in reader:
user_id = row[0]
try:
delete_user(user_id)
except Exception as e:
print(f'Error occurred while deleting user {user_id}: {e}')
time.sleep(1) # Add a delay to avoid overwhelming the server with requests