Skip to content
Permalink
68adcc6bda
Switch branches/tags

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?
Go to file
 
 
Cannot retrieve contributors at this time
50 lines (41 sloc) 1.65 KB
from model.user import User
from database.mongo import Mongo
class Welcome:
def welcomeUser(self):
client = Mongo()
db = client.getClient()
print("Welcome to crypto chat-box.\n")
print("Where we make it easier for you to access realtime prices from your favourite coin")
print("To enable your experience smooth, We've created a helper function to help do this faster with a shortcut.\n")
# get the email address
email = self.provideEmail()
# newUser = User(name, email)
userModel = db["account"]
# first we need to find the account if it present
# we'll use their email address
userExist = userModel.find_one({"email": email})
# print(userExist)
# check if a user was found
if userExist:
print("Welcome " + userExist["name"].capitalize() +
" back to crypto chat-box.\n")
else:
print("\nThank you for providing your Email. We just need one last thing from you.")
# get the user name
name = self.provideName()
print("Thank you for completing your onboarding.. " + name.capitalize())
userModel.insert_one({"email": email, "name": name,
"currencyName": "USD", "currencyID": "yhjMzLPhuIDl"})
return True
def provideName(self):
name = str(input("how can we address you. Please provide your name: \n"))
if name == "":
print("To proceed, you must provide a name.")
self.provideName()
return name
def provideEmail(self):
email = str(input("Please provide your email address: \n"))
if email == "":
print("To proceed, you must provide your email address.")
self.provideemail()
return email