diff --git a/Jarvis2_4windows.py b/Jarvis2_4windows.py index 1c15894..21281e2 100644 --- a/Jarvis2_4windows.py +++ b/Jarvis2_4windows.py @@ -31,13 +31,27 @@ def main(search_engine, takeCommand, debug): while True: query = takeCommand().lower() - # logic for executing basic tasks + # logic for executing commands without arguments + phrases = { + "what's up": command_whatsup, + "nothing": command_nothing, + "abort": command_nothing, + "stop": command_nothing, + "hello": command_hello, + "bye": command_bye, + "play music": command_play_music, + "unpause": command_unpause_music, + "pause music": command_pause_music, + "stop music": command_stop_music, + } + for phrase, command in phrases.items(): + if phrase in query: + command() + + # logic for executing commands with arguments if "wikipedia" in query.lower(): command_wikipedia(speak, debug, query) - elif "what's up" in query or "how are you" in query: - command_whatsup() - elif "open" in query.lower(): command_open( query, @@ -53,27 +67,6 @@ def main(search_engine, takeCommand, debug): elif "mail" in query: command_mail(takeCommand) - elif "nothing" in query or "abort" in query or "stop" in query: - command_nothing() - - elif "hello" in query: - command_hello() - - elif "bye" in query: - command_bye() - - elif "play music" in query: - command_playMusic() - - elif "pause music" in query: - command_pauseMusic() - - elif "stop music" in query: - command_stopMusic() - - elif "unpause" in query: - command_unpauseMusic() - speak("Next Command! Sir!") diff --git a/__pycache__/actions.cpython-37.pyc b/__pycache__/actions.cpython-37.pyc index 711448d..86bdcf1 100644 Binary files a/__pycache__/actions.cpython-37.pyc and b/__pycache__/actions.cpython-37.pyc differ diff --git a/__pycache__/commands.cpython-37.pyc b/__pycache__/commands.cpython-37.pyc index 97cea7b..f2dd312 100644 Binary files a/__pycache__/commands.cpython-37.pyc and b/__pycache__/commands.cpython-37.pyc differ diff --git a/commands.py b/commands.py index 34694d6..575fc16 100644 --- a/commands.py +++ b/commands.py @@ -91,7 +91,7 @@ def command_bye(): sys.exit() -def command_playMusic(): +def command_play_music(): try: music_folder = config['DEFAULT']['musicPath'] music = ("music1", "music2", "music3", "music4") @@ -103,13 +103,13 @@ def command_playMusic(): speak(e) -def command_pauseMusic(): +def command_pause_music(): mixer.music.pause() -def command_stopMusic(): +def command_stop_music(): mixer.music.stop() -def command_unpauseMusic(): +def command_unpause_music(): mixer.music.unpause()