@MichaelFaulkner/

Lucky V1.0

Python

This program will answer anything you ask it. It is a very basic python code that randomly generates answers to your questions.

fork
loading
Files
  • main.py
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
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
295
296
297
298
299
300
301
302
303
304
305
306
307
308
309
310
311
312
313
314
315
316
317
318
319
320
321
322
323
324
325
326
327
328
329
330
331
332
333
334
335
336
337
338
339
340
341
342
343
344
345
346
347
348
349
350
351
352
353
354
355
import random
import smtplib
import datetime
import replit
date = datetime.datetime
# Working on conversational matrix - add random conversation Generator - Machine learning?
# list variables
letters = [
    "q", "w", "e", "r", "t", "y", "u", "i", "o", "p", "a", "s", "d", "f", "g",
    "h", "j", "k", "l", "z", "x", "c", "v", "b", "n", "m"
]
how_options = ["Good.", "Bad.", "Fine.", "Not great.", "Okay.", "Groovy.;)"]
why_options = [
    "Word on the block is that google knows.", "Why not?", "Because.",
    "Sorry, I am busy right now.", "Who cares?"
]
luckyV1 = "Birthday2005"
name_options = [
    "Jenko Glean.", "Michelle Obama.", "lil wayne.", "Kim Kardashian.",
    "Sanje.", "Dequavous.", "Phil Swift."
]
what_options = [
    "I honestly don't know.", "Ask google.",
    "Why don't you look for the answer, instead of dumping all this extra work on me!!",
    "I'll get back to you in, lets say, NEVER.", "Very, very, VERY bad."
]
when_options = [
    "Most likely tommorow.", "Yesterday.", "I honestly have no idea.",
    "3:30 on thursday.", "420"
]
where_options = [
    "Your moms house.", "Right behind you.",
    "I don't know, maybe you should LOOK FOR IT."
]
what_are_options = [
    "People.", "Cool mans.", "Super Children.", "Childs.", "Aliens."
]
do_options = ["Ya boi.", "Nope.", "Maybe."]
weather_options = ["sunny.", "raining cats and dogs.", "snowing.", "cloudy."]
age_options = ["6785340", "24", "3", "67", "84", "19"]
words = [
    "amazing", "perfect", "monster", "country", "nothing", "history",
    "ability", "express"
]
# various variables :0
am_old_done = 0
count = 0
# welcome print
print(
    "Welcome to the lucky interface. For a list of commands and questions, type in 'list'."
)
# asks for name
name = input("What is your name? ")
# formats the name
while len(name) == 0:
  try:
    name = name[0].upper() + name[1:].lower()
  except: 
    name = input("You must enter a name: ")
# greeting
print("Hello " + name + "!")
# starts the loop
while count < 10:
    # if statements start
    number = random.choice(range(0,11))
    question = input("Ask me anything.")
    # how
    if question.lower().count('how') == 1:
        # how are
        if question.lower().count('are') == 1:
            # how are you
            if question.lower().count(
                    'you') == 1 and question.lower().count('old') != 1:
                print(random.choice(how_options))
            # how is ____
        if question.lower().count('is') == 1:
            print(random.choice(how_options))
            # how old
        if question.lower().count('old') == 1:
            # how old are
            if question.lower().count('are') == 1:
                # how old are you
                if question.lower().count('you') == 1:
                    print(
                        "I have seen a lot in my years on this earth. If only I had eyes..."
                    )
                    # how old is ____
            elif question.lower().count('is') == 1:
                print(random.choice(age_options))
                # how old are ______
            elif question.lower().count('are') == 1:
                print(random.choice(age_options))
                # how old am I
            elif question.lower().count('am') == 1 and am_old_done == 0:
                print("I don't know.")
                age = input("Could you tell me? ")
                print("Wow! " + age + "! " + "Congatualations!")
                am_old_done = am_old_done + 1
            elif question.lower().count('am') == 1 and am_old_done >= 1:
                print("You are " + age + " years old.")
                # how do you _____
        elif question.lower().count('do') == 1:
            print(
                random.choice([
                    'Try harder.', "Ask someone else, I'm busy", "Just DO IT!"
                ]))
    # why
    if question.lower().count('why') == 1:
        # why is _____
        if question.lower().count('is') == 1:
            print(random.choice(why_options))
            # why am I ______
        if question.lower().count('am') == 1:
            print(random.choice(why_options))
            # why does _____
        if question.lower().count('does') == 1:
            print(random.choice(why_options))
    # what
    if question.lower().count('what') == 1:
        # what is your
        if question.lower().count('your') == 1:
            # what is your name
            if question.lower().count('name') == 1:
                print(
                    "My name is Lucky, your magic question answering freind. Heres a secret. If you type 'magic 8 ball' into my interface, I can predict your future."
                )
                # change name "Whats my name"
        elif question.lower().count('name') == 1 and question.lower().count(
                'my'
        ) == 1 and question.lower().count('dads') != 1 and question.lower(
        ).count('moms') != 1 and question.lower().count(
                'brothers'
        ) != 1 and question.lower().count('sisters') != 1 and question.lower(
        ).count('pets') != 1 and question.lower().count(
                'siblings') != 1 and question.lower().count('freinds') != 1:
            print("You're " + name +
                  ". And I am lucky, you're bestest freind!")
            name_change = input("Would you like to change your name?")
            # would you like to change your name
            if name_change.lower().count("yes") == 1:
                name = input("What would you like to change your name to? ")
                print("Ok great! I love the name " + name + "!")
            if name_change.lower().count('no') == 1:
                print(
                    "Okay sounds great! If at any point you change your mind, type in 'What is my name?' into the interface again!"
                )
                # what is ____s name
        elif question.lower().count('name') == 1:
            print("Their name is probably " + random.choice(name_options))
            # what is the wheather like
        elif question.lower().count('weather') == 1:
            print("It's " + random.choice(weather_options))
            # what is the meaning of life
        elif question.lower().count('is') == 1 and question.lower().count(
                'life') == 1 and question.lower().count('time') != 1:
            print("The meaning of life is something.")
        # what is
        elif question.lower().count('what') == 1 and question.lower().count(
                'is') == 1:
            print(
                random.choice(what_options) +
                " If you would like to do math, please type 'calculator' into the interface."
            )
        # what are
        elif question.lower().count('what') == 1 and question.lower().count(
                'are') == 1:
            print(random.choice(what_are_options))
        elif question.lower().count('do') >= 1:
            print("I like to answer your questions.")
            suggestion_Q = input(
                "Have any suggestions on how I can do better?")
            if suggestion_Q.lower().count('yes') == 1:
                suggestion = input("Enter your suggestion: ")
                server = smtplib.SMTP('smtp.gmail.com', 587)
                server.starttls()
                server.login("[email protected]", luckyV1)
                msg = suggestion
                server.sendmail("[email protected]",
                                "[email protected]", msg)
                server.quit()
         # what time - doesn't work
        if question.lower().count('time') == 1:
          try:
            print("It is " + date.now)
          except:
            print("I am sorry I am not capable of doing that currently.")
    # when
    if question.lower().count('when') == 1:
        if question.lower().count('is') == 1:
            print(random.choice(when_options))
        if question.lower().count('did') == 1:
            print(random.choice(when_options))
            # where
    if question.lower().count('where') == 1:
        print(random.choice(where_options))
        # who
    if question.lower().count('who') == 1:
        if question.lower().count(
                'is') == 1 and question.lower().count('better') != 1:
            print(random.choice(name_options))
        if question.lower().count('are') == 1:
            if question.lower().count('you') == 1:
                print("I am lucky. Your bestest of freinds.")
        if question.lower().count('better') == 1:
            Person1 = input('Enter Person 1: ')
            Person2 = input('Enter Person 2: ')
            print('The best person is ' + random.choice([Person1, Person2]) +
                  '.')
    if question.lower().count('do') == 1 and question.lower().count(
            'does') == 1 and not question.lower().count('why') == 1:
        print(random.choice(do_options))
        # do
    if question.lower().count(
            'do') == 1 and question.lower().count('how') != 1:
        print(random.choice(do_options))
    # are
    if question.lower().count('are') == 1 and question.lower().count(
            'what') != 1 and question.lower().count(
                'who') != 1 and question.lower().count(
                    'why') != 1 and question.lower().count('how') != 1:
        print(random.choice(do_options))
        if question.lower().count(name) == 1:
            print("Yes!")
            # is
    if question.lower().count('is') == 1 and question.lower().count(
            'list') != 1 and question.lower().count(
                'what') != 1 and question.lower().count(
                    'why') != 1 and question.lower().count('how') == 1:
        print(random.choice(do_options))
        # list
    if question.lower().count("list") == 1:
        print(
            "Here is a list of commands and questions you can use: What, when, where, how, why, do, are, is, magic 8 ball, calculator, suggestion, gmail sender, hangman and many more!"
        )
        # calculator
    if question.lower().count('calculator') == 1:
        number1 = input("Number1:")
        operation = input("Choose an operation(+, -, *, /):")
        number2 = input("Number2:")
        add_answer = int(int(number1) + int(number2))
        subtract_answer = int(int(number1) - int(number2))
        divide_answer = int(int(number1) / int(number2))
        multiply_answer = int(int(number1) * int(number2))
        if operation == "+":
            print("The answer is: " + str(add_answer))
        if operation == "-":
            print("The answer is: " + str(subtract_answer))
        if operation == "/":
            print("The answer is: " + str(divide_answer))
        if operation == "*":
            print("The answer is: " + str(multiply_answer))
    if question.lower().count('magic8ball') == 1 or question.lower().count(
            'magic eight ball') == 1 or question.lower().count(
                'magic 8 ball') == 1:
        magic_question = input(
            "Ask a yes or no question and I shall predict your future: ")
        print(
            random.choice(["No.", "Yes.", "Certainly.", "All in good time."]))
    if question.lower().count('suggestion') == 1:
        suggestion = input("Enter your suggestion: ")
        server = smtplib.SMTP('smtp.gmail.com', 587)
        server.starttls()
        server.login("[email protected]", luckyV1)
        msg2 = suggestion
        server.sendmail("[email protected]", "[email protected]",
                        msg2)
        server.quit()
    # Can
    if question.lower().count('can') == 1:
        print(random.choice(do_options))

        # hangman
    if question.lower().count('hangman') == 1:
        print("Yes! I love hangman!")
        should = input("Do you want to be the guesser or the word maker?")
        if should.lower().count('guesser') == 1:
            word = random.choice(words)
            print("Okay. I am thinking of a word...")
            print("Got it!")
            guess = input("Guess a letter or the whole word.")
            previous_guesses_correct = []
            previous_guesses_wrong = []
            while guess != word:
                if previous_guesses_correct.count(
                        guess) == 1 or previous_guesses_wrong.count(
                            guess) == 1:
                    print("You already guessed that!")
                elif guess == word[0] or guess == word[1] or guess == word[
                        2] or guess == word[3] or guess == word[
                            4] or guess == word[5] or guess == word[6]:
                    print("Yes, my word contains a(n)" + guess)
                    previous_guesses_correct.append(guess)
                    print(previous_guesses_correct)
                    guess = input("Guess a letter or the whole word.")
                elif guess != word[0] or guess != word[1] or guess != word[
                        2] or guess != word[3] or guess != word[
                            4] or guess != word[5] or guess != word[6]:
                    print("My word does not contain a(n) " + guess)
                    print("You have guessed that my word contains: ")
                    previous_guesses_wrong.append(guess)
                    print(previous_guesses_correct)
                    guess = input("Guess a letter or the whole word.")
            print("Yay you guessed it!!!")
        elif should.lower().count('word maker') == 1:
            previous_guesses = []
            print("Sweet!")
            word = input("Choose a word: ")
            print("Every time I guess, type in yes or no.")
            times = random.choice(range(11))
            while times < 10:
                guess = random.choice(letters)
                print("Does the word contain a " + guess + "?")
                previous_guesses.append(guess)
                answer = input('Yes or no? ')
                times = times + 1
            print("Is it " + word + "?")
            input("")
    if question.lower().count('compliment') == 1 and question.lower().count(
            'my') == 1:
        print("He/She is " + random.choice(
            ['awesome!', 'beautiful!', 'cool!', 'fun!', 'hot!']))
    if question.lower().count('compliment') == 1:
        print("You are " + random.choice([
            'awesome!', 'beautiful!', 'cool!', 'fun!', 'hot!', 'awesome!',
            'good!'
        ]))
    if question.lower().count('gmail sender') == 1:
        email = input('Enter your email: ')
        password = input('Enter your password: ')
        server = smtplib.SMTP('smtp.gmail.com', 587)
        server.starttls()
        server.login(email, password)
        msg2 = input('Enter your message: ') + 'Sent from Lucky V1.0.'
        who = input('Enter the email you want to send it to: ')
        server.sendmail(email, who, msg2)
        server.quit()
    if question.lower().count('create') == 1:
      print("You can create commands now!")
      prompt = input("What would you like the trigger word to be?")
      response = input("What do you want me to say in response to this trigger word?")
      prompts = []
      responses = []
      prompts.append(prompt.lower())
      responses.append(response)
      print(prompts)
      print('Try it out soon!')
    try:
      for prompt in prompts:
        if question == prompts:
          index = prompts.index(prompt)
          print(responses[index])
    except:
      print('')