Spaces:
Runtime error
Runtime error
Update app.py
Browse files
app.py
CHANGED
|
@@ -1,53 +1,30 @@
|
|
| 1 |
from mastodon import Mastodon # Mastodon.py
|
| 2 |
|
| 3 |
-
list_of_servers = [
|
| 4 |
-
|
| 5 |
-
|
| 6 |
-
|
| 7 |
-
|
| 8 |
-
|
| 9 |
-
|
| 10 |
-
|
| 11 |
-
|
| 12 |
-
|
| 13 |
-
|
| 14 |
-
|
| 15 |
-
|
| 16 |
-
|
| 17 |
-
|
| 18 |
-
|
| 19 |
-
|
| 20 |
-
|
| 21 |
-
|
| 22 |
-
|
| 23 |
-
|
| 24 |
-
|
| 25 |
-
|
| 26 |
-
|
| 27 |
-
|
| 28 |
-
"ioc.exchange",
|
| 29 |
-
"qoto.org",
|
| 30 |
-
"glasgow.social",
|
| 31 |
-
"primarycare.app",
|
| 32 |
-
"mindly.social",
|
| 33 |
-
"mstdn.party",
|
| 34 |
-
"universeodon.com",
|
| 35 |
-
"learningdisability.social",
|
| 36 |
-
"ravenation.club",
|
| 37 |
-
"home.social",
|
| 38 |
-
"mastodon.ie",
|
| 39 |
-
"techhub.social",
|
| 40 |
-
"mastodon.scot",
|
| 41 |
-
"sfba.social",
|
| 42 |
-
"mastodon.sdf.org",
|
| 43 |
-
"fosstodon.org",
|
| 44 |
-
"mastodon.lol",
|
| 45 |
-
"mastodonapp.uk",
|
| 46 |
-
"mstdn.social",
|
| 47 |
-
"mas.to",
|
| 48 |
-
"newsie.social",
|
| 49 |
-
"social.bau-ha.us",
|
| 50 |
-
"infosec.exchange"]
|
| 51 |
|
| 52 |
# A HTML blob of text used to define the 'login in with' button
|
| 53 |
auth_button_text = '''<a href="{}"><button class="w3-button w3-light-grey w3-padding-large w3-section " onclick="document.getElementById('download').style.display='block'">
|
|
@@ -61,24 +38,32 @@ def client_log_in():
|
|
| 61 |
Generates an authenticated Masterdon client for the admin user. Used for retireving the target website URL
|
| 62 |
'''
|
| 63 |
|
| 64 |
-
|
| 65 |
-
|
| 66 |
-
|
| 67 |
-
|
| 68 |
-
|
| 69 |
-
|
| 70 |
-
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 71 |
|
| 72 |
mastodon = Mastodon(
|
| 73 |
-
client_id=
|
| 74 |
-
api_base_url='https://
|
| 75 |
)
|
| 76 |
|
| 77 |
-
mastodon.log_in(
|
| 78 |
-
|
| 79 |
-
|
| 80 |
-
|
| 81 |
-
redirect_uri="https://user1342-ivory.hf.space/",
|
| 82 |
)
|
| 83 |
|
| 84 |
return mastodon
|
|
@@ -100,9 +85,17 @@ def login_from_code(code):
|
|
| 100 |
:param code: The code which will authenticate the user/ WatchTower.
|
| 101 |
:return: A masterdon client instance signed in as the user.
|
| 102 |
'''
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 103 |
mastodon = Mastodon(
|
| 104 |
-
client_id=
|
| 105 |
-
api_base_url='https://
|
| 106 |
)
|
| 107 |
|
| 108 |
mastodon.log_in(code=code,
|
|
@@ -225,8 +218,7 @@ def block_users(client, threshold, dataset):
|
|
| 225 |
:return: The number of blocked users.
|
| 226 |
'''
|
| 227 |
num_users_blocked = 0
|
| 228 |
-
|
| 229 |
-
print("Testing dropdown value {}".format(slider_choice))
|
| 230 |
|
| 231 |
for filename in os.listdir("users"):
|
| 232 |
filename = os.path.join("users", filename)
|
|
|
|
| 1 |
from mastodon import Mastodon # Mastodon.py
|
| 2 |
|
| 3 |
+
list_of_servers = ['peoplemaking.games',
|
| 4 |
+
'ani.work',
|
| 5 |
+
'libretooth.gr',
|
| 6 |
+
'tilde.zone',
|
| 7 |
+
'hostux.social',
|
| 8 |
+
'social.linux.pizza',
|
| 9 |
+
'nerdculture.de',
|
| 10 |
+
'toot.wales',
|
| 11 |
+
'kolektiva.social',
|
| 12 |
+
'seo.chat',
|
| 13 |
+
'ioc.exchange',
|
| 14 |
+
'glasgow.social',
|
| 15 |
+
'mindly.social',
|
| 16 |
+
'mstdn.party',
|
| 17 |
+
'universeodon.com',
|
| 18 |
+
'ravenation.club',
|
| 19 |
+
'home.social',
|
| 20 |
+
'techhub.social',
|
| 21 |
+
'mastodon.scot',
|
| 22 |
+
'sfba.social',
|
| 23 |
+
'mastodon.sdf.org',
|
| 24 |
+
'mastodon.lol',
|
| 25 |
+
'mstdn.social',
|
| 26 |
+
'mas.to',
|
| 27 |
+
'newsie.social']
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 28 |
|
| 29 |
# A HTML blob of text used to define the 'login in with' button
|
| 30 |
auth_button_text = '''<a href="{}"><button class="w3-button w3-light-grey w3-padding-large w3-section " onclick="document.getElementById('download').style.display='block'">
|
|
|
|
| 38 |
Generates an authenticated Masterdon client for the admin user. Used for retireving the target website URL
|
| 39 |
'''
|
| 40 |
|
| 41 |
+
|
| 42 |
+
global slider_choice
|
| 43 |
+
server = slider_choice
|
| 44 |
+
id = "WatchTower Ivory | Mastodon"
|
| 45 |
+
|
| 46 |
+
#client_id, client_secret = Mastodon.create_app(id,
|
| 47 |
+
# api_base_url= server, scopes=["write:blocks", "write:mutes"],
|
| 48 |
+
# redirect_uris="https://user1342-ivory.hf.space/",
|
| 49 |
+
# website="https://www.watchtower.cartographer.one/")
|
| 50 |
+
|
| 51 |
+
secrets = json.loads(os.getenv('secrets_json'))
|
| 52 |
+
client_id = secrets[server]["client_id"]
|
| 53 |
+
client_secret = secrets[server]["client_secret"]
|
| 54 |
+
password = secrets[server]["password"]
|
| 55 |
+
username = os.getenv('username')
|
| 56 |
+
|
| 57 |
|
| 58 |
mastodon = Mastodon(
|
| 59 |
+
client_id=client_id,client_secret=client_secret,
|
| 60 |
+
api_base_url='https://{}'.format(server)
|
| 61 |
)
|
| 62 |
|
| 63 |
+
access_token = mastodon.log_in(
|
| 64 |
+
username=username,
|
| 65 |
+
password=password,
|
| 66 |
+
redirect_uri="https://user1342-ivory.hf.space/"
|
|
|
|
| 67 |
)
|
| 68 |
|
| 69 |
return mastodon
|
|
|
|
| 85 |
:param code: The code which will authenticate the user/ WatchTower.
|
| 86 |
:return: A masterdon client instance signed in as the user.
|
| 87 |
'''
|
| 88 |
+
|
| 89 |
+
global slider_choice
|
| 90 |
+
server = slider_choice
|
| 91 |
+
|
| 92 |
+
secrets = json.loads(os.getenv('secrets_json'))
|
| 93 |
+
client_id = secrets[server]["client_id"]
|
| 94 |
+
client_secret = secrets[server]["client_secret"]
|
| 95 |
+
|
| 96 |
mastodon = Mastodon(
|
| 97 |
+
client_id=client_id, client_secret=client_secret,
|
| 98 |
+
api_base_url='https://{}'.format(server)
|
| 99 |
)
|
| 100 |
|
| 101 |
mastodon.log_in(code=code,
|
|
|
|
| 218 |
:return: The number of blocked users.
|
| 219 |
'''
|
| 220 |
num_users_blocked = 0
|
| 221 |
+
|
|
|
|
| 222 |
|
| 223 |
for filename in os.listdir("users"):
|
| 224 |
filename = os.path.join("users", filename)
|