import time
import webbrowser
import smtplib
from email.message import EmailMessage

GMAIL_USER = "AndersonS.2028@mtchs.org"
GMAIL_APP_PASSWORD = "pnml rqfj ghaf cbne"

emailVMoodle = input("Email or Moodle? ")
if (emailVMoodle == "Email"):
    while True:
        toWhom = input("Who would you like to send an email to? Gafford, Leyva, Garey, Pence, Vonderehe, Heesch, Grell, or Mathie? if none of these apply, type OTHER ")
        if (toWhom == "Gafford"):
            emailAddress = "mckenna.gafford@mtchs.org"
        elif (toWhom == "Leyva"):
            emailAddress = "vanessa.leyva@mtchs.org"
        elif (toWhom == "Garey"):
            emailAddress = "daren.garey@mtchs.org"
        elif (toWhom == "Pence"):
            emailAddress = "andrew.pence@mtchs.org"
        elif (toWhom == "Vonderehe"):
            emailAddress = "karl.vonderehe@mtchs.org"
        elif (toWhom == "Heesch"):
            emailAddress = "leah.heesch@mtchs.org"
        elif (toWhom == "Grell"):
            emailAddress = "erica.grell@mtchs.org"
        elif (toWhom == "Mathie"):
            emailAddress = "stephen.mathie@mtchs.org"
        elif (toWhom == "OTHER"):
            emailAddress = input("type the full email address of who your sending this email to then! ")
        else:
            print("who are you sending an email to then??? Please hit ctrl C to close the program...")
            continue

        subject = input("What is the subject of this email? ")
        print('Enter your message (type "DONE" on a new line when finished):')
        lines = []
        while True:
            line = input()
            if line == "DONE":
                break
            lines.append(line)
        message = "\n".join(lines)

        msg = EmailMessage()
        msg["Subject"] = subject
        msg["From"] = GMAIL_USER
        msg["To"] = emailAddress
        msg.set_content(message)

        with smtplib.SMTP_SSL("smtp.gmail.com", 465) as smtp:
            smtp.login(GMAIL_USER, GMAIL_APP_PASSWORD)
            smtp.send_message(msg)
        
        anotherOne = input("Say no if you don't want to send another email, otherwise, press any key (and enter) to continue ")
        if (anotherOne == "no"):
            break
    
elif (emailVMoodle == "Moodle"):
    whatPage = input("What Moodle page do you want to open? ")
    webbrowser.register("chrome", None, webbrowser.BackgroundBrowser("C:\Program Files (x86)\Google\Chrome\Application\chrome.exe"))
    chrome = webbrowser.get("chrome")
    if (whatPage == "Math"):
        chrome.open("https://mtchs.moonami.com/course/view.php?id=278")
    elif (whatPage == "Biology"):
        chrome.open("https://mtchs.moonami.com/course/view.php?id=173&section=3#tabs-tree-start")
    elif (whatPage == "Spanish"):
        chrome.open("https://mtchs.moonami.com/course/view.php?id=170")
    elif (whatPage == "English"):
        chrome.open("https://mtchs.moonami.com/course/view.php?id=183")
    elif (whatPage == "Business"):
        chrome.open("https://mtchs.moonami.com/course/view.php?id=227")
    elif (whatPage == "Health"):
        chrome.open("https://mtchs.moonami.com/course/view.php?id=88")
    elif (whatPage == "History"):
        chrome.open("https://schoology.idiglearning.org/course/8210891580/updates")
    elif (whatPage == "Javascript"):
        chrome.open("https://mtchs.moonami.com/course/view.php?id=248")
        time.sleep(5)
        chrome.open("https://www.google.com/logos/2013/drwho/drwho.html")
        time.sleep(3)
        chrome.open("https://www.mtchs.org/wp-uploads/StudentWork/ClickerGame/")
    elif (whatPage == "Pokemon Clicker"):
        chrome.open("https://www.mtchs.org/wp-uploads/StudentWork/ClickerGame/")
    elif (whatPage == "Oh no! A virus!"):
        baseball = int(input("how many viruses are there??? "))
        for i in range(baseball):
            chrome.open("https://www.google.com/logos/2013/drwho/drwho.html")
    else:
        otherLink = input("bro what are you trying to open here? enter the link here: ")
        chrome.open(otherLink)
elif ():
    print("That's not one of the options???")