I recently migrated away from t2bot.io's discord<->matrix bridging (to a self-hosted one), which after figuring out all the nice synapse and systemd related pecularities left me with one last cleanup of all the @_discord_ID:t2bot.io
ghosts haunting my previously bridged matrix rooms.
In order to automate the process I wrote two scripts that I want to share; the main one is purge_t2bot_ghosts.sh
which you provide with a room ID (the internal ones starting with a !
and looking like a random-generated password), and an access token with admin priviledges; also note that due to the _synapse
API these scripts are using, they must be executed on localhost
(this might be rewritten to be used from anywhere, idk). You can optionally specify a delay in seconds between kicks to not trigger the built-in rate limit, but I've found 4 seconds (the default) to be exactly right.
Tip: Do this before setting up any replacement bridges to avoid status spams on the Discord site.
purge_t2bot_ghosts.sh
(requires jq):