Included 4th request by cclauss and fixed bugs
now its easier to use commands without arguments
This commit is contained in:
parent
38b70f4d22
commit
f2305ab685
@ -31,13 +31,27 @@ def main(search_engine, takeCommand, debug):
|
|||||||
while True:
|
while True:
|
||||||
query = takeCommand().lower()
|
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():
|
if "wikipedia" in query.lower():
|
||||||
command_wikipedia(speak, debug, query)
|
command_wikipedia(speak, debug, query)
|
||||||
|
|
||||||
elif "what's up" in query or "how are you" in query:
|
|
||||||
command_whatsup()
|
|
||||||
|
|
||||||
elif "open" in query.lower():
|
elif "open" in query.lower():
|
||||||
command_open(
|
command_open(
|
||||||
query,
|
query,
|
||||||
@ -53,27 +67,6 @@ def main(search_engine, takeCommand, debug):
|
|||||||
elif "mail" in query:
|
elif "mail" in query:
|
||||||
command_mail(takeCommand)
|
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!")
|
speak("Next Command! Sir!")
|
||||||
|
|
||||||
|
|
||||||
|
|||||||
Binary file not shown.
Binary file not shown.
@ -91,7 +91,7 @@ def command_bye():
|
|||||||
sys.exit()
|
sys.exit()
|
||||||
|
|
||||||
|
|
||||||
def command_playMusic():
|
def command_play_music():
|
||||||
try:
|
try:
|
||||||
music_folder = config['DEFAULT']['musicPath']
|
music_folder = config['DEFAULT']['musicPath']
|
||||||
music = ("music1", "music2", "music3", "music4")
|
music = ("music1", "music2", "music3", "music4")
|
||||||
@ -103,13 +103,13 @@ def command_playMusic():
|
|||||||
speak(e)
|
speak(e)
|
||||||
|
|
||||||
|
|
||||||
def command_pauseMusic():
|
def command_pause_music():
|
||||||
mixer.music.pause()
|
mixer.music.pause()
|
||||||
|
|
||||||
|
|
||||||
def command_stopMusic():
|
def command_stop_music():
|
||||||
mixer.music.stop()
|
mixer.music.stop()
|
||||||
|
|
||||||
|
|
||||||
def command_unpauseMusic():
|
def command_unpause_music():
|
||||||
mixer.music.unpause()
|
mixer.music.unpause()
|
||||||
|
|||||||
Loading…
x
Reference in New Issue
Block a user