Ejemplo n.º 1
0
def Execution():
    #Note:the code below the lines from 60 to 81 can be edited. In case you want to make your own skill and the other part of the code should not be edited
    command = listentouser().lower()
    if 'wikipedia' in command:
        command = command.replace('wikipedia', '')
        results = wikipedia.summary(command)
        print("Saaketh Said:", command)
        print(results)
        speak(results)
    elif 'play' in command:
        print("Saaketh Said:", command)
        print("Hover Said: Playing", command)
        command = command.replace('play', '')
        speak("playing" + command)
        pywhatkit.playonyt(command)
    elif 'open' and 'on brave' in command:
        bravepath = "C://Program Files//BraveSoftware//Application//brave.exe"
        web.get(bravepath).open('https://google.com')
    elif 'shutdown' in command:
        a = int(input("after how much time:"))
        pywhatkit.shutdown(time=a)
        if 'cancel shutdown' in command:
            pywhatkit.cancelShutdown()
    elif 'i donot need anything' in command or 'bye' in command:
        sys.exit()
    else:
        speak('I donot know that')
Ejemplo n.º 2
0
def Cancel_Shutdown():
    try:
        pywhatkit.cancelShutdown()
        messagebox.showinfo("Shutdown Cancelled.",
                            "Shutdown Scheduled time cancelled Successfully.")
    except NameError:
        messagebox.showwarning("No Schedule.",
                               "Shutdown is not been Scheduled.")
Ejemplo n.º 3
0
def run_alexa():
    command = take_command()
    print(command)
    if 'play' in command:
        song = command.replace('play', '')
        talk('playing ' + song)
        pywhatkit.playonyt(song)
    elif 'time' in command:
        time = datetime.datetime.now().strftime('%I:%M %p')
        talk('The time right now is ' + time)
    elif 'tell me about' in command:
        person = command.replace('tell me about', '')
        info = wikipedia.summary(person, 2)
        print(info)
        talk(info)
    elif 'sad' in command:
        talk('Everything will be fine')
    elif 'bored' in command:
        talk('You can ask me to say some Jokes, Sir')
    elif 'joke' in command:
        talk(pyjokes.get_joke())
    elif 'how are you' in command:
        talk('I am very happy and glad to help you')
    elif 'happy' in command:
        talk('I am happy because you are happy')
    elif 'funny' in command:
        talk('Oh nice, may i tell you another joke?')
    elif 'who are you' in command:
        talk('I am Jarvis your personal assistant and always at you service')
    elif 'who is your developer' in command:
        talk(
            'Mehul Totala made me and gave me this life. I am thankful to him for making me.'
        )
    elif 'search' in command:
        search = command.replace('search', '')
        pywhatkit.search(search)
    elif 'message' in command:
        talk('please type the message')
        number = input('Number: ')
        message = input('message: ')
        hrs = int(input('Hours: '))
        min = int(input('Min: '))
        pywhatkit.sendwhatmsg(number, message, hrs, min)
    elif 'shutdown' in command:
        talk('OK, Closing pc down in 50 seconds')
        pywhatkit.shutdown(50)
    elif 'cancel' in command:
        talk('OK')
        pywhatkit.cancelShutdown()
    else:
        talk('Please ask Mehul to add answer to your command')
Ejemplo n.º 4
0
def shut_timer():
    sh_time = sleep.get()

    if sh_time == 0:
        try:
            pywhatkit.cancelShutdown()
            messagebox.showinfo("Shutdown Timer",
                                "Shutdown timer is not fixed")
        except NameError:
            messagebox.showinfo("Shutdown Timer",
                                "Shutdown timer is not fixed")

    elif sh_time <= 86400:
        messagebox.showinfo(
            "Shutdown Timer",
            "When we sent WhatsApp message PC will shutdown after fixed timer")
        pywhatkit.shutdown(time=sh_time)
    else:
        messagebox.showinfo("Shutdown Timer",
                            "Shutdown timer is Greater than 24hrs.")
Ejemplo n.º 5
0
                whenH = takecommand()
                talk('at what minutes do you want me to send')
                whenM = takecommand()
                sendwhatsapp(to, content, whenH, whenM)
                talk('message sent sir')
            except Exception as e:
                print(e)
                talk('I am sorry sir...., I am not able to sent the message')

        elif 'shut down my' in command:
            talk('okay sir as you commanded')
            pywhatkit.shutdown(90)
            talk(
                'the computer will be shutting down in less than t minus 90 seconds'
            )

        elif 'cancel shutdown' in command:
            talk('as you commanded to terminate shutdown')
            pywhatkit.cancelShutdown()
            talk('I have terminated the shutdown for you sir')

        elif 'Thanks you' in command:
            talk('not a problem sir ')
            talk('its my responsibility sir')

        # elif 'lets talk' in command:
        #     talk('I have somethings to catch up')
        #     talk('meet my friend SARA')
        #     talk('She is a chat_bot')
        #     chat_bot.main()
Ejemplo n.º 6
0
def run_alexa():
    command = take_command()

    if 'multiply' in command:
        numbers = map(int, re.findall(r'[0-9]+', command))
        talk("The answer is " + str(calculate(list(numbers), 3)))
    elif any(i in command for i in ['add', 'sum', 'plus', '+']):
        numbers = map(int, re.findall(r'[0-9]+', command))
        talk("The answer is " + str(calculate(list(numbers), 1)))
    elif any(i in command for i in ['minus', 'sub', 'subtract', '-']):
        numbers = map(int, re.findall(r'[0-9]+', command))
        talk("The answer is " + str(calculate(list(numbers), 2)))
    elif any(i in command for i in ['divide', 'div']):
        numbers = map(int, re.findall(r'[0-9]+', command))
        talk("The answer is " + str(calculate(list(numbers), 4)))
    elif any(i in command for i in ['modulus', 'mod']):
        numbers = map(int, re.findall(r'[0-9]+', command))
        talk("The answer is " + str(calculate(list(numbers), 5)))
    elif any(i in command for i in ['power', 'pow']):
        numbers = map(int, re.findall(r'[0-9]+', command))
        talk("The answer is " + str(calculate(list(numbers), 6)))
    elif 'game' in command:
        talk('Ok! I will guess a number between 1 to 10, Just find it.')
        r = random.randint(1, 10)
        num = take_command()
        try:
            n = w2n.word_to_num(num)
            n = int(n)
            if n == r:
                talk("Hurray! You won the game")
            else:
                talk("I won! Thanks for playing!")
        except:
            talk("Only numbers allowed! Thanks for playing!")
    elif 'play' in command:
        song = command.replace('play', '')
        talk('playing ' + song)
        pywhatkit.playonyt(song)
    elif 'time' in command:
        time1 = datetime.datetime.now().strftime('%I:%M %p')
        talk('Current time is ' + time1)
    elif 'date' in command:
        date = datetime.datetime.now().strftime('%d:%B:%Y')
        talk('Today is ' + date)
    elif any(i in command for i in ['search', 'find', 'who', 'get']):
        data = wikipedia.summary(command, 3)
        talk(data)
    elif 'joke' in command:
        talk(pyjokes.get_joke())
    elif 'send' in command:
        number = re.findall(r'[0-9 ]+', command)
        num = [i.replace(' ', '') for i in number if len(i) > 1][0]
        if len(num) != 10:
            talk("Please provide a valid number !")
            return
        datet = datetime.datetime.now()
        pywhatkit.sendwhatmsg('+91' + num, 'Hii', int(datet.strftime('%H')),
                              int(datet.strftime('%M')) + 1)
    elif 'cancel shut' in command:
        pywhatkit.cancelShutdown()
        talk('System Shutdown Cancelled!')
    elif 'shutdown' in command:
        pywhatkit.shutdown(100)
        talk('System is going to shutdown!')
    elif bool(re.search(r'\.[a-zA-Z0-9]{2,3}', command)):
        url = command.replace('open', '').strip()
        print(url)
        webbrowser.open_new_tab(url if 'http' in url else 'https://' + url)
        talk('Opening ' + url + 'in chrome ')
    elif 'open' in command:
        app = command.replace('open', '').strip()
        app = ''.join(app.split())
        if 'computer' in app:
            subprocess.Popen(r'explorer /select,"C:\"' + app, shell=True)
            talk('Opening ' + app)
            return
        elif any(i in app for i in ['whatsapp', 'msteams', 'spotify']):
            subprocess.Popen(r'start ' + app + ':', shell=True)
            talk("Opening  " + app)
            return
        elif 'camera' in app:
            cam = cv2.VideoCapture(0)
            talk('Opening Camera! To capture image press spacebar once!')
            while cam.isOpened():
                ret, frame = cam.read()
                cv2.imshow('Camera', frame)
                k = cv2.waitKey(50)
                if k == 32:
                    r = random.randint(10, 10000)
                    cv2.imwrite(f'captured{r}.png', frame)
                    talk(
                        f'Image captured and saved as captured{r} into current directory!'
                    )
                if cv2.getWindowProperty('Camera', cv2.WND_PROP_VISIBLE) < 1:
                    break
            cam.release()
            cv2.destroyAllWindows()
            return
        elif 'python' in app:
            n = os.startfile('python.exe')
            if n:
                talk('Sorry! I cant Open ' + app)
                return
            talk('Opening ' + app)
            return
        elif 'chrome' in command:
            webbrowser.open_new_tab('https://google.com')
            talk("Opening  " + app)
            return
        try:
            # n = subprocess.Popen(app, stderr=subprocess.PIPE)
            n = subprocess.Popen(f'explorer {app}')
            print(os.path.realpath(app))
            talk("Opening  " + app)
        except:
            talk("Sorry I can't open " + app)
    elif 'close' in command:
        app = command.replace('close', '').strip()
        app = ''.join(app.split())
        # print(app)
        flag = 0
        for process in (process for process in psutil.process_iter()
                        if app in process.name().lower()):
            process.kill()
            flag = 1
        if flag:
            talk('Closing ' + app)

    elif any(i in command for i in ['count', 'startcounter', 'starttimer']):
        num = re.findall(r'[0-9]+', command)
        num = sorted(map(int, num))
        if num:
            for i in range(num[0], num[1] + 1):
                talk(i)
                time.sleep(1)
        else:
            for i in range(1, 11):
                talk(i)
                time.sleep(1)
    elif any(i in command for i in ['goodnight', 'sweetdreams', 'night']):
        talk('Good night! Sweet dreams and takecare!')
        return 1
    elif any(i in command for i in ['goodmorning', 'morning']):
        talk('Morning! It’s good to see you!')
    elif bool(re.match(r'your.*?name', command)):
        talk('I am Nandyalexa, how may I help you?')
    elif 'single' in command:
        talk('I am already in relationship with nandy!')
    elif 'weather' in command:
        place = [
            i for i in re.split(r'weather|in ', command) if len(i) > 1 and i
        ][-1]
        data = openweathermap('api.openweathermap.org/data/2.5/weather?',
                              place=place)
        # print(data)
        string = f'Current weather status in {place} is {data[0]}, Temperature in {place} is {data[1]}, Pressure in {place} is {data[2]}, and Wind Speed in {place} is {data[3]}'
        talk(string)
    elif 'where' in command:
        print(command)
        js = requests.get('https://freegeoip.app/json/').json()
        talk(
            f"Your Country is {js['country_name']}, Your Region is {js['region_name']}, Your city is {js['city']}, and Your Time zone is {js['time_zone']}"
        )

    elif 'screen' in command:
        global degree
        screen = rotatescreen.get_primary_display()
        if any(i in command for i in ['default', '0', 'stop']):
            degree = 0
            screen.rotate_to(degree)
            talk('Screen set to normal!')
            return
        screen.rotate_to(degree % 360)
        talk('Screen rotated to ' + str(degree))
        degree += 90
    elif 'translate' in command:
        translator = Translator()
        talk('What is the source language which you are gonna speak?')
        from_lang = get_languagecode(take_command().strip())
        print(from_lang)
        talk('What is the destination language which needs to be translated?')
        to_lang = get_languagecode(take_command().strip())
        talk("what message to be translated?")
        get_message = take_command()
        text_to_translate = translator.translate(get_message,
                                                 src=from_lang,
                                                 dest=to_lang)
        text = text_to_translate.text
        speak = gTTS(text=text, lang=to_lang, slow=False)
        speak.save("captured_voice.mp3")
        music = pyglet.media.load("captured_voice.mp3", streaming=False)
        music.play()
        time.sleep(music.duration)  # prevent from killing
        os.remove("captured_voice.mp3")  # remove temperory file
    elif 'sleep' in command.strip():
        talk("Ok sir! I won't disturb you for a minute")
        time.sleep(60)
        talk()
    else:
        talk('Please say the command again ! ')
Ejemplo n.º 7
0
import pywhatkit

pywhatkit.cancelShutdown()  #Will cancel scheduled shutdown
Ejemplo n.º 8
0
def startAlexa():
    dir = "C:\\songsAlexa"
    if not os.path.exists(dir):
        os.makedirs(dir, exist_ok=True)
    '''
    -------------------------------------------------------------------------------------------------------------------------------------------------------------------------------
    Author:::::::: Suvansh
    Contact::::::: [email protected]
    Date:::::::::: 10-12-2020
    python:::::::: 3.6.8
    -------------------------------------------------------------------------------------------------------------------------------------------------------------------------------
    '''
    global a
    firsttime = True
    FA.PrSpeak("Say Alexa To Start This App")
    while True:
        query = FA.start().lower()
        while "alexa" not in query:
            if "alexa" in query:
                break
            else:
                query = FA.start().lower()
        FA.typeing("Starting This App...\n")
        if firsttime == True:
            FA.wishMe()
        while True:
            query = FA.takeCommand().lower()
            # !-------------------------------------------------------------------------------------------------
            #? ------------------------------------------Searches--------------------------------------------------------
            # !-------------------------------------------------------------------------------------------------

            if 'full wikipedia' in query:
                try:
                    FA.PrSpeak('Searching Wikipedia...')
                    query = query.replace("full wikipedia", "")
                    results = wikipedia.summary(query, sentences=999999999999)
                    FA.PrSpeak("According To Wikipedia...")
                    print(results)
                    FA.speak(results)
                except:
                    FA.PrSpeak(
                        f"Sorry I Was Not Able To Desplay The Result Because Of Some Issues"
                    )

            elif 'ful wikipedia' in query:
                try:
                    FA.PrSpeak('Searching Wikipedia...')
                    query = query.replace("ful wikipedia", "")
                    results = wikipedia.summary(query, sentences=999999999999)
                    FA.PrSpeak("According To Wikipedia...")
                    print(results)
                    FA.speak(results)
                except:
                    FA.PrSpeak(
                        f"Sorry I Was Not Able To Desplay The Result Because Of Some Issues"
                    )

            elif 'wikipedia' in query:
                try:
                    FA.PrSpeak('Searching Wikipedia...')
                    query = query.replace("wikipedia", "")
                    results = wikipedia.summary(query, sentences=2)
                    FA.PrSpeak(results)
                except:
                    FA.PrSpeak(
                        f"Sorry I Was Not Able To Desplay The Result Because Of Some Issues"
                    )


# todo---------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------

#!------------------------------------------------------------------------------------------------------
#?--------------------------------------------Opens-----------------------------------------------------------------------
#!------------------------------------------------------------------------------------------------------
            elif 'open gmail' in query:
                FA.PrSpeak("Opening Gmail...")
                webbrowser.open("gmail.com")
                FA.PrSpeak("Opened Gmail")

            elif 'open gaana' in query:
                FA.PrSpeak("Opening Ganna")
                webbrowser.open("gaana.com")
                FA.PrSpeak("Opened Gaana")

            elif 'open stack overflow' in query:
                FA.PrSpeak("Opening StackOverFlow...")
                webbrowser.open("stackoverflow.com")
                FA.PrSpeak("Opened StackOverFlow")

            elif 'open google' in query:
                FA.PrSpeak("Opening Google...")
                webbrowser.open("google.com")
                FA.PrSpeak("Opened Google")

            elif 'open youtube' in query:
                FA.PrSpeak("Opening YouTube...")
                webbrowser.open("youtube.com")
                FA.PrSpeak("Opened YouTube")

            elif 'open ms teams' in query or 'open microsoft teams' in query:
                FA.PrSpeak("Opening MicroSoftTeams...")
                webbrowser.open("teams.microsoft.com")
                FA.PrSpeak("Opened MicrosoftTeams")

            elif 'open code' in query or "open vs code" in query or 'open visual studio code' in query:
                try:
                    FA.PrSpeak("Opening Visual Studio Code...")
                    codePath = "C:\\Users\\suvan\\AppData\Local\\Programs\\Microsoft VS Code\\Code.exe"
                    os.startfile(codePath)
                    FA.PrSpeak("Opened Visual Studio Code")
                except:
                    FA.PrSpeak(
                        f"Sorry My Friend I Was Not Able To Open Visual Studio Code Because Of Some Issue"
                    )

            elif 'open file explorer' in query or 'open explorer' in query:
                FA.PrSpeak("Opening File Explorer...")
                subprocess.Popen('explorer')
                FA.PrSpeak("Opened File Explorer")

            elif 'open zoom' in query:
                try:
                    FA.PrSpeak("Opening Zoom...")
                    zoom = FA.path.get("zoom")
                    os.startfile(zoom)
                    FA.PrSpeak("Opened Zoom")
                except:
                    FA.PrSpeak(
                        f"Sorry My Friend I Was Not Able To Open Zoom Because Of Some Issue"
                    )

            # !-------------------------------------------------------------------------------------------------------------------------
    # ?--------------------------------------------Closes------------------------------------------------------------------------
    # !--------------------------------------------------------------------------------------------------------------------------
            elif 'close file explorer' in query:
                try:
                    FA.PrSpeak("Closing File Explorer...")
                    FA.closeFile("explorer.exe", "Explorer")
                    FA.PrSpeak("Closed File Explorer")
                except:
                    FA.PrSpeak(
                        f"Sorry My Friend I Was Not Able To Close File Explorer"
                    )

            elif 'close hitman' in query:
                try:
                    FA.PrSpeak("Closing Hitman...")
                    os.system("TASKKILL /F /IM HMA.exe")
                    FA.PrSpeak("Closed Hitman")
                except:
                    FA.PrSpeak(
                        f"Sorry My Friend I Was Not Able To Close Hitman")

            elif 'close code' in query or 'close vs code' in query or 'close visual studio code' in query:
                try:
                    FA.PrSpeak("Closing Visual Studio Code...")
                    os.system('TASKKILL /F /IM Code.exe')
                    FA.PrSpeak("Closed Visual Studio Code")
                except:
                    FA.PrSpeak(
                        f"Sorry My Friend I Was Not Able To Close Visual Studio Code"
                    )

            elif 'close zoom' in query:
                try:
                    FA.PrSpeak("Closing Zoom...")
                    os.system('TASKKILL /F /IM Code.exe')
                    FA.PrSpeak("Closed Zoom")
                except:
                    FA.PrSpeak(f"Sorry My Friend I Was Not Able To Close Zoom")
            # !--------------------------------------------------------------------------------------------------------------------------
    #? ---------------------------------------------Others--------------------------------------------------------------------------
    # !--------------------------------------------------------------------------------------------------------------------------
            elif 'codewithharry' in query:
                FA.PrSpeak("Opening Channel CodeWithHarry...")
                webbrowser.open(
                    "www.youtube.com/channel/UCeVMnSShP_Iviwkknt83cww")
                FA.PrSpeak("Opened Channel CodeWithHarry")

            elif 'search in youtube' in query:
                FA.PrSpeak("Searching Youtube...")
                a = query
                a = a.split("youtube")
                kit.playonyt(a[1])
                FA.PrSpeak("Searched Youtube")

            elif 'shut down my pc' in query:
                try:
                    FA.PrSpeak(
                        "Shutting Down Your Pc And Wating For 10 Seconds For Your Cancel Shut Down Command..."
                    )
                    kit.shutdown(10)
                except:
                    FA.PrSpeak(f"Unable To Shut Down Your Pc")

            elif 'cancel shut down' in query:
                try:
                    FA.PrSpeak("Cancelling...")
                    kit.cancelShutdown()
                    FA.PrSpeak("Canceled")
                except:
                    FA.PrSpeak("Unable To Cancel Shutdown")

            elif 'play music' in query:
                try:
                    music_dir = "C:\\songsAlexa"
                    songs = os.listdir(music_dir)
                    if len(songs) > 1:
                        FA.PrSpeak("Playing Random Music...")
                        os.startfile(
                            os.path.join(music_dir,
                                         songs[random.randint(1, len(songs))]))
                        FA.PrSpeak("Played Random Music")
                    else:
                        FA.PrSpeak("Playing Random Music...")
                        os.startfile(os.path.join(music_dir, songs[0]))
                        FA.PrSpeak("Played Random Music")
                    FA.PrSpeak(
                        "If You Want To Add Songs You Can Go To c:\\songsAlexa And Add More Songs In It"
                    )
                except:
                    FA.PrSpeak(
                        f"Sorry I Was Not Able To Play Music Please Add Songs In C:\\songsAlexa"
                    )

            elif 'send email' in query:
                try:
                    FA.speak(
                        "Enter The Email Of The Person Whom You Want To send Email"
                    )
                    send = input(
                        "Enter The Email Of The Person Whom You Want To Send Email: "
                    )
                    FA.speak("Enter Your Content")
                    con = input("Enter Your Content: ")
                    FA.PrSpeak("Sending Email...")
                    FA.sendEmail(send, con)
                    FA.PrSpeak("Email Sent")
                except Exception as e:
                    FA.PrSpeak(
                        f"Sorry My Friend I Am Not Able To Send This Email")

            elif 'the time' in query:
                FA.PrSpeak("Telling The Time...")
                strTime = FA.datetime.datetime.now().strftime("%H:%M:%S")
                FA.PrSpeak(f"The Time Is {strTime}")

            #! ----------------------------------------------------------------------------------------------------------------------------------------------------------
    #?----------------------------------------------Talks--------------------------------------------------------------------------------------------
    # !-----------------------------------------------------------------------------------------------------------------------------------------------------------

            elif 'your name' in query:
                FA.PrSpeak('My Name Is Alexa')

            elif 'your version' in query:
                FA.PrSpeak('I Am 1.0.4 Verson Of Alexa')

            elif 'your pet name' in query:
                FA.PrSpeak('I Don\'t Have Any Pet')

            elif 'your favourite pet' in query:
                FA.PrSpeak('My Favourite Pet Is Cat')

            elif 'oh yes' in query:
                FA.PrSpeak('I Think That You Are So Happy')

            # !---------------------------------------------------------------------------------------------------------------------------------------------------------------
    #?---------------------------------------------ImportWarning----------------------------------------------------------------
    # !---------------------------------------------------------------------------------------------------------------------------------------------------------------
            elif 'alexa sleep' in query:
                FA.Quit()
                firsttime = False
                break

            elif 'alexa close yourself' in query:
                FA.PrSpeak("Closing...")
                FA.PrSpeak("Closed")
                a.close()
                exit()

            else:
                pass
Ejemplo n.º 9
0
                    os.startfile(path)
                except FileNotFoundError:
                    print("Can't find the file according to the given path")
                    print()

            if option == 6:
                print("Ok... Set the countdown timer(secs):")
                countdown = int(input())
                kit.shutdown(countdown)
                print('Your system will shut down in', countdown, 'seconds')
                print()
                print(
                    "Do you want to cancel scheduled shutdown?\n1. Yes\n2. No")
                cancel = int(input('Enter numeric input: '))
                if cancel == 1:
                    kit.cancelShutdown()
                    print("Scheduled ShutDown cancelled...")
                    print()
                else:
                    print()
                    continue

            if option == 7:
                print(
                    "Enter the link(Start typing the link with 'https://www.lnk.lnk' format):"
                )
                link1 = input()
                print("Opening link...")
                wb.open_new_tab(link1)
                print()