Last active
November 16, 2022 14:07
-
-
Save promovicz/d7759720be0c582ad6539c28f59115ad to your computer and use it in GitHub Desktop.
Mastodon: script that unsuspends all users given on the command line
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/python3 | |
| # spontaneously smashed together by @promovicz@chaos.social | |
| # in response to a question by @TheGibson@hackers.town | |
| from argparse import ArgumentParser | |
| from mastodon import Mastodon | |
| ap = ArgumentParser('unsuspend') | |
| ap.add_argument('-i',type=str,help='instance',default='chaos.social') | |
| ap.add_argument('-t',type=str,help='token (string or file)',default='secret.key') | |
| ap.add_argument('u',type=str,nargs='*',help='users') | |
| a = ap.parse_args() | |
| m = Mastodon(api_base_url=a.i,access_token=a.t) | |
| users = [] | |
| for uid in a.u: | |
| results = m.account_search(uid) | |
| if len(results) == 0: | |
| raise Exception('User %s not found' % uid) | |
| elif len(results) > 1: | |
| raise Exception('User %s is ambiguous' % uid) | |
| users += results | |
| for user in users: | |
| print("unsuspending %d" % user.id) | |
| m.admin_account_unsuspend(user) |
Author
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
This script allows unsuspending users in batch on the command-line.
It will only accept locally unambiguous user names, so be sure to provide the whole identifier.
Admin privileges are obviously required.