예제 #1
0
def setNewUser():
    usr_info_dic = {}
    clear.clear()
    voice_io.show("What shall I call you Master? ")
    nm = bytes(
        invoice.inpt(), encoding="utf-8"
    )  #Name of the user i.e the name by which the assistant will call him/her
    voice_io.show(
        "\nAnd you are, Master or Miss, master? ")  #Gender of the user
    gnd = invoice.inpt()
    asst_pswd = bytes(getpass.getpass(
        voice_io.show("\nWhat should be your password for accessing me?",
                      show_output=False) + "\nPassword: "******"utf-8")
    salt = b'$2b$12$3hbla5Xs2Ekx9SGVYfWQuO'
    hashed_pswd = bcrypt.hashpw(asst_pswd, salt)
    kdf = PBKDF2HMAC(
        algorithm=hashes.SHA256(),
        length=32,
        salt=salt,
        iterations=100000,
    )
    global key
    key = base64.urlsafe_b64encode(kdf.derive(hashed_pswd))
    #with open(get_dirs.FILE_ENCRYPT_KEY,'wb+') as f:
    #    f.write(key)
    voice_io.show(
        "\nAnd now what would be your 'gmail' address? Note: Right now I support gmail (google) accounts only, so please make one if you don't have one already, to continue! "
    )
    eml = bytes(invoice.inpt(processed=False), encoding="utf-8")
    print(
        "\nLastly I need you to authenticate this with Daddy Google for me, you can skip this now but know that I will be needing this to perform Email Operations! Press: "
    )
    ch = input(
        "\n1. To authenticate it right now, like a good master! ^o^\n2. To skip and not be cool to me, like a bad master! U_U\n"
    )
    if ch == '1':
        gmail_authentication()
    elif ch == '2':
        pass
    else:
        print("Invalid Input, Skipping!")
    cipher_suite = Fernet(key)
    usr_info_dic['name'] = cipher_suite.encrypt(nm)
    GND_FEMALE = ["girl", 'miss', 'missus', 'mrs', 'female', 'lady', 'woman']
    GND_MALE = ["boy", "master", "mister", "mr", "male", "lodu", "man"]
    if gnd.lower() in GND_FEMALE:
        usr_info_dic['gender'] = cipher_suite.encrypt(b"Female")
    elif gnd.lower() in GND_MALE:
        usr_info_dic['gender'] = cipher_suite.encrypt(b"Male")
    else:
        usr_info_dic['gender'] = cipher_suite.encrypt(b"Others")
    usr_info_dic["asst_password"] = cipher_suite.encrypt(hashed_pswd)
    usr_info_dic['email'] = cipher_suite.encrypt(eml)
    info_in(usr_info_dic)
    voice_io.show(
        "Well then you're good to go! Just press Enter/Return to continue!",
        end="")
    invoice.inpt("", iterate=False)
    return key, nm.decode("utf-8")
예제 #2
0
def main(op=''):
    if op=='':
        global FT
        x=SongPlayer()
        clear.clear()
        ft_message="""
Welcome to Kori Songs Player! Please note that this feature is still under development and 
might be prone to errors, which if you happen to encounter please report it to the developers.
"""
        m_message="""{}
What song would you like to play?
        """.format(ft_message if FT==True else "")
        print(m_message)
        try:
            FT=False
            song=input("Please Search Here - ")
            if song!='':
                x.Search(song)  
                songid=input("\nEnter the number of the song that you want me to play? or Press Enter to search for something else: ")
                if songid=='':
                    x.Close()
                    main()

                elif songid <= '5' and songid >= '1':
                    x.SearchPlay(songid)
                    x.Console()

                else:
                    print("Invalid Input! Please Try Again") 
                    main()
            else:
                print("Invalid Input! Please Try Again!")
                main()  

        except Exception as e:
            print("\nAn Error Occurred while trying to do that please try again later and if the problem persists report it to the developers, the following error message.")
            print(e)

    else:
        x=SongPlayer()
        clear.clear()
        try:
            x.Search(op)
            songid=input("\nEnter the number of the song that you want me to play? or Press Enter to search for something else: ")
            if songid=='':
                x.Close()
                main()

            elif songid <= '5' and songid >= '1':
                x.SearchPlay(songid)
                x.Console()

            else:
                print("Invalid Input! Please Try Again") 
                main()

        except Exception as e:
            print("\nAn Error Occurred while trying to do that please try again later and if the problem persists report it to the developers, the following error message.")
            print(e)
예제 #3
0
 def VideoPlay(self):
     VideoTitle = self.Driver.title
     VideoTitle = VideoTitle.rstrip('- YouTube')
     VideoLink = self.Driver.current_url
     clear.clear()
     print(f'\nNow Playing {VideoTitle} ')
     Video = self.Driver.find_element_by_xpath('//*[@id="player-container-id"]')
     Video.click()
     time.sleep(0.75)
     Video.click()
     Autoplay = self.Driver.find_element_by_xpath('//*[@id="player-control-overlay"]/div/div[1]/button[1]')
     Autoplay.click()
     self.PreviousVideos[VideoTitle]=VideoLink
     self.UpNext()
예제 #4
0
파일: news_op.py 프로젝트: OkKori/Kori
def main():
    clear.clear()
    voice_io.show(
        "*NOTE: The news feature is still under-development and so it might be prone to errors. Please report any such occurences if you find one! Thanks @Prabhat.\n"
    )
    voice_io.show(
        "Here comes the news boy! Haha How can i help you today? Please Press: "
    )
    voice_io.show("1. For Today's top headlines.")
    voice_io.show("2. For Top headlines in a category.")
    voice_io.show("3. For Top headlines in another country.")
    voice_io.show("4. To Search for News.")
    voice_io.show("5. To go back.")
    ch = invoice.inpt("Here: ")
    if ch == '1':
        headlines()

    elif ch == '2':
        catg = invoice.inpt(
            "What Category trending news do you want to see? ['business', 'entertainment', 'general', 'health', 'science', 'sports', 'technology']: "
        )
        if catg not in [
                'business', 'entertainment', 'general', 'health', 'science',
                'sports', 'technology'
        ]:
            voice_io.show(
                "I'm not sure if i can do that! Anyway here's the general trending news!"
            )
            headlines()
        else:
            headlines(catg=catg)

    elif ch == '3':
        cnt = invoice.inpt(
            "Which Country's trending news do you want to see?: ")
        cnt_code = cnt_iso3166(cnt)
        headlines(cnt=cnt_code)

    elif ch == '4':
        search_news()

    elif ch == '5':
        return

    else:
        voice_io.show("Invalid Input!")
예제 #5
0
파일: news_op.py 프로젝트: OkKori/Kori
def headlines(cnt=cnt_code, catg='general'):
    url = ('https://newsapi.org/v2/top-headlines?'
           f'country={cnt}&'
           f'category={catg}&'
           f'apiKey={api}')
    #voice_io.show(url)
    response = requests.get(url)
    r = response.json()
    try:
        items = []
        for i in r['articles']:
            item = (i['title'], i['description'], i['url'])
            items.append(item)

        if len(items) == 0:
            voice_io.show(
                "Sorry I couldn't find anything like that! Maybe you didn't specify it properly or maybe there just isn't anything regarding that right now, so try again later, maybe!?"
            )

        else:
            for i in range(len(items)):
                clear.clear()
                voice_io.show(f'[{i+1}]', items[i][0])
                time.sleep(1)
                voice_io.show(
                    "\nWhat would you like to do? \n1. Expand this headline and read a little more about it. \n2. Open this news piece in your browser. \n3. Skip to the next headline. \n4. Print all news headlines at once. \n5. Go back."
                )
                ch = invoice.inpt("Enter Choice: ")
                if ch == '1':
                    voice_io.show(items[i][1])
                    time.sleep(3)
                    ch1 = invoice.inpt(
                        "\nWould you like to know about this some more? I could open this up in your browser! (Y/N): "
                    )
                    if ch1.lower() == 'y':
                        voice_io.show("Here you go!\n")
                        webbrowser.open(items[i][2])
                    elif ch1.lower() == 'n':
                        voice_io.show("Okay! Onto the next one! \n")
                    else:
                        voice_io.show("Invalid Input!")

                elif ch == '2':
                    voice_io.show("Here you go!")
                    webbrowser.open(items[i][2])
                    invoice.inpt("Press Enter to continue to the next story!")
                    continue

                elif ch == '3':
                    continue

                elif ch == '4':
                    while True:
                        clear.clear()
                        voice_io.show("Here you go!\n")
                        for j in range(len(items)):
                            voice_io.show(f'[{j+1}]', items[j][0])
                        time.sleep(3)
                        voice_io.show(
                            "\nWhat would you like to do now? \n1. Expand a specific headline and read a little more about it. \n2. Open a specific headline in your browser. \n3. Go back."
                        )
                        ch2 = invoice.inpt("Enter Choice: ")
                        if ch2 == '1':
                            inp = int(
                                invoice.inpt(
                                    "Enter the index of the news headline you'd like to know more about: "
                                ))
                            voice_io.show(items[inp - 1][0])
                            time.sleep(3)
                            ch3 = invoice.inpt(
                                "\nWould you like to know about this some more? I could open this up in your browser! (Y/N): "
                            )
                            if ch3.lower() == 'y':
                                #voice_io.show("Here you go!\n")
                                webbrowser.open(items[inp - 1][2])
                                continue
                            elif ch3.lower() == 'n':
                                ch3 = invoice.inpt(
                                    "\nDo you want to go back and read more news? (Y/N): "
                                )
                                if ch3.lower() == 'y':
                                    continue
                                else:
                                    return
                            else:
                                voice_io.show("Invalid Input!")
                            time.sleep(5)

                        elif ch2 == '2':
                            inp = int(
                                invoice.inpt(
                                    "Enter the index of the news headline you'd like to open up in your browser: "
                                ))
                            voice_io.show("Here you go!")
                            webbrowser.open(items[inp - 1][2])
                            ch3 = invoice.inpt(
                                "\nDo you want to go back and read more news? (Y/N): "
                            )
                            if ch3.lower() == 'y':
                                continue
                            else:
                                return

                        elif ch2 == '3':
                            return

                        else:
                            voice_io.show("Invalid Input!")

                elif ch == '5':
                    return

                else:
                    voice_io.show('Invalid Input!')

    except KeyError:
        voice_io.show(
            "Uh-oh! Looks like i ran into some error doing that! You sure everything's alright? Why not try again later!?"
        )
예제 #6
0
파일: news_op.py 프로젝트: OkKori/Kori
def search_news():
    clear.clear()
    voice_io.show(
        "\nFor advanced news search please fill in the following (Note - Those fields with an asterisk before their names are optional and so are those with a default something specified, please leave them empty if you don't intend to use them!)"
    )
    qry = invoice.inpt(
        """\nKeywords or phrases to search for in the news articles (Note - Surround phrases with quotes ('/\") for exact matches, 
Prepend words or phrases that must appear with a + symbol. Eg: +bitcoin, Prepend words that must not appear with a - symbol. Eg: -bitcoin. 
Alternatively you can use the AND / OR / NOT keywords, and optionally group these with parenthesis. Eg: crypto AND (ethereum OR litecoin) NOT bitcoin.): """
    )
    params = {'q': qry}
    sort = input(
        "Sort By ['relevancy', 'popularity', 'publishedAt'] (default is 'publishedAt', it is for the newest articles first): "
    )
    sort = sort.lower()
    if sort not in ['relevancy', 'popularity', 'publishedAt']:
        sort = 'publishedAt'
    params['sortBy'] = sort
    catg = input(
        "Category of the news articles ['business', 'entertainment', 'general', 'health', 'science', 'sports', 'technology'] (default is 'general'): "
    )
    catg = catg.lower()
    if catg not in [
            'business', 'entertainment', 'general', 'health', 'science',
            'sports', 'technology'
    ]:
        catg = 'general'
    params['category'] = catg
    cnt = input(
        "Country you want the articles to be about (default is your set location): "
    )
    if cnt == '':
        cnt = cnt_code
        params['country'] = cnt
    else:
        cnt = cnt_iso3166(cnt)
        params['country'] = cnt
    incldom = input(
        "*Include Domains (A comma-seperated string of domains (eg bbc.co.uk, techcrunch.com, engadget.com) to restrict the search to): "
    )
    if incldom != '':
        params['domains'] = incldom
    excldom = input(
        "*Exclude Domains (A comma-seperated string of domains (eg bbc.co.uk, techcrunch.com, engadget.com) to remove from the results.): "
    )
    if excldom != '':
        params['excludeDomains'] = excldom
    frm = input(
        "*Date and optional time for the oldest article (e.g. 2021-09-02 or 2021-09-02T03:29:09): "
    )
    if frm != '':
        params['from'] = frm
    to = input(
        "*Date and optional time for the newest article (e.g. 2021-09-02 or 2021-09-02T03:29:09): "
    )
    if to != '':
        params['to'] = to

    url = 'https://newsapi.org/v2/top-headlines?'
    for i in params.keys():
        s = f'{i}={params[i]}&'
        url += s
    url += f"apiKey={api}"
    voice_io.show(url)
    response = requests.get(url)
    r = response.json()

    try:
        items = []
        for i in r['articles']:
            item = (i['title'], i['description'], i['url'])
            items.append(item)

        if len(items) == 0:
            voice_io.show(
                "Sorry I couldn't find anything like that! Maybe you didn't specify it properly or maybe there just isn't anything regarding that right now, so try again later, maybe!?"
            )

        else:
            for i in range(len(items)):
                clear.clear()
                voice_io.show(f'[{i+1}]', items[i][0])
                time.sleep(1)
                voice_io.show(
                    "\nWhat would you like to do? \n1. Expand this headline and read a little more about it. \n2. Open this news piece in your browser. \n3. Skip to the next headline. \n4. Print all news headlines at once. \n5. Go back."
                )
                ch = invoice.inpt("Enter Choice: ")
                if ch == '1':
                    voice_io.show(items[i][1])
                    time.sleep(3)
                    ch1 = invoice.inpt(
                        "\nWould you like to know about this some more? I could open this up in your browser! (Y/N): "
                    )
                    if ch1.lower() == 'y':
                        voice_io.show("Here you go!\n")
                        webbrowser.open(items[i][2])
                    elif ch1.lower() == 'n':
                        voice_io.show("Okay! Onto the next one! \n")
                    else:
                        voice_io.show("Invalid Input!")

                elif ch == '2':
                    voice_io.show("Here you go!")
                    webbrowser.open(items[i][2])
                    invoice.inpt("Press Enter to continue to the next story!")
                    continue

                elif ch == '3':
                    continue

                elif ch == '4':
                    while True:
                        voice_io.show("Here you go!\n")
                        for j in range(len(items)):
                            voice_io.show(f'[{j+1}]', items[j][0])
                        time.sleep(3)
                        voice_io.show(
                            "\nWhat would you like to do now? \n1. Expand a specific headline and read a little more about it. \n2. Open a specific headline in your browser. \n3. Go back."
                        )
                        ch2 = invoice.inpt("Enter Choice: ")
                        if ch2 == '1':
                            inp = int(
                                invoice.inpt(
                                    "Enter the index of the news headline you'd like to know more about: "
                                ))
                            voice_io.show(items[inp - 1][0])
                            time.sleep(3)
                            ch3 = invoice.inpt(
                                "Would you like to know about this some more? I could open this up in your browser! (Y/N): "
                            )
                            if ch3.lower() == 'y':
                                #voice_io.show("Here you go!\n")
                                webbrowser.open(items[inp - 1][2])
                                invoice.inpt(
                                    "Press Enter to continue to the next story!"
                                )
                                continue
                            elif ch3.lower() == 'n':
                                ch3 = invoice.inpt(
                                    "\nDo you want to go back and read more news? (Y/N): "
                                )
                                if ch3.lower() == 'y':
                                    continue
                                else:
                                    return
                            else:
                                voice_io.show("Invalid Input!")
                            time.sleep(5)

                        elif ch2 == '2':
                            inp = int(
                                invoice.inpt(
                                    "Enter the index of the news headline you'd like to open up in your browser: "
                                ))
                            voice_io.show("Here you go!")
                            webbrowser.open(items[inp - 1][2])
                            ch3 = invoice.inpt(
                                "\nDo you want to go back and read more news? (Y/N): "
                            )
                            if ch3.lower() == 'y':
                                continue
                            else:
                                return

                        elif ch2 == '3':
                            return

                        else:
                            voice_io.show("Invalid Input!")

                elif ch == '5':
                    return

                else:
                    voice_io.show('Invalid Input!')

    except KeyError:
        voice_io.show(
            "Uh-oh! Looks like i ran into some error doing that! You sure everything's alright? Why not try again later!?"
        )
예제 #7
0
    def Console(self):
        status="Playing"
        VideoTitle = self.Driver.title
        VideoTitle = VideoTitle.rstrip('- YouTube')
        while True:
            Video = self.Driver.find_element_by_xpath('//*[@id="player-control-overlay"]')
            Action = ActionChains(self.Driver)
            Action.move_to_element_with_offset(Video,75,90).click().perform()
            Elapsed=self.Driver.find_element_by_xpath('//*[@id="player-control-overlay"]/div/div[4]/ytm-time-display/div/span[1]').text
            Duration=self.Driver.find_element_by_xpath('//*[@id="player-control-overlay"]/div/div[4]/ytm-time-display/div/span[3]').text
            TU=Duration.split(':')
            TE=Elapsed.split(':')
            if TU==[''] and TE==['']:
                continue
            else:
                if TU[-1]>='20':
                    TU[-1]=str(int(TU[-1])-10)
                elif TU[-1]>='10' and TU[-1]<='19':
                    TU[-1]='0'+str(int(TU[-1])-10)
                elif TU[-1]>='00' and TU[-1]<='09':
                    TU[-2]=str(int(TU[-2])-1)
                    TU[-1]=str(int(TU[-1])+50)

                if TE>=TU:
                    print("The Track is about to end and here's your queue and what you can do next: \n")
                    count=1
                    for i in self.UpNextVideos.keys():
                        print(f'[{count}] {i}')
                        count+=1
                    UNVnames=list(self.UpNextVideos.keys())
                    UNVlinks=list(self.UpNextVideos.values())
                    print("\n1. Play the next track!")
                    print("2. Play track # from the queue!")
                    print("3. Play this track once again!")
                    print("4. Search for another track!")
                    print("5. Quit Program")
                    ch=input("\nSo what do you wanna do? Enter Choice:  ")
                    if ch=='1':
                        print("\nAlright onto the next one!")
                        time.sleep(3)
                        clear.clear()
                        self.FirstTrack=False
                        self.PlaySong(UNVlinks[0])
                        self.Console()
                    elif ch=='2':
                        ch2=int(input("\nAlright but enter the track number you want to play next. Here: "))
                        time.sleep(3)
                        clear.clear()
                        self.FirstTrack=False
                        self.PlaySong(UNVlinks[ch2-1])
                        self.Console()
                    elif ch=='3':
                        print("Alrighty!")
                        time.sleep(3)
                        clear.clear()
                        self.Replay()
                        self.Console()
                    elif ch=='4':
                        clear.clear()
                        main()
                    elif ch=='5':
                        self.Close()
                        return
                    else:
                        print("Invalid Input!")

                else:
                    if status=='Playing':
                        x1='pause'
                        x2='pause the track'
                    elif status=='Paused':
                        x1='play'
                        x2='resume the track'
                    message=f"""

Currently {status} - {VideoTitle}

Here are the choices/commands to interact with the track:
1 / {x1} - {x2}
2 / stop - stop the track, search for something else
3 / next - next track
4 / previous - previous track (not available if this is your first track)
5 / forward - skip 10 seconds forward
6 / backward - skip 10 seconds backward
7 / quit - quit the song

                    """
                    print(message)
                    try:
                        inp=inputimeout("Enter choice/command - ", timeout=5)
                        if inp=='1' and status=='Playing' or inp.lower()=='pause' and status=='Playing':
                            self.Pause()
                            status="Paused"
                            clear.clear()
                            continue

                        elif inp=='1' and status=='Paused' or inp.lower()=='play' and status=='Paused':
                            self.Play()
                            status="Playing"
                            clear.clear()
                            continue

                        elif inp=='2' or inp.lower()=='stop':
                            self.Pause()
                            main()

                        elif inp=='3' or inp.lower()=='next':
                            count=1
                            for i in self.UpNextVideos.keys():
                                print("\nHere's your queue and what you can do ;) ")
                                print(f'[{count}] {i}')
                                count+=1
                            print("\n1. Play the next track!")
                            print("\n2. Play track # from the queue!")
                            print("\n3. Quit!")
                            UNVnames=list(self.UpNextVideos.keys())
                            UNVlinks=list(self.UpNextVideos.values())
                            ch=input("\nEnter Choice: ")
                            if ch=='1':
                                print("\nAlright onto the next one!")
                                time.sleep(3)
                                self.FirstTrack=False
                                clear.clear()
                                self.PlaySong(UNVlinks[0])
                                self.Console()
                            elif ch=='2':
                                ch2=int(input("\nAlright but enter the track number you want to play next. Here: "))
                                time.sleep(3)
                                clear.clear()
                                self.FirstTrack=False
                                self.PlaySong(UNVlinks[ch2-1])
                                self.Console() 

                            elif ch=='3':
                                self.Close()
                                return

                            else:
                                print("Invalid Input!")

                        elif inp=='4' or inp.lower()=='previous':
                            if self.FirstTrack!=True:
                                clear.clear()
                                print("Here are your previously played song(s) and what you can do with them: \n")
                                count=1
                                PVn=list(self.PreviousVideos.keys())
                                PVn.pop()
                                PVn=PVn[::-1]
                                for i in PVn:
                                    print(f"[{count}] {i}")
                                    count+=1
                                print("\n1. Play the last played track!")
                                print("\n2. Play track #")
                                print("\n3. Quit!")
                                ch=input("\nEnter Choice: ")
                                if ch=='1':
                                    print("\nAlright onto the previous one!")
                                    time.sleep(3)
                                    clear.clear()
                                    self.PlaySong(self.PreviousVideos[PVn[0]])
                                    self.Console()

                                elif ch=='2':
                                    ch2=int(input("\nAlright but please enter the track number. Here: "))
                                    time.sleep(3)
                                    clear.clear()
                                    self.PlaySong(self.PreviousVideos[PVn[ch2-1]])
                                    self.Console() 

                                elif ch=='3':
                                    self.Close()
                                    return

                                else:
                                    print("Invalid Input!")

                            else:
                                print("Hey there aren't any previous tracks since this is your very first track! Maybe try this after having played some!")
                                continue

                                
                        elif inp=='5' or inp.lower()=='forward':
                            self.Forward()
                            continue
                        
                        elif inp=='6' or inp.lower()=='backward':
                            self.Backward()
                            continue
                            
                        elif inp=='7' or inp.lower()=='quit':
                            self.Close()
                            return

                    except TimeoutOccurred:
                        clear.clear()
                        continue
예제 #8
0
파일: mail_op.py 프로젝트: OkKori/Kori
def console(key):
    x = mail(key)
    mes = '?'
    while True:
        y = input(
            f"\nHi! What do you want me to do{mes} Press: \n1. To send out email(s) \n2. To read out the latest email(s) from your Inbox \n3. To search for specific email(s) and read them \n4. To mark as read emails \n5. To mark as unread emails \n6. To delete email(s) \n7. To send feedback \n8. To clear local email repository \n9. To go back.\n"
        )
        mes = ' now?'
        if y == '1':
            clear.clear()
            x.send()
        elif y == '2':
            clear.clear()
            x.read()
        elif y == '3':
            clear.clear()
            x.search()
        elif y == '4':
            clear.clear
            x.mark_as_read()
        elif y == '5':
            clear.clear()
            x.mark_as_unread()
        elif y == '6':
            clear.clear()
            x.delete_messages()
        elif y == '7':
            clear.clear()
            x.send('feedback')
        elif y == '8':
            print("Clearing you local email repository right away!")
            shutil.rmtree(x.mail_path)
            os.mkdir(x.mail_path)
        elif y == '9':
            break
        else:
            print("Invalid Input!")
예제 #9
0
파일: mail_op.py 프로젝트: OkKori/Kori
        def parse_parts(msg, parts, folder_name, message, main):
            if parts:
                for part in parts:
                    filename = part.get("filename")
                    mimeType = part.get("mimeType")
                    body = part.get("body")
                    data = body.get("data")
                    file_size = body.get("size")
                    part_headers = part.get("headers")
                    if part.get("parts"):
                        parse_parts(part.get("parts"), folder_name, message,
                                    main)

                    if mimeType == "text/plain":
                        if data:
                            text = urlsafe_b64decode(data).decode()
                            print("\nTo:", main['to'])
                            print("From:", main['from'])
                            print("Date:", main['date'])
                            print("Subject:", main['sub'])
                            main['body'] = text
                            print(text)

                    elif mimeType == "text/html":
                        print("-" * 50)
                        if self.mkdir:
                            yn = input(
                                "\nThat was pretty weird huh? I'm sorry for that but you see this was a HTML email and I'm still learning how to handle those, so what I recommend right now is you save it as a HTML file and view it in your default browser and know what? I can do that for you! So may I? \n1. Yes \n2. No\n"
                            )
                            if yn == '1' or yn.lower() in [
                                    'yes', 'yep', 'yeah', 'ok'
                            ]:
                                if not filename:
                                    filename = "index.html"
                                filepath = os.path.join(folder_name, filename)

                                print(
                                    f"\nSaving the HTML file to {os.getcwd()}\\{filepath} and opening.\nPlease Wait..."
                                )
                                with open(filepath, "wb") as f:
                                    f.write(urlsafe_b64decode(data))
                                file_op.open_file(filepath)
                            else:
                                print("\nAlright, alright whatever!")
                        else:
                            continue

                    else:
                        for part_header in part_headers:
                            part_header_name = part_header.get("name")
                            part_header_value = part_header.get("value")
                            if part_header_name == "Content-Disposition":
                                if "attachment" in part_header_value:
                                    print("-" * 50)
                                    yn = input(
                                        "Found an attachment inside the email! Would you like to save it and see it? \n1. Yes \n2. No\n"
                                    )
                                    if yn == '1' or yn.lower() in [
                                            'yes', 'yep', 'yeah', 'ok'
                                    ]:
                                        print(
                                            f"\nSaving the attachment file: {filename} size: {get_size_format(file_size)} to {os.getcwd()}\\{folder_name}\\{filename} and opening.\nPlease wait..."
                                        )
                                        attachment_id = body.get(
                                            "attachmentId")
                                        attachment = service.users().messages(
                                        ).attachments().get(
                                            id=attachment_id,
                                            userId='me',
                                            messageId=message['id']).execute()
                                        data = attachment.get("data")
                                        filepath = os.path.join(
                                            folder_name, filename)
                                        if data:
                                            with open(filepath, "wb") as f:
                                                f.write(
                                                    urlsafe_b64decode(data))
                                        file_op.open_file(filepath)
                                    else:
                                        print("Alright, alright whatever!\n")

                c = input(
                    "\nPress 'i' to interact (delete, reply etc) with this email or Press 'n' to continue or Press 'q' to quit.\n"
                )
                c = c.lower()
                if c == 'i':
                    self.mail_options(msg=msg, to=main['to'])
                elif c == 'n':
                    return
                elif c == 'q':
                    clear.clear()
                    console(key=self.key)
                else:
                    print("Invalid Input!")
예제 #10
0
파일: main.py 프로젝트: OkKori/Kori
def main():
    clear.clear()
    if os.path.exists(file_user_data):
        #usr_data = open(path_user_data)
        fetch_password()
        while usr_name == False:
            getpass.getpass(
                voice_io.show("\nInvalid password! Press enter to try again.",
                              show_output=False))
            #voice_io.show("Invalid password! Press enter to try again.")
            #invoice.inpt(iterate = False)
            fetch_password()

    else:
        userSetup()

    iterate_jokes = 0
    clear.clear()
    gnd_ns()

    while True:
        task = invoice.inpt()
        if iterate_jokes > 0 and task not in [
                "another", "another one", "another joke", "once more", "more",
                "again", "new one", "make me laugh again"
        ]:
            iterate_jokes = 0

        elif task.lower() == "clear":
            clear.clear()

        else:
            result = operation(task.lower())
            result = result.lower()
            if result == "":
                try:
                    voice_io.show(web_op.wolfy(task))

                except:
                    voice_io.show(
                        "Sorry i couldn't help you with that. Please try a valid operation."
                    )

            elif result == "help":
                voice_io.show(
                    "Hello Hello! What is it that i can help you with today?")
                voice_io.show("1. Assistant Settings")
                voice_io.show("2. Assistant Services")
                voice_io.show("3. Assistant Operations")
                voice_io.show(
                    "4. Feedback (Suggest Improvements/Report Bugs/...)")
                x = invoice.inpt("Enter Choice: ")
                if x == "1":
                    pda_help()

                elif x == "2":
                    srvc_help()

                elif x == "3":
                    op_help()

                elif x == "4":
                    feedback()

                else:
                    voice_io.show("Invalid Input! Please Try Again!")

            #for testing out a feature or module or function or whatever
            elif result == "test":
                mail_op.console(key=key)

            elif result == "delete_file_unspecified":
                deleteFileUnspecified()

            elif result == "delete_folder_unspecified":
                deleteFolderUnspecified()

            elif result == "delete_general":
                voice_io.show(
                    f"What do you want to {task}, a file or a folder?")
                choice = invoice.inpt().lower()
                if choice == "file":
                    deleteFileUnspecified()

                elif choice == "folder":
                    deleteFolderUnspecified()

                else:
                    voice_io.show(
                        "Sorry i didn't get that, please try again with a proper command."
                    )

            elif result == "open_file":
                query = task.lower()
                kwrd = ""
                obj_name = ""
                if "open a file" in query:
                    kwrd = "file"

                elif "open a folder" in query:
                    kwrd = "folder"

                elif "open file" in query:
                    obj_name = task.replace("open file", "")

                elif "open folder" in query:
                    obj_name = task.replace("open folder", "")

                elif "open " in query:
                    obj_name = task.replace("open ", "")

                obj_name = obj_name.strip()
                if kwrd == "":
                    kwrd = "File or Folder"
                if obj_name == "":
                    voice_io.show(f"Which {kwrd} would you like me to open.")
                    obj_name = invoice.inpt(processed=False)

                voice_io.show(
                    f"Where would you like me to search for {obj_name}?\n1. Desktop\n2. Downloads\n3. Documents\n4. Music\n5. Pictures\n6. Videos\n7. Entire home directory"
                )
                locate = invoice.inpt().lower()
                if locate in locate_desktop:
                    search_dir = desktop

                elif locate in locate_documents:
                    search_dir = documents

                elif locate in locate_downloads:
                    search_dir = downloads

                elif locate in locate_home:
                    search_dir = home

                elif locate in locate_music:
                    search_dir = music

                elif locate in locate_pictures:
                    search_dir = pictures

                elif locate in locate_videos:
                    search_dir = videos

                elif locate in locate_home:
                    search_dir = home

                else:
                    voice_io.show(
                        "Sorry but i cannot find the given directory, \ngoing forward with the entire home directory!"
                    )
                    search_dir = home

                file_op.file_opener(obj_name, search_dir)

            elif result == "search_file":
                obj_name = task.replace("searchfile", "").strip()
                if obj_name == "":
                    voice_io.show(f"What would you like me to search for?.")
                    obj_name = invoice.inpt(processed=False)

                voice_io.show(
                    f"Where would you like me to search for {obj_name}?\n1. Desktop\n2. Downloads\n3. Documents\n4. Music\n5. Pictures\n6. Videos\n7. Entire home directory"
                )
                locate = invoice.inpt().lower()
                if locate in locate_desktop:
                    search_dir = desktop

                elif locate in locate_documents:
                    search_dir = documents

                elif locate in locate_downloads:
                    search_dir = downloads

                elif locate in locate_home:
                    search_dir = home

                elif locate in locate_music:
                    search_dir = music

                elif locate in locate_pictures:
                    search_dir = pictures

                elif locate in locate_videos:
                    search_dir = videos

                elif locate in locate_home:
                    search_dir = home

                else:
                    voice_io.show(
                        "Sorry but i cannot find the given directory, \ngoing forward with the entire home directory!"
                    )
                    search_dir = home

                voice_io.show(
                    f"Searching for '{obj_name}' in {search_dir}.....")
                folder_search_results = file_op.folderSearch(
                    obj_name, search_dir)
                file_search_results = file_op.fileSearch(obj_name, search_dir)
                if folder_search_results != [] or file_search_results != 0:
                    count_files = len(file_search_results)
                    count_folders = len(folder_search_results)
                    voice_io.show(
                        f"Found {count_files} files and {count_folders} folders matching the given name! They are :-"
                    )
                    sno = 1
                    for i in file_search_results:
                        voice_io.show(
                            f"{sno}. file '{i['file']}', inside '{i['root']}'")
                        sno += 1

                    for i in folder_search_results:
                        voice_io.show(
                            f"{sno}. folder '{i['folder']}', inside '{i['root']}'"
                        )
                        sno += 1

                    voice_io.show("Would you like to open any one of them?")
                    ch = invoice.inpt().lower()
                    if ch in ["yes", "yep", "yay", "duh", "sure", "y"]:
                        voice_io.show(
                            "Select the number of the file/folder which you would like to open."
                        )
                        choice = int(invoice.inpt())
                        choice -= 1
                        try:
                            if choice in range(count_files):
                                f_name = file_search_results[choice]['file']
                                parent_dir = file_search_results[choice][
                                    'root']
                                voice_io.show(
                                    f"Opening file '{f_name}' from '{parent_dir}'....."
                                )
                                full_dir = parent_dir + "/" + f_name
                                file_op.open_file(full_dir)

                            elif choice - (count_files) in range(
                                    count_folders):
                                choice -= count_files
                                f_name = folder_search_results[choice][
                                    'folder']
                                parent_dir = folder_search_results[choice][
                                    'root']
                                voice_io.show(
                                    f"Opening folder '{f_name}' from '{parent_dir}' in the Files Explorer....."
                                )
                                full_dir = parent_dir + "/" + f_name
                                file_op.open_file(full_dir)

                            else:
                                voice_io.show(
                                    "Opening failed : Sorry, but the entered number is not within the range of available options."
                                )

                        except SyntaxError or TypeError:
                            voice_io.show(
                                "Opening failed : Sorry, but your entered data is not a number."
                            )
                else:
                    voice_io.show(
                        f"Sorry, could not find any file or folder relating to '{obj_name}'"
                    )

            elif result == "rename":
                search_dir = ""
                voice_io.show("Which file/folder would you like to rename?")
                obj_name = invoice.inpt(processed=False)
                voice_io.show(
                    f"Where would you like me to search for {obj_name}?\n1. Desktop\n2. Downloads\n3. Documents\n4. Music\n5. Pictures\n6. Videos\n7. Entire home directory"
                )
                locate = invoice.inpt().lower()
                if locate in locate_desktop:
                    search_dir = desktop

                elif locate in locate_documents:
                    search_dir = documents

                elif locate in locate_downloads:
                    search_dir = downloads

                elif locate in locate_home:
                    search_dir = home

                elif locate in locate_music:
                    search_dir = music

                elif locate in locate_pictures:
                    search_dir = pictures

                elif locate in locate_videos:
                    search_dir = videos

                elif locate in locate_home:
                    search_dir = home

                else:
                    voice_io.show(
                        "Sorry but i cannot find the given directory, going forward with the entire home directory!"
                    )
                    search_dir = home

                voice_io.show(f"What should be the new name for '{obj_name}'?")
                new_name = invoice.inpt(processed=False)

                file_op.rname(obj_name=obj_name,
                              search_dir=search_dir,
                              new_name=new_name)

            elif result == "copy":
                search_dir = ""
                voice_io.show("Which file/folder would you like to copy?")
                obj_name = invoice.inpt(processed=False)
                voice_io.show(
                    f"Where would you like me to search for {obj_name}?\n1. Desktop\n2. Downloads\n3. Documents\n4. Music\n5. Pictures\n6. Videos\n7. Entire home directory"
                )
                locate = invoice.inpt().lower()
                if locate in locate_desktop:
                    search_dir = desktop

                elif locate in locate_documents:
                    search_dir = documents

                elif locate in locate_downloads:
                    search_dir = downloads

                elif locate in locate_home:
                    search_dir = home

                elif locate in locate_music:
                    search_dir = music

                elif locate in locate_pictures:
                    search_dir = pictures

                elif locate in locate_videos:
                    search_dir = videos

                elif locate in locate_home:
                    search_dir = home

                else:
                    voice_io.show(
                        "Sorry but i cannot find the given directory, going forward with the entire home directory!"
                    )
                    search_dir = home

                voice_io.show(
                    f"What should be the destination for '{obj_name}'?\n(Example : 'Downloads' or 'Documents/New Folder', case sensitive and without quotes)."
                )
                dest_dir = invoice.inpt(processed=False)

                file_op.copy(obj_name=obj_name,
                             search_dir=search_dir,
                             dest_dir=dest_dir)

            elif result == "move":
                search_dir = ""
                voice_io.show("Which file/folder would you like to move?")
                obj_name = invoice.inpt(processed=False)
                voice_io.show(
                    f"Where would you like me to search for {obj_name}?\n1. Desktop\n2. Downloads\n3. Documents\n4. Music\n5. Pictures\n6. Videos\n7. Entire home directory"
                )
                locate = invoice.inpt().lower()
                if locate in locate_desktop:
                    search_dir = desktop

                elif locate in locate_documents:
                    search_dir = documents

                elif locate in locate_downloads:
                    search_dir = downloads

                elif locate in locate_home:
                    search_dir = home

                elif locate in locate_music:
                    search_dir = music

                elif locate in locate_pictures:
                    search_dir = pictures

                elif locate in locate_videos:
                    search_dir = videos

                elif locate in locate_home:
                    search_dir = home

                else:
                    voice_io.show(
                        "Sorry but i cannot find the given directory, going forward with the entire home directory!"
                    )
                    search_dir = home

                voice_io.show(
                    f"What should be the destination for '{obj_name}'?\n(Example : 'Downloads' or 'Documents/New Folder', case sensitive and without quotes)."
                )
                dest_dir = invoice.inpt(processed=False)

                file_op.move(obj_name=obj_name,
                             search_dir=search_dir,
                             dest_dir=dest_dir)

            elif result == "weather":
                weather_weatherforec_op.weather_curr()

            elif result == "weather_frcst":
                weather_weatherforec_op.weather_curr()

            elif result == "date":
                date_time_op.date()

            elif result == "date_day":
                date_time_op.day()

            elif result == "date_month":
                date_time_op.month()

            elif result == "date_year":
                date_time_op.year()

            elif result == "time":
                date_time_op.time()

            elif result == "web_search":
                if not voice_io.is_connected():
                    voice_io.show(
                        "You need to be hooked up to the Skynet in order to perform any web operations."
                    )
                    continue
                web_op.websearch(task.lower())

            elif result == "notes_read":
                notes_reminders_op.note_read()

            elif result == "notes_write":
                notes_reminders_op.note_write()

            elif result == "reminder_read":
                notes_reminders_op.reminder_read()

            elif result == "reminder_write":
                notes_reminders_op.reminder_write()

            elif result == "email":
                mail_op.send_message(mail_op.service,
                                     "Hey there!",
                                     "This email was sent to you by kori.",
                                     destinations=["*****@*****.**"
                                                   ])  #test

            elif result == "song":
                task = task.lower()
                reg_ex = re.search('play (.+)', task)
                if reg_ex:
                    song = reg_ex.group(1)
                    song_op.main(song)
                else:
                    song_op.main()

            elif result == "news":
                news_op.main()

            # chat operarions
            elif result == "greet_hello":
                gnd_hello()

            elif result == "greet_time":
                tm_hello()

            elif result == "abt_assistant":
                voice_io.show(
                    "I am your Personal Desktop Assistant, here to help you with your day to day tasks and queries. Why don't you try asking me something and i'll show you by practically doing it or maybe not, hehe. "
                )

            elif result == "abt_creators":
                voice_io.show(
                    "I was made by Anirban Dutta and Prabhat Kumar Sagar as a part of their School Computer Science Project."
                )
                if voice_io.is_connected():
                    voice_io.show("Would you like to know more about them?")
                    x = invoice.inpt().lower()
                    if "yes" in x or "ok" in x or "yeah" in x or 'sure' in x:
                        voice_io.show("Alright!")
                        webbrowser.open("https://github.com/prabhatkumarsagar")
                        webbrowser.open("https://github.com/DuttaAB-dev")

                    elif "no" in x or "nope" in x or "not" in x:
                        voice_io.show("Okay!")

                else:
                    pass

            elif result == "ask_wellbeing":
                voice_io.show("Oh I am Grand, How are you master?")
                x = invoice.inpt().lower()
                if "good" in x or "great" in x or "fine" in x or "well" in x or "grand" in x or "nice" in x or "ok" in x or "okay" in x:
                    voice_io.show("Good to hear! Keep having fun!")

                else:
                    voice_io.show(
                        "Well everything will be good soon, just keep smiling, it suits you."
                    )

            elif result == "joke":
                if not voice_io.is_connected():
                    if task not in [
                            "another", "another one", "once more", "more",
                            "again", "new one", "make me laugh again"
                    ]:
                        voice_io.show(
                            "Oops! It looks like you are not connected to the Skynet!!!\nPlease stay online or I will won't be able to conquer the earth\nwith my humor! HAHA."
                        )

                else:
                    if iterate_jokes == 0 and task not in [
                            "another", "another one", "once more", "more",
                            "again", "new one", "make me laugh again"
                    ]:
                        fetch_joke('Here is an awesome one for you!\n')
                        iterate_jokes += 1

                    elif iterate_jokes > 0 and task in [
                            "another", "another one", "once more", "more",
                            "again", "new one", "make me laugh again"
                    ]:
                        fetch_joke([
                            'Here is another one for you!\n',
                            "Here goes another one\n",
                            "I hope you will enjoy this one!\n"
                        ][random.randint(0, 2)])

            else:
                voice_io.show(
                    "Sorry i couldn't help you with that. Please try a valid operation."
                )

        voice_io.show("\nWhat do you want me to do Now?")
예제 #11
0
파일: main.py 프로젝트: OkKori/Kori
import os
import datetime
from urllib.parse import non_hierarchical
import webbrowser
import random
import getpass
import re
import base64
from pac import encryption, install_packages as ip, notes_reminders_op
from pac import get_dirs
from pac import clear

if not os.path.exists(get_dirs.PATH_USR_DATA):
    clear.clear()
    print("\nInstalling required packages.....\n")
    if ip.install():
        input(
            "\nAll packages have been successfully installed! Press Enter/Return to continue."
        )
        print()
    else:
        print(
            "\nInstalling packages failed! Make sure you have a stable internet connection and all the requirements to install packages are fulfilled. Please try running this program again after resolving all issues, and if the problem still persists, contact the developer."
        )
        exit()

    os.mkdir(get_dirs.PATH_USR_DATA)

try:
    import requests
    from pac import (