shaker-bot/faucet.py

25 lines
828 B
Python
Raw Permalink Normal View History

2023-11-08 16:29:54 +11:00
import os
from dotenv import load_dotenv
import discord
from discord import app_commands
import json
from email_validator import validate_email, EmailNotValidError
import requests
async def send_domain(user, email):
try:
emailinfo = validate_email(email, check_deliverability=False)
email = emailinfo.normalized
except EmailNotValidError as e:
2023-11-09 11:27:25 +11:00
return "Your email is invalid"
2023-11-08 16:29:54 +11:00
2023-11-09 11:27:25 +11:00
response = requests.post("https://faucet.woodburn.au/api?email=" + email+"&name="+str(user) + "&key=" + os.getenv('FAUCET_KEY'))
print(response)
print(response.text)
2023-11-08 16:29:54 +11:00
response = response.json()
if response['success']:
2023-11-09 11:27:25 +11:00
return "Congratulations! We've sent you a domain to your email"
2023-11-08 16:29:54 +11:00
else:
2023-11-09 11:27:25 +11:00
return "Sorry, something went wrong. Please try again later\n" + response['error']
2023-11-08 16:29:54 +11:00