-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathredisWithPython.py
89 lines (77 loc) · 2.49 KB
/
redisWithPython.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
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
import hashes
name_undefined = True
print("")
print("")
print("##### MESSAGING BOARD #####")
while name_undefined :
print("")
print("")
print("What is your name ?")
print("A name stars with @, can contain alpha num, - or _")
print("")
print("")
given_name = input("Your name : ")
if hashes.name_check(given_name):
name_undefined = False
user_name = str.lower(given_name)
if user_name not in hashes.get_user_names() :
print("")
print("Are you new ?")
is_new_user = input("Your Answer (y/n): ")
password = input("set your password: ")
print("")
if is_new_user == "n" :
print("verify your username: " + given_name)
is_name_correct = input("confirm this is your handle (y/n): ")
if is_name_correct == 'n' :
name_undefined = True
else :
hashes.set_user_password(given_name, password)
else :
not_auth = True
while not_auth :
input_password = input("enter your password: ")
if hashes.check_user_password(given_name, input_password) :
not_auth = False
else :
print("This is not the right password")
exit_option = input("try again ? (y/n) --> ")
if exit_option == 'n' :
name_undefined = True
break
else :
pass
else:
print("this name is not valid")
print("")
print("")
print("###### Welcome " + given_name + " ! #####")
while True:
print("")
print("")
print("##### MENU #####")
print("")
print("c - to write a new message")
print("r - to read all the messages")
print("@[user_handle] - to see a user timeline")
print("")
print("q - to quit")
print("")
print("################")
interface = input("Your choice: ")
print("")
print("")
print("")
if interface == 'c':
input_message = input("Enter your message: ")
hashes.create_tweet(given_name, input_message)
elif interface == 'r':
hashes.print_tweets(hashes.get_all_tweets())
elif interface == 'q':
break
else:
res = hashes.get_tweet_for_one_user(interface)
if len(res) > 0 :
hashes.print_tweets(res)
else :
print("this user does not exist")