import requests
import time

EMAIL = input("Email : ")
REFERAL_CODE = input("Referral Code : ")

def dotify(string):
    if len(string) == 1:
        yield string
        return

    for rest in dotify(string[1:]):
        yield string[0] + rest
        yield string[0] + "." + rest  

for email in list(dotify(EMAIL.split("@")[0].replace(".","") + "@" + EMAIL.split("@")[1])):
    requestURL = "https://invites.oneplus.net/index.php?r=share/signup&success_jsonpCallback=success_jsonpCallback&email={0}&koid={1}&_=1438677876942".format(email.replace("@", "%40"), REFERAL_CODE)
    print("Sending invite to " + email)
    res = requests.get(requestURL)
    while res.status_code != 200:
        print("Request failed. "+str(res.status_code))
        time.sleep(5)
        res = requests.get(requestURL)
    print("Successfully retreived response")
