Skip to content

Update chat-bot-master.py #2

Merged
merged 1 commit into from
Nov 5, 2018
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
132 changes: 132 additions & 0 deletions chat-bot-master.py
Original file line number Diff line number Diff line change
@@ -1 +1,133 @@
# George's code #
from random import randint
import getpass
import json
import http.client
listOfTopics = ["SPORTS", "VIDEO GAMES", "NEWS", "BOOKS", "MOVIES", "WEATHER"]

def userLogin():
name = ["KANYE", "GEORGE", "BOB", "DAVE", "POGO"]
userFirstInput = input("Please enter your username: ")
userFirstInput = userFirstInput.upper()
if userFirstInput in name:
print("Welcome " + userFirstInput)
userPasswordInput = getpass.getpass("Please enter password: ")
# userPasswordInput = input("Please enter password: ")
if userFirstInput == "KANYE":
if userPasswordInput == "kanyeyeast":
print("You are now able to use the chat bot.")
else:
print("You are not allowed here, goodbye.")
exit()
elif userFirstInput == "GEORGE":
if userPasswordInput == "george123":
print("You are now able to use the chat bot.")
else:
print("You are not allowed here, goodbye.")
exit()
elif userFirstInput == "BOB":
if userPasswordInput == "bob123":
print("You are now able to use the chat bot.")
else:
print("You are not allowed here, goodbye.")
exit()
elif userFirstInput == ("POGO"):
if userPasswordInput == "pogo123":
print("You are now able to use the chat bot.")
else:
print("You are not allowed here, goodbye.")
exit()
elif userFirstInput == ("DAVE"):
if userPasswordInput == ("123savage"):
print("21 21 21")
else:
print("I'm disappointed.")
exit()
else:
print("You aren't a valid user.")
exit()

def Sports():
favSport = input("Which sport would you like to talk about? ")
favSport = favSport.upper()
footie = ["FOOTBALL", "FOOTIE", "FOOTY", "FUTBAL", "FOOTBAL", "FOOTBOLL"]
bball = ["BASKETBALL", "BASKETBAL", "BBALL", "BSKETBALL"]
if favSport in footie:
favLeagueInput = input("Which football league is your favourite? My personal favourite is the premier league: ")
sportConnection = http.client.HTTPConnection('api.football-data.org')
sportHeaders = { 'X-Auth-Token': "3bb5ce52167545eba1be7e267522a063" }
sportConnection.request('GET','/v2/competitions/' + favLeagueInput + '/teams', None, sportHeaders)
sportResponse = json.loads(sportConnection.getresponse().read().decode())
favLeague = sportResponse["competition"]["name"]
print(sportResponse)
print("Your favourite league is " + favLeague)
favLeagueID = sportResponse["competition"]["id"]
print("Your favourite league's ID is " + str(favLeagueID))
favLeagueCountry = sportResponse["competition"]["area"]["name"]
print("Your favourite league is in " + favLeagueCountry)
changeLeague = input("What would you like to know about this league? Or would you prefer to talk about another league/competition? ")
changeTheLeague = ["change", "something"]
changeNewLeague = changeLeague.split()
for changeNewLeague in changeTheLeague:
print("ok")
break
elif favSport in bball:
print("Placeholder bball")
else:
print("Whoops, don't know anything about that sport, can we interest you in another sport?")

def News():
print("placeholder news")

def videoGames():
print("placeholder video games")

def Weather():
print("placeholder weather")

def booksMovies():
print("placeholder books and movies")


def randomNumber(): # This is a random number test.
userSecondInput = input("Do you like numbers? Please enter YES or NO: ")
userSecondInput = userSecondInput.upper()
if userSecondInput == "YES":
randNum = randint(1,10)
print(randNum)
elif userSecondInput == "NO":
print("Should of chosen YES.")
exit()
else:
pass

userLogin()
intialInput = input("What would you like to talk about? ")
intialInput = intialInput.upper()

if intialInput in listOfTopics:
if intialInput == "SPORTS":
Sports()
elif intialInput == "NEWS":
News()
elif intialInput == "VIDEO GAMES":
videoGames()
elif intialInput == "WEATHER":
Weather()
elif intialInput == "BOOKS" or "MOVIES" or "BOOKS MOVIES":
booksMovies()
else:
randomNum = randint(1,5)
if randomNum == 1:
randomTopic = "Sports"
elif randomNum == 2:
randomTopic = "News"
elif randomNum == 3:
randomTopic = "Video Games"
elif randomNum == 4:
randomTopic = "Weather"
elif randomNum == 5:
randomTopic = "Books and Movies"
print("We don't know much about that, maybe I can interest you in something we do know about, like: " + randomTopic)

# End of George's code #