mastoes-bots/moderabot.py

26 lines
991 B
Python
Raw Permalink Normal View History

2023-04-23 11:47:16 +00:00
from common import get_api
from common import list_read
from common import list_append
bot_name = 'moderabot'
api = get_api('masto.es', bot_name)
2023-09-19 15:37:12 +00:00
notifications = api.notifications(types=["admin.sign_up"])
2023-04-23 11:47:16 +00:00
# Vietnamese accounts
2023-09-19 15:37:12 +00:00
forbidden_words = list_read('moderabot_forbidden_words')
2023-04-23 11:47:16 +00:00
for n in notifications:
2023-09-19 15:37:12 +00:00
for word in forbidden_words:
if word in n['account']['note']:
api.admin_account_moderate(n['account']['id'], action='suspend', send_email_notification=False)
list_append(bot_name + "_banned", n['account']['acct'])
2023-11-13 17:05:28 +00:00
print("banned: " + n['account']['acct'])
2023-04-23 11:47:16 +00:00
# Known spam accounts with similar names
names = list_read('moderabot_forbidden_names')
for name in names:
result = api.search_v2(name, result_type='accounts', resolve=False)
for account in result['accounts']:
api.admin_account_moderate(account['id'], action='suspend', send_email_notification=False)
list_append(bot_name + "_banned", account['acct'])