User1342 commited on
Commit
777faa3
·
1 Parent(s): 74c6310

Update app.py

Browse files
Files changed (1) hide show
  1. app.py +14 -3
app.py CHANGED
@@ -1,3 +1,5 @@
 
 
1
  from mastodon import Mastodon # Mastodon.py
2
 
3
  list_of_servers = ['peoplemaking.games',
@@ -224,9 +226,18 @@ def get_client_from_tokens(code):
224
  def block_user(user_id, user, reason):
225
  finished = False
226
  blocked = True
 
227
  while not finished:
228
- client.account_block(user_id)
229
-
 
 
 
 
 
 
 
 
230
  print("Blocked {}, for {}".format(user, reason))
231
  return blocked
232
 
@@ -419,7 +430,7 @@ with block:
419
  )
420
  text_input = gr.Text(label="Input", visible=False).style()
421
  text_output = gr.Text(label="Output", visible=False).style()
422
- with gr.Row().style(equal_height=True):
423
  dropdown = gr.Dropdown(choices=list_of_servers, label="Server", value=list_of_servers[0])
424
  html_button = mastodon_auth_button = gr.HTML(
425
  value=auth_button_text.format(
 
1
+ import time
2
+
3
  from mastodon import Mastodon # Mastodon.py
4
 
5
  list_of_servers = ['peoplemaking.games',
 
226
  def block_user(user_id, user, reason):
227
  finished = False
228
  blocked = True
229
+ attempts = 0
230
  while not finished:
231
+ try:
232
+ attempts = attempts + 1
233
+ client.account_block(user_id)
234
+ except:
235
+ time.sleep(60)
236
+
237
+ if attempts > 5:
238
+ finished = True
239
+ break
240
+
241
  print("Blocked {}, for {}".format(user, reason))
242
  return blocked
243
 
 
430
  )
431
  text_input = gr.Text(label="Input", visible=False).style()
432
  text_output = gr.Text(label="Output", visible=False).style()
433
+ with gr.Row().style():
434
  dropdown = gr.Dropdown(choices=list_of_servers, label="Server", value=list_of_servers[0])
435
  html_button = mastodon_auth_button = gr.HTML(
436
  value=auth_button_text.format(