-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathprocess_module.py
More file actions
66 lines (65 loc) · 2.23 KB
/
Copy pathprocess_module.py
File metadata and controls
66 lines (65 loc) · 2.23 KB
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
55
56
57
58
59
60
61
62
63
64
65
66
from time_module import get_time
from database import get_answers_from_memory,insert_question_and_answer,change_assis_name
from output_module import output
from input_module import take_input
from internet import internet_access,check_wikipedia,open_web,add_new_web_address
from system_control import take_screenshot
from greeting_module import sayGoodBye
import system_details
def process(query):
"""
Process the query and return output
"""
answer = get_answers_from_memory(query)
if query == "":
return None
elif 'open' in query:
if(open_web(query)):
return None
else:
return "Open application Feature Under development"
elif answer == "add new web address":
return add_new_web_address()
elif answer == "get time details":
return get_time()
elif answer == "check internet connection":
if internet_access() == True:
return "Online"
else:
return "Offline"
elif answer == "change name":
output("ok what will you call me?")
temp = take_input()
if temp == system_details.sys_name:
return "ok not changing! You are happy with my old name."
else:
change_assis_name(temp)
system_details.sys_name = temp
return "Now you can call me " + temp
elif answer == "take screenshot":
output("Taking Screenshot..")
try:
return "Screenshot saved at "+take_screenshot()
except:
return(PermissionError)
elif answer == "exit":
output(sayGoodBye())
exit()
elif 'search wikipedia' in query:
answer = check_wikipedia(query)
return answer
else:
output("Could not get this one.")
print("Say it means, [existing question]. And I will remember this.")
ans = take_input()
if "it means" in ans:
ans.replace("it means","")
ans.strip()
value = get_answers_from_memory(ans)
if value == "":
return "Sorry, can't help with this one"
else:
insert_question_and_answer(query, value)
return"ok, i will remember from next time"
else:
return None