this post was submitted on 18 Jul 2023
126 points (100.0% liked)

Lemmy.world Support

3227 readers
30 users here now

Lemmy.world Support

Welcome to the official Lemmy.world Support community! Post your issues or questions about Lemmy.world here.

This community is for issues related to the Lemmy World instance only. For Lemmy software requests or bug reports, please go to the Lemmy github page.

This community is subject to the rules defined here for lemmy.world.

To open a support ticket Static Badge


You can also DM https://lemmy.world/u/lwreport or email report@lemmy.world (PGP Supported) if you need to reach our directly to the admin team.


Follow us for server news ๐Ÿ˜

Outages ๐Ÿ”ฅ

https://status.lemmy.world/



founded 1 year ago
MODERATORS
 

I recently wrote a command-line utility lemmyverse to find communities indexed by Lemmy Explorer. A quick count shows almost 14%(!) of all communities indexed by lemmyverse are junk communities created by a single user @LMAO (reported here):

% lemmyverse . | wc -l
  30376
% lemmyverse enoweiooe | wc -l
   4206

Here's a python script, using no external dependencies, which uses Lemmy's HTTP API to delete all communities that @LMAO moderates:

#!/usr/bin/env python

import json
import urllib.parse
import urllib.request

baseurl = "https://lemmy.world"
username = "admin"
password = "password"

def login(user, passwd):
	url = baseurl+"/api/v3/user/login"
	body = urllib.parse.urlencode({
		"username_or_email": user,
		"password": passwd,
	})
	resp = urllib.request.urlopen(url, body.encode())
	j = json.load(resp)
	return j["jwt"]

def get_user(name):
	query = urllib.parse.urlencode({"username": name})
	resp = urllib.request.urlopen(baseurl+"/api/v3/user?"+query)
	return json.load(resp)

def delete_community(token, id):
	url = baseurl+"/api/v3/community/delete"
	params = {
		"auth": token,
		"community_id": id,
	}
	body = urllib.parse.urlencode(params)
	urllib.request.urlopen(url, body.encode())

token = login(username, password)
user = get_user("LMAO")
for community in user["moderates"]:
	id = community["community"]["id"]
	try:
		delete_community(token, id)
	except Exception as err:
		print("delete community id %d: %s" % (id, err))

Change username and password on lines 8 and 9 to suit.

Hope that helps! :) Thanks for the work you all put in to running this popular instance.

top 17 comments
sorted by: hot top controversial new old
[โ€“] Semi-Hemi-Demigod@kbin.social 39 points 1 year ago (1 children)

Gotta say, I'm loving the transparency in the fediverse

[โ€“] otl@lemmy.sdf.org 3 points 1 year ago

I've managed to create an entire career (almost 10 years in now) out of the transparency in the tech community. Especially in open source. I'm hoping that paying it back like this inspires and provides the same opportunity to others!

[โ€“] frontporchtreat@lemmy.ca 20 points 1 year ago (2 children)

I wonder how long it took to create those communities. one dude wasted so much time just to have all their work wiped out by a script.

[โ€“] HeartyBeast@kbin.social 35 points 1 year ago

I wonder how long it took to create those communities.

.. about as long as it took LMAO to write a script to do it, at a guess.

[โ€“] pyzn@lemmy.world 6 points 1 year ago

Depending on how easy the API is to use, that might be done in a couple of minutes

[โ€“] dilligasatall@lemmy.world 19 points 1 year ago* (last edited 1 year ago) (1 children)

Is it a coincidence or is that the same person that was attacking lemmy a few weeks back for revenge on getting booted?

Edit: yup it is.

[โ€“] cashsky@lemmy.world 5 points 1 year ago

Mental illness is a helluva thing

[โ€“] freamon@feddit.nl 13 points 1 year ago (1 children)

This is great work. I assume LMAO was the same guy as Angled - it'll be an 1.7K communities nixed if the script is used for him (so, 19% of the total!)

[โ€“] youthinkyouknowme@lemmy.dbzer0.com 5 points 1 year ago* (last edited 1 year ago)

Yup, that's the guy, says so in the profile bio.

[โ€“] DrTautology@lemmy.world 12 points 1 year ago

Now that's some beautiful python code. Good work.

[โ€“] SheeEttin@lemmy.world 11 points 1 year ago (1 children)

So we're going to need a captcha on community creation now? It's not the worst idea.

[โ€“] otl@lemmy.sdf.org 1 points 1 year ago

Some per-session rate-limiting by a HTTP reverse proxy could go a long way. Should any user be able to create a community via the API more than, say, once every 10 seconds? I'm not familiar with the rate limiting already built in to the Lemmy server, though.

[โ€“] Blaze@sh.itjust.works 8 points 1 year ago

Great news, thanks for the help!

You should let him get to like 20k communities then run this.

[โ€“] TCGM@lemmy.world 1 points 1 year ago (1 children)

Should probably put in a check for if the community has any content or not tbh. Low chance, but still an edge case.

[โ€“] Kbobabob@lemmy.world 1 points 1 year ago (1 children)

Why does this douche cannon deserve to have a community?

[โ€“] MintyMint@lemmy.world 3 points 1 year ago

The ownership could be changed rather than deleting it entirely in this case.

load more comments
view more: next โ€บ