Permalink
Cannot retrieve contributors at this time
Name already in use
A tag already exists with the provided branch name. Many Git commands accept both tag and branch names, so creating this branch may cause unexpected behavior. Are you sure you want to create this branch?
ChatBotGroup/ChatBot.py
Go to fileThis commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
132 lines (115 sloc)
6.44 KB
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
# Starting a conversation | |
print("Hi!") | |
greeting = input("What is your name?: ") | |
user = str(greeting) | |
if user[0].isupper(): | |
print("Hello " + user + ",i'm glad to meet you" + "!") | |
else: | |
print("Hello " + user + ",i'm glad to meet you" + "!") | |
print("Next time you should write your name starting with capital letter :)") | |
print("The number of letters of your name is: ") | |
print(len(user)) | |
# keep going the conversation | |
userAge = input("How old are you?: ") | |
userNumber = int(userAge) | |
if userNumber < 0: | |
print("That's not possible!") # If user puts a number below 0 it prints "That's not possible" | |
elif userNumber < 50: | |
print("Well, you are young, you have plenty of time to do anything you want, that's great, isn't it?") # If user puts a number below 50 it prints "You have very big knowledge about everything and anything." | |
elif userNumber < 100: | |
print("You have very big knowledge about everything and anything.") # If user puts a number below 100 it prints "You have very big knowledge about everything and anything." | |
elif userNumber < 120: | |
print("I don't know what to say, that is incredible.") # If user puts a number below 120 it prints "I don't know what to say, that is incredible." | |
else: | |
print("Hmm, i think you lying ") | |
print("Next year you will be " + str(int(userNumber) + 1)) | |
# keep going the conversation | |
question1Answer = ["Bad", "bad", "Boored", "boored", "Super", "super", "Terrible", "terrible", "Tired", "tired", | |
"Depressed", "depressed", "Angry", "angry", "annoyed", "Annoyed", "gloomy", "Gloomy", "Grumpy", | |
"grumpy", "Indifferent", "indiffrent", "Rejected", "receted", "Stressed", "stressed", "Irritated", | |
"irritated", "weird", "Weird"] | |
question1Answer1 = ["Good", "good", "Okey", "okey", "Amazing", "amazing", "I'm okey", "i'm okey", "great", "Great", | |
"Awesome", "awesome", "happy" "Happy", "Optimistic", "optimistic", "joyful", "Joyful", "Loving", | |
"loving", "Mellow", "mellow", "Peaceful", "peaceful", "Silly", "silly", "Sympaetic", "sympaetic", | |
"Calm", "calm", "Excited", "excited"] | |
question1 = input("How are you feeling today?: ") | |
if question1 in question1Answer: | |
print("Ahhh, that is not good, i hope you gonna feel better as soon as possible :) ") | |
elif question1 in question1Answer1: | |
print("Wow, atleast someone has a good day, that's nice") | |
else: | |
print("This is the first time i've heard this kinda mood") | |
# keep going the conversation | |
question2Answer = ["6"] | |
smart = input( | |
"Hey, quick math question, if you gonna answer it correctly, i'm gonna give you a candy(just kidding)! 2+2*2?: ") | |
if smart in question2Answer: | |
print("Well done! Wasn't so hard, right?") | |
else: | |
print("PIIIP, WRONG! First you need to calculate 2*2 and then +2, that is simple math") | |
# keep going the conversation | |
import random # This is required to include random module | |
jokekeywords = ["Yes", "yes", "Sure", "sure", "Why not", "why not", "Okey", "okey", "Ok", "ok", "Yeah", "yeah"] | |
jokekeywords1 = ["No", "no", "No, thanks", "no thanks", "Nah", "nah"] | |
joke_responces = ["My dog used to chase people on a bike a lot. It got so bad, finally I had to take his bike away.", | |
"What is the difference between a snowman and a snowwoman? -Snowballs.", | |
"I can’t believe I forgot to go to the gym today. That’s 7 years in a row now.", | |
"A naked women robbed a bank. Nobody could remember her face.", | |
"I’m selling my talking parrot. Why? Because yesterday, the bastard tried to sell me.", | |
"A wife is like a hand grenade. Take off the ring and say good bye to your house.", | |
" Don’t be sad when a bird craps on your head. Be happy that dogs can’t fly."] | |
joke = input("Do you wanna hear a joke? ") | |
if joke in jokekeywords: | |
print("Okey, here you go" + "!" + "-" + random.choice(joke_responces)) | |
elif joke in jokekeywords1: | |
print("Meh, that is not interesting") | |
else: | |
print("What do you mean?") | |
# keep going the conversation | |
movie = input("Do you like movies? Yes/No ") | |
movieanswer = str(movie) | |
if movieanswer == "Yes": | |
movie1 = input("What was the last movie you watched? ") | |
movieanswer1 = str(movie1) | |
print("Oh, i want to watch this movie too" + "!") | |
elif movieanswer == "No": | |
print("Whaaat? How is that possible") | |
else: | |
print("What do you mean?") | |
# keep going the conversation | |
import time # This is required to include time module | |
localtime = time.asctime(time.localtime(time.time())) # https://www.tutorialspoint.com/python/python_date_time.htm | |
print("Have you eaten today? " + "It's already " + localtime) | |
print("If you haven't, then you should get something or better idea is to cook something, that's gonna be cheaper") | |
# keep going the conversation | |
import requests # This is required to include request module | |
city = input("So, which city you live in?:") | |
api_address = "http://api.openweathermap.org/data/2.5/weather?appid=bd32fd2208dbc8c9b3aa875dfd08f838&q={}&units=metric".format( | |
city) # https://www.youtube.com/watch?v=lcWfSn6-m_8 | |
json_data = requests.get(api_address).json() # This is used to communicate between the web server and client | |
weather_data = json_data['main']['temp'] | |
print("The weather in this City right know is - ") | |
print("The temperature is {}".format(weather_data)) | |
# Ending the conversation | |
import bs4 # This is required to include bs4 module | |
conversation_words = ["No", "no" "Nah", "nah", "No, i don't", "no, i don't"] | |
conversation_words1 = ["Yea", "yea", "Yeah", "yeah", "Yes", "yes", "Yes, i like", "yes, i like"] | |
bye = input("Bye the way, do you like our conversation? ") | |
if bye in conversation_words: | |
print("Okey, i'm gonna leave you alone!") | |
elif bye in conversation_words1: | |
print("Thank'ya, same here") | |
search = input("Do you want to search for something? Yes/No ") #https://www.youtube.com/watch?v=dyUhGZ6iNTc | |
if search == "Yes": | |
search1 = input("What do you want to search for? Write without spaces! ") | |
sus_adress = 'https://google.com/search?q=' + (search1) | |
result = requests.get(sus_adress) | |
result1 = bs4.BeautifulSoup(result.text, "html.parser") # This is used for pulling data from the HTML files | |
link1 = result1.select('.r a') | |
link2 = min(2, len(link1)) | |
print("So the most popular information is - ") | |
for i in range(link2): | |
m = sus_adress + link1[i].get('href') | |
print(m[35+len(search1):-1]) | |
else: | |
print("Bye") |