Advertisement
Guest User

Untitled

a guest
Sep 11th, 2017
194
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
Python 1.90 KB | None | 0 0
  1. import os
  2. import time
  3. option = ''
  4. def register():
  5.     username = input("What would you like your username to be?")
  6.     password = input("What would you like your password to be?")
  7.     file = open("logins.txt","a")
  8.     file.write(username)
  9.     file.write(" ")
  10.     file.write(password)
  11.     file.write(" ")    
  12.     file.write("\n")
  13.     file.close()
  14.  
  15.    
  16. def login():
  17.     username = input("What is your username?")
  18.     password = input("What is your password?")
  19.     if username in open('logins.txt').read() and password in open('logins.txt').read():
  20.         print("Login Correct, Welcome ",username)
  21.         signedin = "yes"
  22.  
  23. def msg():
  24.     message = input("What is your message?")
  25.     recipient = input("What is the person's username you are sending it to")
  26.    
  27.     file = open("messages.txt","a")
  28.     file.write(message)
  29.     file.write(" ")
  30.     file.write("To")
  31.     file.write(" ")
  32.     file.write(recipient)
  33.     file.write(" ")
  34.     file.write("From")
  35.     file.write(username)
  36.     file.write(" ")
  37.     file.write("\n")
  38.     file.close()
  39.  
  40.    
  41. print("Welcome to CryptChat Your options are below: ")
  42. print("Register")
  43. print("Login")
  44. print("Message (Login first)")
  45. print("Type 'exit' to quit")
  46. while option != 'exit':
  47.    
  48.     option = input("Please select one of the options: ")
  49.     file = open("logins.txt","a")
  50.     signedin = "no"
  51.      
  52.     if option.lower() == "register":
  53.         register()
  54.          
  55.     if option.lower() == "login":
  56.         login()
  57.      
  58.     if option.lower() == "Message" and signedin == "yes":
  59.         msg()
  60.     elif option.lower() =="message" and signedin =="no":
  61.         print("you are not able to send a message unless\n you login first")
  62.         print("you will be redirected to Login page in 5 seconds")
  63.         time.sleep(5)            
  64.         print( os.system("CLS"),chr(13)," ",chr(13))
  65.         login()
  66.     print( os.system("CLS"),chr(13)," ",chr(13))
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement