Skip to content

Commit

Permalink
Logging
Browse files Browse the repository at this point in the history
  • Loading branch information
MiranDaniel committed Nov 20, 2021
1 parent c7fbe21 commit 6e56fe5
Showing 1 changed file with 5 additions and 0 deletions.
5 changes: 5 additions & 0 deletions app.py
Original file line number Diff line number Diff line change
Expand Up @@ -50,6 +50,7 @@
quit(1)

def recaptcha(token):
print(f"Verifying recaptcha {token[:15]}")
recaptcha_url = 'https://www.google.com/recaptcha/api/siteverify'
payload = {
'secret': config["recaptcha"]["private"],
Expand All @@ -61,12 +62,14 @@ def recaptcha(token):
return result

def invite():
print("Generating new invite!")
resp = requests.post(
'https://discordapp.com/api/channels/%s/invites' % config["discord"]["welcome_room"],
headers={'Authorization': 'Bot %s' % config["discord"]["private"]},
json={'max_uses': 1, 'unique': True, 'expires': 300}
)
i = resp.json()
print("Generated new invite!")
return i["code"]

app = Flask(__name__)
Expand All @@ -82,9 +85,11 @@ def index():
if key: # if key set
r = recaptcha(key) # confirm captcha
if r["success"]: # if ok
print(f"Recaptcha {key[:30]} verified!")
i = invite() # generate new invite
return redirect(f"https://discord.gg/{i}") # redirect user to new invite
else: # if captcha invalid
print(f"Recaptcha {key[:30]} failed!")
return render_template("index.html", public=config["recaptcha"]["public"], failed=True, theme=theme, border=border, catpcha_theme=catpcha_theme) # return error page
# if not key
return render_template("index.html", public=config["recaptcha"]["public"], failed=False, theme=theme, border=border, catpcha_theme=catpcha_theme) # return normal page

0 comments on commit 6e56fe5

Please sign in to comment.