예제 #1
0
def get_news():
    if check_internet_connection():

        # BBC news api
        main_url = " https://newsapi.org/v1/articles?source=bbc-news&sortBy=top&apiKey=3b651a51643045f7a8d0c4ee775c68de"

        # fetching data in json format
        open_bbc_page = requests.get(main_url).json()

        # getting all articles in a string article
        article = open_bbc_page["articles"]

        # empty list which will
        # contain all trending news
        results = []

        for ar in article:
            results.append(ar["title"])

        for i in range(len(results)):

            # printing all trending news
            output(str(i + 1) + " " + results[i])

        return "So these were the top news from today "
    else:
        return "please check your internet connection first"
예제 #2
0
def get_news():

    if check_internet_connection():
        # BBC news api
        main_url = " https://newsapi.org/v1/articles?source=bbc-news&sortBy=top&apiKey=1bf3cdcaf711482589457e06c9936aef"

        # fetching data in json format
        open_bbc_page = requests.get(main_url).json()

        # getting all articles in a string article
        article = open_bbc_page["articles"]

        # empty list which will
        # contain all trending news
        results = []

        for ar in article:
            results.append(ar["title"])

        for i in range(len(results)):

            # printing all trending news
            print(str(i + 1) + " " + results[i])

        return "So these were the top news from today"
    else:
        return "Please Check your internet connection"
def process(query):

    if 'hi' in query :
        return "hello, Sir"
    elif 'hello' in query:
        return "Hi, Sir"
    elif "how are you" in query:
        return "I am fine sir, How are you doing?"
    elif "fine" in query:
        return "okay. What can i do for you sir."
    elif "thanks" in query:
        return "welcome, Sir"
    elif "thank you" in query:
        return "welcome, Sir"
    elif "sorry" in query:
        return "its ok, i never mind"
    elif "ok" in query:
        return "its nice to talk with you, Sir"
    elif "okay" in query:
        return "its nice to talk with you, Sir"
    elif "play music" in query:
        play_misic()
        return "playing music in youtube"
    elif "good morning" in query:
        return "Good Morning, Sir"
    elif "good evening" in query:
        return "Good evening, Sir"
    elif "good afternoon" in query:
        return "Good afternoon, Sir"
    elif "good night" in query:
        output("Good night, Sir")
        quit()
        #return "Good night, Sir"
    elif "open facebook" in query:
        open_facebook()
    elif "open my cv" in query:
        open_cv()
        return "opening your cv now"
    elif "open my google cv" in query:
        open_google_cv()
        return "opening your google cv now"
    elif "open my selling app" in query:
        open_my_selling_app()
        return "opening your selling app now in the browser"
    elif "open simon game" in query:
        open_simon_game()
        return "opening simon game in your browser"
    elif "open movie sentiment app" in query:
        open_my_movie_sentiment_app()
        return "opening movie sentiment app in your browser"
    elif "open movie recommender app" in query:
        open_my_movie_recommend_app()
        return "opening movie recommendation app in your browser"

    elif "search in wikipedia" in query:
        output("say what to search for in wikipedia")
        ans = take_input()
        ans.lower()
        answer = check_on_wiki(ans)
        if answer != "":
            return answer

    elif "search in internet" in query:
        output("say what to search for in internet")
        ans = take_input()
        ans.lower()
        answer = from_internet(ans)
        if answer != "":
            return answer

    elif "recommend me movies" in query:
        movie_recommendation()
        return "Sir, i hope you will like my recommendations."
    elif "recommend me movies again" in query:
        movie_recommendation()
        return "Sir, i hope you will like my recommendations."

    elif "open my github" in query:
        open_my_github()
        return "opening your github account sir"

    elif "open campusx page" in query:
        open_campusx()
        return "opening campusx official page in your browser"

    elif "open github" in query:
        open_github()
        return "opening github in browser"

    elif "activate price predictor module" in query:
        output("activating price predictor module")
        output("what do you want to sell?")
        output("options - mobile or bike or laptop/desktop or car or something else?")
        ans=take_command()
        if ans.lower()=="car":
            predict_car()
            return "I Hope the information would be helpful"
        elif ans.lower()=="mobile":
            predict_mobile()
            return "I Hope the information would be helpful"
        elif ans.lower()=="bike":
            predict_bike()
            return "I Hope the information would be helpful"
        elif ans.lower()=="laptop/desktop":
            predict_laptop()
            return "I Hope the information would be helpful"
        else:
            return (f"sorry, my maker is lazy hence i am still learning how to predict the price of {ans}")

    elif "activate price predictor module again" in query:
        output("activating price predictor module")
        output("what do you want to sell?")
        ans=take_command()
        if ans.lower()=="car":
            predict_car()
            return "I Hope the information would be helpful"
        elif ans.lower()=="mobile":
            predict_mobile()
            return "I Hope the information would be helpful"
        elif ans.lower()=="bike":
            predict_bike()
            return "I Hope the information would be helpful"
        elif ans.lower()=="laptop/desktop":
            predict_laptop()
            return "I Hope the information would be helpful"
        else:
            return (f"sorry, my maker is lazy hence i am still learning how to predict the price of {ans}")



    else:

        answer = get_answer_from_memory(query)

        if answer == "get time details" :
            return ("Time is "+ get_time())

        elif answer == 'quit':
            return ("Good-bye, Sir"+quit())

        elif answer== "check internet connection":
            if check_internet_connection():
                return "Internet is Connected"
            else:
                return "Internet is not Connected"

        elif answer == "tell date":
            return "Date is "+ get_date()

        elif answer == "on speak" :
            return turn_on_speech()

        elif answer == "off speak":
            return turn_off_speech()

        elif answer == "open facebook":
            open_facebook()
            return "opening facebook now"

        elif answer == "open google":
            open_google()
            return "opening google now"

        elif answer == "open browser":
            open_google()
            return "opening browser now"

        elif answer == "close browser":
            close_browser()
            return "Browser closed."

        elif answer == "change name":
            output("Okay! what do you want call me?")
            temp = take_command()
            if temp == assistant_details.name:
                return "Can't change. Its just my previous name"
            else:
                update_name(temp)
                assistant_details.name=temp
                return ("Now you can call me " + temp)

        else:

                return "Say that again please!"
def process(self,quest):

    answer = database.get_answers_from_memory(quest)
    
    if answer == "get time details":
        return(f'Time is {get_time()}')

    elif answer == "check internet connection":
        if internet.check_internet_connection():
            return "internet is connected"
        else:
            return "internet is not connected"
    
    elif answer == 'tell date':
        return ("date is "+get_date())

    elif answer == '100':
        return('I am fine, Thank you How are you, Sir')

    elif answer == '101':
        return("It's good to know that you are fine")

    elif answer == '102':
        return(f"my friend call me {assistant_details.name}")

    elif answer == "103":
        return("i have been created by KP KETAN KISHAN")

    elif answer == "104":
        return (pyjokes.get_joke())

    elif answer == "105":
        return ("if you talk then definately you are human")

    elif answer == "106":
        return("Thanks to KP. Further it is secret")

    elif answer == "107":
        return ("i am you virtual assistant created on 9th september")

    elif answer == "108":
        return ("i was created as a minor project by kumar priyanshu,ketan shah,kishan guta ")

    elif answer == "109":
        return (system_task.power_point())

    elif answer == "close powerpoint":
        return (system_task.close_powerpoint())

    elif answer == "110":
        speak("say your context")
        usertext = take_input(self)
        system_task.note(usertext)
        return("taken note of that")     
 
    elif answer == "close notepad":
        k=system_task.close_notepad()
        return(k)   

    elif answer == "111":
        return ("i'm not sure about, may be you should give me some time")

    elif answer == "112":
        return ("it's hard to understand")

    elif answer == "on speak":
        return database.turn_on_speech()

    elif answer == "off speak":
        return database.turn_off_speech()

    elif answer == 'music':
        system_task.play_music()
        return "playing song"

    elif answer == 'video':
        system_task.videos()
        return ("playing video")

    elif answer == 'focus':
        return (system_task.play_focus())

    elif answer == 'photo':
        system_task.photo()
        return ("opening photo")

    elif answer == 'chrome':
        return (system_task.chrome())

    elif answer == 'close chrome':
        return (system_task.close_chrome())

    elif answer == 'sublime text':
        return (system_task.sublime_text())

    elif answer == 'close sublime text':
        return (system_task.close_sublime_text())

    elif answer == 'vs code':
        return (system_task.vs_code())

    elif answer == 'close vs code':
        return (system_task.close_vs_code())

    elif answer == 'shell':
        return (system_task.shell())

    elif answer == 'word':
        return (system_task.word())

    elif answer == 'close word':
        return (system_task.close_word())

    elif answer == 'excel':
        return (system_task.excel())

    elif answer == 'close excel':
        return (system_task.close_excel())

    elif answer == "open facebook":
        open_facebook()
        return "opening facebook"

    elif answer == "close facebook":
        close_facebook()
        return "closing facebook"

    elif answer == "open google":
        open_google()
        return "opening google"

    elif answer == "open spotify":
        open_spotify()
        return "opening spotify"

    elif answer == "open geeksforgeeks":
        open_gfg()
        return "opening geeks for geeks"

    elif answer=="open youtube":
        open_youtube()
        return("opening youtube")

    elif answer=="open wynk":
        open_wynk()
        return "opening wynk"

    elif answer=="open stackof":
        open_stackof()
        return "opening stack over flow"

    elif answer=="open git":
        open_git()
        return "opening github"

    elif answer=="comsites":
        responded=open_comsites(self)
        return (f"opening {responded}")

    elif answer=="sites":
        responded=open_sites(self)
        return (f"opening {responded}")

    elif answer=="image search":
        responded=imgsearch(quest)
        return (f"opening {responded}")
    
    elif answer=="search":
        responded=search(quest)
        return (f"showing results for {responded}")

    elif answer=="play":
        responded=play(quest)
        return (f"playing... {responded}")

    elif answer=="whatsapp":
        return(open_whatsapp(self))

    elif answer == 'change name':
        give_output("okay! what do you want to call me")
        temp = take_input(self)
        if temp == assistant_details.name:
            return "can't change. i think you're happy with my old name"
        else:
            database.update_name(temp)
            assistant_details.name=temp
            return "now you can call me "+ temp
    
    elif answer == "0":
        return "say again"

    elif answer == "turn off":
        return "signing off sir"
    else:
        try:
            res = client.query(quest)
            if res['@success']=='true':
                pod1=res['pod'][1]
                result = pod1['subpod']['plaintext']
                if (('definition' in pod1['@title'].lower()) or ('result' in  pod1['@title'].lower()) or (pod1.get('@primary','false') == 'true')):
                    if result == '(data not available)':
                        answer = internet.check_on_wikipedia(quest+" wikipedia")
                        if answer!="":
                            return answer
                        else:
                            addq=adding_query(self,quest)
                            return addq
                    else:
                        return result
                else:
                    answer = internet.check_on_wikipedia(quest+" wikipedia")
                    if answer!="":
                        return answer
                    else:
                        addq=adding_query(self,quest)
                        return addq
            else:
                answer = internet.check_on_wikipedia(quest+" wikipedia")
                if answer!="":
                    return answer
                else:
                    addq=adding_query(self,quest)
                    return addq
        except Exception as e:
            return (e)
예제 #5
0
def process(query):

    query = query.lower()
    name = assistant_details.name
    query = query.replace(name, "")

    noAnswer = [
        "Sorry, can't understand you", "Please give me more info",
        "Not sure I understand"
    ]

    if len(query) <= 1:
        return random.choice(noAnswer)

    if "quit" in query:
        umbrella()
        output("Thank You!!! See You Soon")
        exit()

    if query == "--help" or query == "--h":
        help(query)
        return "What can I do for you?"

    if "game" in query:
        answer = get_answer_from_memory("play game")

    elif 'play' in query and 'music' not in query and 'songs' not in query:
        answer = get_answer_from_memory("play")

    elif 'weather' in query:
        answer = get_answer_from_memory("weather")

    elif 'location' in query:
        answer = get_answer_from_memory("location")

    elif 'search' in query:
        answer = get_answer_from_memory("search")

    elif 'send mail' in query or 'send email' in query:
        answer = get_answer_from_memory("send email")

    elif 'calculate' in query:
        answer = get_answer_from_memory("calculate")

    elif 'map' in query:
        answer = get_answer_from_memory("google map")

    elif 'remind me' == query.lower() or 'alarm' in query.lower():
        if 'remind me' == query.lower():
            output("Enter msg to remind")
            msg = take_input()
            output("Enter time(like 11:15)")
            time = take_input()
            output("Enter date(like 21 july)")
            date = take_input()
            res = 'remind me to ' + msg + 'at ' + time + 'on ' + date

            return remind(res)

        else:
            msg = "Alarm"
            output("Enter time(like 11:15)")
            time = take_input()
            output("Enter date(like 21 july)")
            date = take_input()
            res = 'remind me to ' + msg + 'at ' + time + 'on ' + date
            remind(res)
            return "Alarm Set"
    elif 'remind me' in query.lower():
        answer = get_answer_from_memory("remind me")
    else:
        answer = get_answer_from_memory(query)

    # print("answer - ", answer)

    # Check query

    if answer == "get time details":
        return ('Time is ' + get_time())

    elif answer == "change name":
        output("Okay! what do u want to call me")
        temp = take_input()
        if temp == assistant_details.name:
            return "Can't change. I think you are happy with my old name"
        else:
            update_name(temp)
            assistant_details.name = temp
            return "Now you can call me " + temp

    elif answer == "tell date":
        return "Date is " + get_date()

    elif answer == "on speak":
        return turn_on_speech()

    elif answer == "off speak":
        return turn_off_speech()

    elif answer == "on listen":
        return turn_on_listen()

    elif answer == "off listen":
        return turn_off_listen()

    elif answer == "play game":
        return play_game()

    elif answer == "open facebook":
        open_facebook()
        return "opening facebook"

    elif answer == "open google":
        open_google()
        return "opening google"

    elif answer == "close browser":
        close_browser()
        return "closing browser"

    elif answer == "check internet connection":
        if check_internet_connection():
            return "Internet is Connected"
        else:
            return "Internet Not Connected"

    elif answer == "play music":
        return play_music()

    elif answer == "pause music":
        return pause_music()

    elif answer == "stop music":
        return stop_music()

    elif answer == "next song":
        return next_song()

    elif answer == "previous song":
        return previous_song()

    elif answer == "play":
        music = play_specific_song(query)
        if "not found" in music:
            output("Song not found, Should i search on youtube!")
            res = take_input()
            if "yes" in res.lower():
                open_youtube_song(query.replace('play ', ''))
                return ("Searching on YouTube")
            else:
                return ('Okay')
        else:
            return music

    elif answer == 'search':
        if 'youtube' in query:
            query = query.replace('search ', '')
            query = query.replace(' on youtube', '')
            search_youtube(query)
            return "Searching youtube"
        else:
            query = query.replace('search ', '')
            query = query.replace(' google', '')
            query = query.replace(' on google', '')
            search_google(query)
            return "Searching Google"

    elif answer == "change wallpaper":
        return change_wallpaper()

    elif answer == "get news":
        return get_news()

    elif answer == "weather":
        place = query.replace('weather', '')
        return check_weather(place)

    elif answer == "location":
        return get_location()

    elif answer == "nearby":
        query = query.replace('nearby ', '')
        return search_near(query)

    elif answer == 'calculate':
        return calculator(query)

    elif answer == "map":
        indx = query.lower().split().index('map')
        que = query.split()[indx + 1:]
        cmd = 'python map.py ' + ' '.join(que)
        os.system(cmd)
        return "Opening Google Map"

    elif answer == "direction":
        output("Start location (if current location leave blank)")
        start_place = take_input()
        output("Destination")
        end_place = take_input()
        if start_place == None:
            return directions(end_place)
        else:
            return directions(end_place, start_place)

    elif answer == "mail":
        name = query.replace("send email to ", "")
        mail = get_emailId(name)
        if mail == '0':
            output("Email Id not found in database, please input mail id")
            mail = take_input()
            insert_emailId(name, mail)
            output("mail id inserted to database")

        output("Enter message to send to " + name)
        msg = take_input()

        return sending_mail(name, mail, msg)

    elif answer == "send msg":
        output("Enter Contact Number ")
        number = take_input()
        output("Enter message to send to " + number)
        msg = take_input()

        return sending_text(msg, number)

    elif answer == 'remind me':
        remind(query)
        return "Reminder Set"

    else:
        res = response(query)
        if res != '0':
            return res

        else:
            output("Dont know this one should i search on internet?")
            ans = take_input()
            if "yes" in ans:
                output("Searching Wikipedia...")
                answer = check_on_wikipedia(query)
                if answer != "":
                    return answer
            else:

                output("Can you please tell me what it means?")
                ans = take_input()
                if "it means" in ans:
                    ans = ans.replace("it means", "")
                    ans = ans.strip()

                    value = get_answer_from_memory(ans)

                    if value == "":
                        return "Can't help with this one"

                    else:
                        insert_question_and_answer(query, value)
                        return "Thanks, I will remember it for the next time"

                else:
                    return "Can't help with this one"

            return "Nothing"
예제 #6
0
def process(query):

    if 'hi' in query :
        return "hello, Sir"
    elif 'hello' in query:
        return "Hi, Sir"
    elif "how are you" in query:
        return "I am fine sir, How are you doing?"
    elif "fine" in query:
        return "okay. What can i do for you sir."
    elif "thanks" in query:
        return "welcome, Sir"
    elif "thank you" in query:
        return "welcome, Sir"
    elif "welcome" in query:
        return "hehe, Sir you are a nice person"
    elif "are you a girl" in query:
        return "what do you think, sir"
    elif "girl" in query:
        return "sir, you are very smart"
    elif "i think you are a girl" in query:
        return "i have no doubt, sir"
    elif "boy" in query:
        return "Sir, i am a girl"
    elif "i think you are a boy" in query:
        return "Nice joke sir, but it was not funny"
    elif "sorry" in query:
        return "its ok, i never mind"
    elif "who is your creator" in query:
        return "My creator is Lord Tuhin Mukherjee"
    elif "ok" in query:
        return "its nice to talk with you, Sir"
    elif "okay" in query:
        return "its nice to talk with you, Sir"
    elif "ok i got it" in query:
        return "its nice to talk with you, Sir"
    elif "okay i got it" in query:
        return "its nice to talk with you, Sir"

    else:

        answer = get_answer_from_memory(query)

        if answer == "get time details" :
            return ("Time is "+ get_time())

        elif answer == 'quit':
            return ("Good-bye, Sir"+quit())

        elif answer== "check internet connection":
            if check_internet_connection():
                return "Internet is Connected"
            else:
                return "Internet is not Connected"

        elif answer == "tell date":
            return "Date is "+ get_date()

        elif answer == "on speak" :
            return turn_on_speech()

        elif answer == "off speak":
            return turn_off_speech()

        elif answer == "open facebook":
            open_facebook()
            return "opening facebook now"

        elif answer == "open google":
            open_google()
            return "opening google now"

        elif answer == "open browser":
            open_google()
            return "opening browser now"

        elif answer == "close browser":
            close_browser()
            return "Browser closed."

        elif answer == "change name":
            output("Okay! what do you want call me?")
            temp = take_input()
            if temp == assistant_details.name:
                return "Can't change. Its just my previous name"
            else:
                update_name(temp)
                assistant_details.name=temp
                return ("Now you can call me " + temp)


        else:

            output("Don't know this one. Should i search in wikipedia or in Internet?")
            ans = take_input()
            ans.lower()
            if "wikipedia" in ans:
                answer = check_on_wiki(query)
                if answer != "":
                    return answer

            elif "internet" in ans :
                answer = from_internet(query)
                if answer != "":
                    return answer



            else:

                output("Can you please tell me what it means?")
                ans=take_input()
                if "it means" in ans:
                    ans = ans.replace("it means","")
                    ans=ans.strip()

                    value=get_answer_from_memory(ans)
                    if value=="":
                        return ("Can't help with this one")

                    else:
                        inset_question_and_answer(query, value)
                        return ("Thanks, I will remember it for the next time")

                else:

                    return "Can't help with this one!"
예제 #7
0
def process(query):

    if 'play' in query and 'music' not in query:
        answer = get_answer_from_memory('play')
    else:
        answer = get_answer_from_memory(query)

    if answer == "get time details":
        return ("Time is " + get_time())

    elif answer == "check internet connection":
        if check_internet_connection():
            return "internet is connected"
        else:
            return "internet is not connected"

    elif answer == "tell date":
        return "Date is " + get_date()

    elif answer == "on speak":
        return turn_on_speech()

    elif answer == "off speak":
        return turn_off_speech()

    elif answer == "close browser":
        close_browser()
        return "closing browser"

    elif answer == "open facebook":
        open_facebook()
        return "opening facebook"

    elif answer == "open google":
        open_google()
        return "opening google"

    elif answer == "play music":
        return play_music()

    elif answer == 'play':
        return play_specific_song(query)

    elif answer == "pause music":
        return pause_music()

    elif answer == "stop music":
        return stop_music()

    elif answer == "next song":
        return next_song()

    elif answer == "previous song":
        return previous_song()

    elif answer == 'change wallpaper':
        return change_wallpaper()

    elif answer == 'get news':
        return get_news()

    elif answer == 'change name':
        output("Okay! what do you want to call me")
        temp = take_input()
        if temp == assistant_details.name:
            return "Can't change. I think you're happy with my old name"
        else:
            update_name(temp)
            assistant_details.name = temp
            return "Now you can call me " + temp

    else:
        output("Dont know this one should i search on internet?")
        ans = take_input()
        if "yes" in ans:
            answer = check_on_wikipedia(query)
            if answer != "":
                return answer

        else:
            output("can you please tell me what it means?")
            ans = take_input()
            if "it means" in ans:
                ans = ans.replace("it means", "")
                ans = ans.strip()

                value = get_answer_from_memory(ans)
                if value == "":
                    return "Can't help with this one "

                else:
                    insert_question_and_answer(query, value)
                    return "Thanks i will remember it for the next time"

            else:
                return "can't help with this one"