From 49d2d15493dc537086e19b6b4bbb1d1fd7da454c Mon Sep 17 00:00:00 2001 From: Lynne Date: Tue, 24 Sep 2019 12:05:14 +1000 Subject: [PATCH] nope, you are nitpicking and biased, i win, bye bye --- app/blacklist.json | 17 +++++++++++++++++ app/pages/bot/accounts_add.py | 8 ++++++-- app/pages/bot/create.py | 6 +++++- 3 files changed, 28 insertions(+), 3 deletions(-) create mode 100644 app/blacklist.json diff --git a/app/blacklist.json b/app/blacklist.json new file mode 100644 index 0000000..6f3ac40 --- /dev/null +++ b/app/blacklist.json @@ -0,0 +1,17 @@ +[ + "freespeechextremist.com", + "kiwifarms.cc", + "neckbeard.xyz", + "gameliberty.club", + "freespeech.firedragonstudios.com", + "shitposter.club", + "pawoo.net", + "the.hedgehoghunter.club", + "honey.church", + "anime.website", + "aria.company", + "pl.765racing.com", + "yorishiro.space", + "pl.smuglo.li", + "albin.social" +] diff --git a/app/pages/bot/accounts_add.py b/app/pages/bot/accounts_add.py index 88066c6..7562bb8 100644 --- a/app/pages/bot/accounts_add.py +++ b/app/pages/bot/accounts_add.py @@ -1,7 +1,7 @@ -from flask import session, render_template, request, redirect +from flask import session, render_template, request, redirect, url_for import requests from mastodon import Mastodon -import re +import re, json def bot_accounts_add(mysql, cfg): if request.method == 'POST': @@ -21,6 +21,10 @@ def bot_accounts_add(mysql, cfg): session['instance'] = handle_list[2] session['handle'] = request.form['account'] + if session['instance'] in json.load(open("blacklist.json")): + session['error'] = "Learning from accounts on this instance is not allowed." + return redirect(url_for("render_bot_accounts_add")) + try: r = requests.get("https://{}/api/v1/instance".format(session['instance']), timeout=10) except requests.exceptions.ConnectionError: diff --git a/app/pages/bot/create.py b/app/pages/bot/create.py index 3af7fac..e52b814 100644 --- a/app/pages/bot/create.py +++ b/app/pages/bot/create.py @@ -1,13 +1,17 @@ from flask import request, session, render_template, redirect, url_for import requests from mastodon import Mastodon -import re +import re, json def bot_create(mysql, cfg, scopes, scopes_pleroma): if request.method == 'POST': if session['step'] == 1: # strip leading https://, if provided session['instance'] = re.match(r"^(?:https?:\/\/)?(.*)", request.form['instance']).group(1) + + if session['instance'] in json.load(open("blacklist.json")): + session['error'] = "Creating a bot on this instance is not allowed." + return redirect(url_for("render_bot_create")) # check for mastodon/pleroma try: