-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathquerycommands.py
54 lines (43 loc) · 1.4 KB
/
querycommands.py
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
import os
import time
import audioprocessor as ap
import pyjokes
import wikipedia
def queryCommands(text):
if(text == "powerpoint"):
os.system("libreoffice --draw")
elif(text == "excel"):
os.system("libreoffice --calc")
elif(text == "writer"):
os.system("libreoffice --writer")
elif(text == "time"):
ap.say(time.ctime())
elif(text == "vs code"):
os.system("code")
elif(text == "joke"):
ap.say(pyjokes.get_joke())
elif("wikipedia" in text):
query = text.replace("wikipedia", "").strip()
if(query == ""):
ap.say("Sorry! I cannot find anything to search for...")
else:
results = wikipedia.summary(query, sentences=1)
ap.say("According to Wikipedia...")
print(results)
ap.say(results)
elif(text == "shutdown system"):
confirm = ap.listen()
if("yes" in confirm):
os.system("shutdown -h +1")
ap.say("Shutting down in 1 minute")
else:
ap.say("Aborting Shutdown..")
elif(text == "restart system"):
confirm = ap.listen()
if("yes" in confirm):
os.system("shutdown -r +1")
ap.say("Restarting in 1 minute")
else:
ap.say("Aborting Restart..")
elif(text in ["cancel shutdown", "cancel restart"]):
os.system("shutdown -c")