Exemplo n.º 1
0
def send_initiate():
    target.clear()
    username = ''  # input("Full email address: ")
    password = ''  # input('Password: '******'contact_list.txt', 'r') as f:
            user_list = [line.rstrip('\n') for line in f]
    except IOError:
        f = open('contact_list.txt', 'w')
    user_list.extend(all_recipients)
    user_list = list(set(user_list))
    for i, s in enumerate(user_list):
        print((i + 1))
        print(s)
        print()
    chat_speak("Who do you want to connect to ?")
    choice = int(input('Who do you want to connect to (0 for new contact): '))
    for i, s in enumerate(user_list):
        if choice == (i + 1):
            target.append(s)
            found = 1
            sending(target)
        else:
            continue
    if choice == 0:
        #print('Could not find the corresponding email_id...!\n')
        chat_speak("Enter the complete email address of the recipient")
        new_email = input('Enter the complete email address of recipient: ')
        target.append(new_email)
        user_list.append(new_email)
        sending(target)
        with open('contact_list.txt', 'w') as f1:
            for s in user_list:
                f1.write(s + '\n')
            f1.close()
    try:
        mail_conn.close()  # Close currently selected folder (if any)
    finally:
        mail_conn.logout()
    f.close()
Exemplo n.º 2
0
def keyword_search():
    chat_speak("Enter a keyword to search in filename")
    file_name = input('Enter a keyword to search in filename: ')
    try:
        read_file(file_name)
    except IOError:
        write_file()
        read_file(file_name)
Exemplo n.º 3
0
def connect(user, pwd, server=DEFAULT_MAIL_SERVER):
    """Connect to [the specified] mail server. Return an open connection"""
    conn = imaplib.IMAP4_SSL(server)
    try:
        conn.login(user, pwd)
    except imaplib.IMAP4.error:
        chat_speak("Failed to login, try again")
        print("Failed to login")
        sys.exit(1)
    return conn
Exemplo n.º 4
0
def read_file(file_name):
    with io.open('file_list.txt', 'r', encoding="utf-8") as f:
        user_list = [line.rstrip('\n') for line in f]
        for i, x in enumerate(user_list):
            # regex = re.findall(r"(?i)(.*)file(.*)",x)
            if file_name in x:
                matches.append(x)
    for i, x in enumerate(matches):
        print(i + 1)
        print(x)
    chat_speak("Your choice")
    file_choice = int(input("Enter your choice: "))
    os.startfile(matches[(file_choice - 1)])
    f.close()
Exemplo n.º 5
0
def websearch(string):
    try:
        #wolframalpha
        app_id = "2977GH-AH3R25WXXJ"
        client = wolframalpha.Client(app_id)
        res = client.query(string)
        answer = next(res.results).text
        print("wolf answer:\n" + answer)
        chat_speak(answer)
    except:
        #wikipedia
        answer = wikipedia.summary(string, sentences=4)
        print("wiki answer: \n" + answer)
        chat_speak(answer)
Exemplo n.º 6
0
def sending(target_mail):
    print(target_mail)
    chat_speak("Message content")
    content = input('Message content: ')
    msg = MIMEText(content)
    chat_speak("Subject")
    msg['Subject'] = input('Subject: ')
    msg['From'] = username
    msg['To'] = ', '.join(target)
    server = smtplib.SMTP_SSL(smtp_ssl_host, smtp_ssl_port)
    server.login(username, password)
    server.sendmail(username, target, msg.as_string())
    chat_speak("Mail sent")
    print('Mail sent')
    server.quit()
    return
Exemplo n.º 7
0
def reading():
    mail = imaplib.IMAP4_SSL('imap.gmail.com')
    mail.login('', '')
    mail.list()
    mail.select('inbox')
    result, data = mail.uid('search', None, 'UNSEEN')
    if data[0]==b'':
        chat_speak("No new mails")
        print("No new mails")
    for num in data[0].split():
        #latest_email_uid = data[j].split()[x]
        results, email_data = mail.uid('fetch', num, '(RFC822)')
        raw_email = email_data[0][1]
        raw_email_string = raw_email.decode('utf-8')
        email_message = email.message_from_string(raw_email_string)
        for response_part in email_data:
            if isinstance(response_part, tuple):
                response = response_part[1].decode('utf-8')
                original = email.message_from_string(response)
                sender = original['From']
                chat_speak("There is a message from")
                chat_speak(sender)
                print("Sender: "+sender)
                data = original['Subject']
                chat_speak("With subject")
                chat_speak(data)
                print("Subject: "+data)
        for part in email_message.walk():
            if part.get_content_type() == "text/plain":  # ignore attachments/html
                body = part.get_payload(decode=True)
                body = body.decode('utf-8')
                chat_speak("The message content is")
                chat_speak(body)
                print ("Message content is: "+body)
            else:
                continue
Exemplo n.º 8
0
           speak(case)
           web_browse.browse( \
               filtered_sentence[filtered_sentence.index('website') + 1])
    #Searching(Query)
    if word_list[0] in ["who", "when", "where", "how","what"] :
        if not("you" in word_list or "your" in word_list):
            websearch(string)
        else:
            if os.path.isfile("bot_brain.brn"):
                kernel.bootstrap(brainFile="bot_brain.brn")
            else:
                kernel.bootstrap(learnFiles="std-startup.xml", commands="load aiml b")
            #print(string)
            answer = kernel.respond(string)
            print("ISAAC: "+answer)
            chat_speak(answer)

    #Searching(System)
    if 'search' in filtered_sentence and 'for' in filtered_sentence:
        if 'file' in filtered_sentence and \
                        filtered_sentence.index('search') \
                        < filtered_sentence.index('file'):
            pos = unfiltered.index("file") + 5
            unfiltered = unfiltered[pos:]
        else:
            pos = unfiltered.index("for") + 4
            unfiltered = unfiltered[pos:]
        case = 2
        speak(case)
        keyword_search()
        #winsearch(unfiltered)