-
Notifications
You must be signed in to change notification settings - Fork 0
/
start_chat.py
97 lines (59 loc) · 2.55 KB
/
start_chat.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
# import statements
#from globals import current_status_message
from add_status import add_status
from add_friend import add_friend
# start_chat() function definition.
def start_chat(name, age, rating, status):
from send_message import send_message
from read_message import read_message
from globals import current_status_message
from globals import friends
from termcolor import colored
# validating users details.
error_message = None # variable for storing error messages.
if not (age > 12 and age < 50) :
# invalid age.
error_message = ("Invalid age. Provide correct details.")
print (error_message,'red')
else:
welcome_message = "Authentication complete. Welcome\n " \
"Name : " + name + "\n" \
"Age: " + str(age) + "\n" \
"Rating: " + str(rating) + "\n" \
"Proud to have you onboard" + "\n"
if (rating > 4.0):
welcome_message = welcome_message + "Great work"
elif (rating >= 3.0):
welcome_message = welcome_message + "Average"
else:
welcome_message = welcome_message + "Do some work to increase your's rating"
print colored(welcome_message,'green')
# displaying menu for user.
show_menu = True
while show_menu:
menu_choices = "What do you want to do? \n " \
"1. Add a status update \n " \
"2. Add a friend \n " \
"3. Send a secret message \n " \
"4. Read a secret message \n " \
"5. Read Chats from a user \n " \
"6. Close Application \n"
result = int(raw_input(menu_choices))
# validating users input
if (result == 1):
current_status_message = add_status(current_status_message)
#action statement
print("Your current status is:" + current_status_message,"blue")
#action
elif (result == 2):
number_of_friends = add_friend()
print ('You have %d friends' % (number_of_friends),'blue')
elif(result == 3):
send_message()
elif(result == 4):
read_message()
elif(result == 6):
# close application
show_menu = False
else:
print ("Wrong choice. Try again.",'red')