User1342 commited on
Commit
630cf05
·
1 Parent(s): 3ff4afd

Update app.py

Browse files
Files changed (1) hide show
  1. app.py +58 -66
app.py CHANGED
@@ -1,53 +1,30 @@
1
  from mastodon import Mastodon # Mastodon.py
2
 
3
- list_of_servers = [
4
- "mastodon.social",
5
- "peoplemaking.games",
6
- "maly.io",
7
- "ani.work",
8
- "libretooth.gr",
9
- "tilde.zone",
10
- "pettingzoo.co",
11
- "phpc.social",
12
- "hostux.social",
13
- "activism.openworlds.info",
14
- "metalhead.club",
15
- "x0r.be",
16
- "mathstodon.xyz",
17
- "indieweb.social",
18
- "social.linux.pizza",
19
- "lor.sh",
20
- "nerdculture.de",
21
- "toot.wales",
22
- "kolektiva.social",
23
- "mastodon.pirateparty.be",
24
- "socel.net",
25
- "mastodon.nz",
26
- "noc.social",
27
- "seo.chat",
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
- # Setup a 'secret' file used for persisting session between requests.
65
- secret_file = open("ivory-secret.txt", "w")
66
- secret_file.write("{}\n".format(os.getenv('app_secret_1')))
67
- secret_file.write("{}\n".format(os.getenv('app_secret_2')))
68
- secret_file.write("https://infosec.exchange\n")
69
- secret_file.write("WatchTower | Ivory")
70
- secret_file.close()
 
 
 
 
 
 
 
 
 
71
 
72
  mastodon = Mastodon(
73
- client_id="ivory-secret.txt",
74
- api_base_url='https://infosec.exchange'
75
  )
76
 
77
- mastodon.log_in(
78
- os.getenv('username'),
79
- os.getenv('password'),
80
- scopes=["write:blocks", "write:mutes"],
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="ivory-secret.txt",
105
- api_base_url='https://infosec.exchange'
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
- global dropdown
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)