-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathprocess_module.py
116 lines (83 loc) · 3.09 KB
/
process_module.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
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
from output_module import output
from time_module import get_time, get_date
from input_module import take_input
from database import *
from internet import check_internet_connection, check_on_wikipedia
import assistant_details
from web_jobs import open_facebook, open_google, close_browser
from music import play_music, pause_music, stop_music, next_song, previous_song, play_specific_song
from display import change_wallpaper
from news_module import get_news
def process(query):
if 'play' in query and 'music' not in query:
answer = get_answer_from_memory('play')
else:
answer = get_answer_from_memory(query)
if answer == "get time details":
return ("Time is " + get_time())
elif answer == "check internet connection":
if check_internet_connection():
return "internet is connected"
else:
return "internet is not connected"
elif answer == "tell date":
return "Date is " + get_date()
elif answer == "on speak":
return turn_on_speech()
elif answer == "off speak":
return turn_off_speech()
elif answer == "close browser":
close_browser()
return "closing browser"
elif answer == "open facebook":
open_facebook()
return "opening facebook"
elif answer == "open google":
open_google()
return "opening google"
elif answer == "play music":
return play_music()
elif answer == 'play':
return play_specific_song(query)
elif answer == "pause music":
return pause_music()
elif answer == "stop music":
return stop_music()
elif answer == "next song":
return next_song()
elif answer == "previous song":
return previous_song()
elif answer == 'change wallpaper':
return change_wallpaper()
elif answer == 'get news':
return get_news()
elif answer == 'change name':
output("Okay! what do you want to call me")
temp = take_input()
if temp == assistant_details.name:
return "Can't change. I think you're happy with my old name"
else:
update_name(temp)
assistant_details.name = temp
return "Now you can call me " + temp
else:
output("Dont know this one should i search on internet?")
ans = take_input()
if "yes" in ans:
answer = check_on_wikipedia(query)
if answer != "":
return answer
else:
output("can you please tell me what it means?")
ans = take_input()
if "it means" in ans:
ans = ans.replace("it means", "")
ans = ans.strip()
value = get_answer_from_memory(ans)
if value == "":
return "Can't help with this one "
else:
insert_question_and_answer(query, value)
return "Thanks i will remember it for the next time"
else:
return "can't help with this one"