Last active
September 21, 2022 17:42
-
-
Save nukeador/e774e003de0593e5ab72ced49d0ea59f to your computer and use it in GitHub Desktop.
Bulk-banning a user on multiple rooms from a text file using matrix-commander
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
#!/usr/bin/env python3 | |
""" | |
Usage bulk-ban.py room-list.txt @userid:server.com | |
Please set the notice_room variable to the room your want to notify when | |
banning an user. | |
You will need matrix-commander installed configured before | |
https://github.com/8go/matrix-commander/ | |
""" | |
import subprocess, sys | |
# Setup using a public or private room you want to notify about the ban | |
# set notification = False for no notifications | |
notifications = True | |
notice_room = '#yourroom:server.tld' | |
file_path = sys.argv[1] | |
user = sys.argv[2] | |
with open(file_path) as file: | |
for line in file: | |
room = line.replace('\n','') | |
subprocess.run(['matrix-commander', '--room-ban', room, '--user', user]) | |
if notifications: | |
# Notice to the control room about the ban | |
notice_msg = '⚠️ Notice: ' + user + ' banned in all #openmapping-humanitarian-general:matrix.org rooms' | |
subprocess.run(['matrix-commander', '-m', notice_msg, '--room', notice_room]) |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment