forked from AadarshChaurasia/desktop_assistant_v1.1
-
Notifications
You must be signed in to change notification settings - Fork 0
/
main.py
245 lines (149 loc) · 4.07 KB
/
main.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
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
'''
Functions :-
open(argument)
query(argument)
'''
from webbrowser import open_new_tab as open_website
import os
from getmac import get_mac_address
from Time import time_status as ts
from Time import get_current_time as current_time
from Time import timer
from System import speak
from search import finder
import Browser
import Time
import System
import extra_func
import Automating
def open(data):
words = data.split(' ')
new_query = ''
# print(words)
count = 0
if '.com' in data or '.in' in data or '.org' in data:
for word in words:
if '.com' in word or '.in' in words or '.org' in words:
new_query = word
break
open_website(new_query)
elif 'software' in data or 'application' in data:
length = len(words)
# print(length)
for i in range(length):
# print(i)
word = words[i]
# print(word)
if word=='software' or word=='application':
new_query = words[i-1]
break
Automating.start_software(new_query)
else:
new_query = data[5:]
finder(new_query)
return f'opening {new_query}'
def query(query):
# Time module
new_query = ''
if 'time' in query:
if 'status' in query:
status = ts()
new_query = f'this is {status} time sir.'
print(new_query)
if 'current' in query: # Printing current time which has been inherted by Time part/
new_query = current_time() # /of projet. example :- tell me current time or what is the current time
print(new_query)
if 'set' in query and 'timer' in query:
data_array = query.split(' ')
for data in data_array:
try:
float(data)
time = data
break
except:
continue
# print(data)
new_query = f'timer set for {data}'
timer(data)
if 'open' in query:
new_query = open(query)
# Automating module
if query == 'connect to wifi':
new_query = Automating.wifi()
# Browser module
if 'tell me about' in query or 'ke bare mai batao' in query:
new_query = Browser.show_info_about(query)
print(new_query)
if 'google' in query:
new_query = Browser.search_on_google(query)
# System module
if 'shut down' in query or 'shutdown' in query:
try:
letters = query.split(' ')
for letter in letters:
try:
int(letter)
time = int(letter)
print(time)
System.shutdown(minutes=letter)
except:
pass
except:
System.shutdown()
new_query = 'shutting down...'
if 'restart' in query:
try:
letters = query.split(' ')
for letter in letters:
try:
int(letter)
time = int(letter)
print(time)
System.restart(minutes=letter)
except:
pass
except:
System.restart()
new_query = 'restarting...'
if 'minimize' in query:
if 'all' in query:
System.min_all()
else:
System.minimize()
if 'close' in query:
System.close()
new_query = 'clossing current window'
if 'change' in query and 'window' in query:
System.change_working_window()
if 'system' in query:
if 'info' in query or 'information' in query or 'about' in query:
System.info()
if 'ip' in query:
new_query = System.IP()
print(new_query)
if 'mac' in query and 'address' in query: # work only when connected to internet
new_query = get_mac_address()
print(new_query)
if 'battery' in query and 'left' in query:
new_query = System.bettery_left()
print(new_query)
if 'cpu' in query:
if 'usage' in query or 'use' in query:
new_query = System.cpu_usage()
print(new_query)
if 'restore' in query:
if 'up' in query:
System.maxsize()
if 'down' in query:
System.minisize()
return new_query
# if 'help' in query:
# open('help_commands.txt','r') as f:
if __name__ == '__main__':
# status = ts()
# speak(f'Good {status} sir. How can i help you.')
# q = input('Enter: ')
try:
query('restore downward')
except:
print('sorry but an unexpected error occured :(')