-
Notifications
You must be signed in to change notification settings - Fork 0
/
status.py
169 lines (155 loc) · 5.1 KB
/
status.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
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
import main
import user as us
def status(n,db,user):
if n=='1':
moname(db,user)
elif n=='2':
update(db,user)
elif n=='3':
showfollow(db,user)
elif n=='4':
showfollower(db,user)
elif n=='5':
myblock(db,user)
def moname(db,user):
user = db.member.find_one({'_id': user['_id']})
newname=input('Enter your new name : ')
if input('Are U Sure? (Yes:y/No:n) : ')=='y':
db.member.update({'_id':user['_id']},{'$set':{'name':newname}})
main.clear()
print('Successfully modified.')
us.printstatus(db, user)
def update(db,user):
user = db.member.find_one({'_id': user['_id']})
print('Your profile : ',end='')
try:
pro=user['profile']
print(pro)
except:
print('None')
up=input('Enter your new profile : ')
rusure = input('Are U Sure? (Yes:y/No:n) :')
if rusure=='n':return
else:
db.member.update({'_id':user['_id']},{'$set':{'profile':up}})
main.clear()
print('Successfully modifed!')
us.printstatus(db, user)
def showfollow(db,user):
user = db.member.find_one({'_id': user['_id']})
followings=user['following']
main.clear()
print('+-------------You are now following-------------+')
if followings==[]:
print('No one')
for f in followings:
tain=db.member.find_one({'_id':f},{'_id':1,'name':1})
print(tain['name']+'(@'+tain['_id']+')')
print('+'+'-'*47+'+')
while(True):
#print('-'*49)
print('1) Follow more')
print('2) Unfollow')
print("3) Explore the other's page")
print('q) Exit')
print('-'*49)
a=input('Enter:')
if a=='1':
import follow
follow.follow(db,user)
elif a=='2':
import follow
follow.unfollow(db,user)
elif a=='3':
other=input('Enter id to explore (enter q to quit) : ')
if other=='q':
return
exploreothers(db,user,other)
else:
return
def exploreothers(db,user,other):
import post
user = db.member.find_one({'_id': other})
post.wall(db,user)
def showfollower(db,user):
user = db.member.find_one({'_id': user['_id']})
followings=user['follower']
main.clear()
print('+-------------You are followed by---------------+')
if followings==[]:
print('No one')
for f in followings:
tain=db.member.find_one({'_id':f},{'_id':1,'name':1})
print(tain['name']+'(@'+tain['_id']+')')
print('+'+'-'*47+'+')
while(True):
#print('-'*49)
print('1) Block')
print('2) Unblock')
print("3) Explore the other's page")
print('q) Exit')
print('-'*49)
a=input('Enter:')
if a=='1':
blockid = input('Enter an id to block : ')
try:
f=db.member.find_one({'_id':blockid})
if user['_id'] == blockid:
raise Exception
try:
if user['follower'] != []:
db.member.update({'_id': user['_id']}, {'$pull': {'follower': blockid}})
db.member.update({'_id': blockid}, {'$pull': {'following': user['_id']}})
except:
pass
finally:
db.member.update({'_id': user['_id']}, {'$push': {'block': blockid}})
print("You have blocked @" + blockid + '\n')
except:print("You can't block.\n")
elif a=='2':
try:
b=user['block']
if b==[]:raise Exception
id=input("Enter id to delete from the block list : ")
db.member.update({'_id': user['_id']}, {'$pull': {'block': id}})
print('Successfully unblocked\n')
except:
print("You can't unblock.\n")
elif a=='3':
other=input('Enter id to explore : ')
return
else:
return
def myblock(db,user):
while(True):
user = db.member.find_one({'_id': user['_id']})
main.clear()
print('+----------------My block list------------------+')
try:
blocks = user['block']
if blocks == []:
print('No one')
for f in blocks:
tain = db.member.find_one({'_id': f}, {'_id': 1, 'name': 1})
print(tain['name'] + '(@' + tain['_id'] + ')')
except:
print('No one')
print('+' + '-' * 47 + '+')
print('1) Delete ')
print('2) Add ')
print('q) Exit')
print('-'*49)
a=input('Enter:')
if a=='1':
try:
b=user['block']
if b==[]:raise Exception
id=input("Enter id to delete from the block list : ")
db.member.update({'_id': user['_id']}, {'$pull': {'block': id}})
print('Successfully unblocked\n')
except:
print("You can't unblock.\n")
elif a=='2':
showfollower(db,user)
else:
return