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.

    • Oliver Lowe@lemmy.sdf.orgOP
      link
      fedilink
      arrow-up
      12
      ·
      11 months 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!

      • AnarchistArtificer@slrpnk.net
        link
        fedilink
        arrow-up
        5
        ·
        11 months ago

        Stuff like this makes me really happy.

        Sometimes, people call me naïve or overly optimistic for being hopeful for change, but I’m not expecting us to be able to fix all the problems; I’m excited because we’re taking steps towards transmuting our current set of problems into a different set that will put us closer to a hypothetical ideal world. I can’t imagine what this ideal world would look like, but I don’t need to as long as I maintain a sense of “towards” and be clear on what values are worth striving towards.

        It’s helpful for my morale to remember that we’re not building an ideal world from scratch, we’re iterating upon what already exists. This means that people like you exist, and the domain knowledge you possess is far from a new thing, but will continue to grow and adapt as the rest of the world changes around it. There’s a lot of smart and wise people working on making things better :)

        (And I include myself in the “smart” category at least, it’s just that protein structure isn’t too relevant to social media (well… aside from the game Fold-it… or the fact that Meta and Google research is very relevant to BioInformatics ¯\(ツ)/¯ )

        • Oliver Lowe@lemmy.sdf.orgOP
          link
          fedilink
          arrow-up
          3
          ·
          11 months ago

          This comment really spoke to me; thanks for replying.

          we’re iterating upon what already exists

          Absolutely. Do I think Lemmy, Python, ActivityPub or any of this web stuff is ideal? Personally: no. But that ability to make a little gesture like this, maybe have it accepted (or not!), and make it all a bit easier to work is worth any sort of personal compromise and frustration I feel. That optimism that you mention is really powerful.

  • Jay@lemmy.world
    link
    fedilink
    arrow-up
    50
    ·
    edit-2
    1 year ago

    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.

  • freamon
    link
    fedilink
    English
    arrow-up
    31
    ·
    1 year ago

    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!)

  • frontporchtreat@lemmy.ca
    cake
    link
    fedilink
    arrow-up
    29
    arrow-down
    1
    ·
    1 year ago

    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
      link
      fedilink
      arrow-up
      41
      ·
      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
      link
      fedilink
      English
      arrow-up
      13
      ·
      1 year ago

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

    • Oliver Lowe@lemmy.sdf.orgOP
      link
      fedilink
      arrow-up
      2
      ·
      11 months 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.

  • TCGM@lemmy.world
    link
    fedilink
    arrow-up
    7
    arrow-down
    1
    ·
    1 year ago

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