-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathcommand.py
More file actions
62 lines (55 loc) · 2.19 KB
/
Copy pathcommand.py
File metadata and controls
62 lines (55 loc) · 2.19 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
from functions import *
calender_str = ["what do i have", "do i have plans", "am i busy", "am i free"]
def command (text):
tag = talk(text)
conversation = ["greeting", "goodbye", "name", "age", "complements"]
request = ["time", "date", "joke", "news", "web", "search", "note"]
classification = ""
for con in conversation:
if tag == con:
classification = "conversation"
break
else:
classification = "request"
break
if classification == "conversation":
for tg in data["intents"]:
if tg["tag"] == tag:
responses = tg["responses"]
ans = random.choice(responses)
response(ans)
break
if classification == "request":
offline = ["time", "date", "note"]
online = ["joke", "news", "web", "search"]
for o in online:
if o == tag:
try:
requests.get("https://www.google.com")
except:
response("you are offline, you cannot access such features")
break
else:
for tg in data["intents"]:
if tg["tag"] == tag:
responses = tg["responses"]
ans = random.choice(responses)
if tag == "date":
response(ans + tell_date())
elif tag == "time":
response(ans + time_tell())
elif tag == "news":
response(ans)
news()
elif tag == "joke":
response(ans)
jokes()
elif tag == "web":
site(text)
elif tag == "search":
response(ans)
search(text)
else:
response("i have no response for that input yet")
break
break