-
Notifications
You must be signed in to change notification settings - Fork 1
/
Copy pathreply.py
155 lines (124 loc) · 5.75 KB
/
reply.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
from utilities import *
from questions import *
from jokes_and_quotes import *
import re
def reply(str):
if (str in ask_time):
voice(tell_time())
elif (str in who_are_you):
voice("I am Bucky, the new age personal assistant")
elif (str in greetings):
voice("hello, nice to meet you")
elif (str in about_creators):
voice("i was created by those 4 people standing next to you")
elif (str in how_are_you):
voice("i'm doing fine, thanks how are you ")
elif (str in where_are_you):
voice("I am probably inside someone's computer")
elif (str in about_skills):
voice("i can recognize and carry out basic voice commands, monitor your expenses, search internet for you, and much more!")
elif (str in ask_date):
voice(tell_date())
elif (str in ask_jokes):
voice(tell_jokes())
elif (str in ask_quotes):
voice(tell_quotes())
elif (str in write_diary):
diary_entry()
else:
#to call calculator
try:
searchObj=re.search( r'(.*) of (.*) and (.*)', str, re.M|re.I)
if searchObj:
if(searchObj.group(1) in['sum','add']):
voice(float(searchObj.group(2))+float(searchObj.group(3)))
elif(searchObj.group(1) in['subtract','difference']):
voice(float(searchObj.group(2))-float(searchObj.group(3)))
elif(searchObj.group(1) in['product','multiplication']):
voice(float(searchObj.group(2))*float(searchObj.group(3)))
elif(searchObj.group(1) in['quotient','division','ratio']):
voice(float(searchObj.group(2))/float(searchObj.group(3)))
searchObj = re.search( r'(.*) (.*) of (.*) and (.*)', str, re.M|re.I)
if searchObj:
if(searchObj.group(2) in['sum','add']):
voice(float(searchObj.group(3))+float(searchObj.group(4)))
elif(searchObj.group(2) in['subtract','difference']):
voice(float(searchObj.group(3))-float(searchObj.group(4)))
elif(searchObj.group(2) in['product','multiplication']):
voice(float(searchObj.group(3))*float(searchObj.group(4)))
elif(searchObj.group(2) in['quotient','division','ratio']):
voice(float(searchObj.group(3))/float(searchObj.group(4)))
# to call countdown timer
searchObj = re.search( r'(countdown|countdown timer|timer|countdown for|timer for|countdown timer for) (.*) (.*)', str, re.M|re.I)
if searchObj:
countdown(searchObj.group(2),searchObj.group(3))
searchObj = re.search( r'(countdown|countdown timer|timer|countdown for|timer for|countdown timer for) (.*)', str, re.M|re.I)
if searchObj:
countdown(searchObj.group(2))
#to call tell day or yesterday or tomorrow
searchObj = re.search( r'(what day is|what day was|what is the day|what was the day) (.*)', str, re.M|re.I)
if searchObj:
if(searchObj.group(2)=="today"):
tell_day()
elif (searchObj.group(2)=="yesterday"):
tell_day(int(time.strftime('%d'))-1)
elif (searchObj.group(2)=="tomorrow"):
tell_day(int(time.strftime('%d'))+1)
#make code for custom dates
#to call dictionary
searchObj = re.search( r'(define|what is the meaning of|meaning of|what is meaning of|who is|google) (.*)', str, re.M|re.I)
if searchObj:
dictionary(searchObj.group(2))
searchObj = re.search( r'(what does the word|what does) (.*) (means|mean)', str, re.M|re.I)
if searchObj:
dictionary(searchObj.group(2))
#to play diary
searchObj = re.search( r'(play diary|read diary) (on|of) (.*) (.*) (.*)', str, re.M|re.I)
if searchObj:
play_diary(searchObj.group(3),searchObj.group(4),searchObj.group(5))
#add code to play more general dates
except AttributeError:
voice("Sorry. something error, has occured!")
except ValueError:
voice("Sorry. something went wrong!")
'''
(str=="i love you"):
voice("I love you too handsome")
elif (str=="go to hell"):
voice("perhaps i have already been there")
elif (str=="search *"):
voice("okay what do you want to search")
elif (str=="check notifications"):
voice("you have no new notelifications")
elif (str=="music"):
voice("A husband and wife stepped up to view the body of his mother-in-law. As he began to cry, his wife punched him and said: Why are you crying, you never liked my mother anyway. I know he replied, I thought I saw her move!")
elif (str=="who am i"):
voice("i'm sorry, what is your name")
elif (str=="what is my name"):
voice("i'm sorry, what is your name")
elif (str=="how is the weather"):
voice("32 degree celcius with chances of rain")
elif (str=="set a reminder"):
voice("ok, what should i remind you of")
elif (str=="count to 10"):
voice("1, 2, 3, 4, 5, 6, 7, 8, 9, 10")
elif (str=="toss a coin"):
import random
x = random.randint(0,1)
if (x==0):
voice "Head"
else:
voice "Tail"
elif (str=="im confused"):
voice("lets toss a coin")
elif (str=="i am sad"):
voice("hi sad, my name is Bucky ha ha ha")
elif (str==""):
voice("I am Bucky, the new age personal assitant")
else:
voice("Nothing to say")
voice("Nothing ")
#client = wolframalpha.Client("K9RLXP-GKPWYPR92J")
#res = client.str(str)
#voice(next(res.results).text)
'''