-
Notifications
You must be signed in to change notification settings - Fork 0
/
main.py
158 lines (99 loc) · 4.25 KB
/
main.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
import datetime
import os
import sys
import time
print("Hy user , Welcome to the R-Maill where you send your mails to anyones you want")
class Email:
def send_mail(self, send_to_where, message):
'''This method will send the message'''
with open(f'{send_to_where}.txt', "a") as sending_message:
sending_message.write(f"At {datetime.datetime.now()} : {message}, \n")
sending_message.close()
def create_account(self):
'''This method will create an account if no account exists'''
account_email = input("Enter your E-mail Address to create a new account: ")
account_password = input("Enter your E-Mail Password to create an account: ")
with open('login_signup.txt', 'a') as creating_account:
creating_account.write(f'{account_email}\n')
creating_account.write(f'{account_password}\n')
creating_account.close()
def login_account(self):
'''This method will be used to login'''
account_email = input("Enter your E-Mail Address to login : ")
if account_email in open('login_signup.txt').read():
account_password = input("Enter your E-Mail Password to login : ")
if account_password in open('login_signup.txt').read():
main_senders()
else:
print('Hey thief this is wrong guess')
else:
print("E-mail is not found")
def read_mails(self):
'''This method will be used to read the mails'''
whose_mail = input("Whose mails do you want to read : ")
file_path = r'/media/rishaw/Local Disk/R-Mail Project/' + whose_mail + '.txt'
if os.path.exists(file_path):
with open(f'{whose_mail}.txt') as reading_mail:
print(reading_mail.read())
def delete_mail(self):
'''This method will be used to delete the all the mails of a specific email'''
removing_mail = input("Whose mails should be deleted: ")
if os.path.exists(f"{removing_mail}.txt"):
os.remove(f"{removing_mail}.txt")
else:
print("The file does not exist")
def delete_account(self):
'''This method will delete the account and password of the user'''
deleting_decision = input("Are you sure[Y/N] : ")
if deleting_decision == 'y' or 'Y':
with open('login_signup.txt', 'wt') as removing_account:
removing_account.write('')
removing_account.close()
print("Your account is deleted successfully")
else:
print('Your is not deleted')
Account = Email()
def main_senders():
'''This function controls the all sending, reading, and deleting of a account or mail'''
with open('login_signup.txt') as user_name:
get_name = user_name.readline().split('.')
print(f"Welcome {get_name[0]}")
user_name.close()
ender = False
while ender is not True:
print("\nEnter 's' to send the mail, 'r' to read the mails, 'c' to delete the account, 'd' to delete the mail contact, and 'q' to quite")
select = input("Select : ")
take = select.lower()
if take == 's':
where_to_send = input("Enter the mail : ")
message = input("Enter your message here : ")
Account.send_mail(where_to_send, message)
elif take == 'r':
Account.read_mails()
elif take == 'd':
Account.delete_mail()
elif take == 'c':
Account.delete_account()
time.sleep(0.3)
last_decision = input("Type 'n' for create a new account and 'z' to exit : ")
if last_decision == 'n':
main()
elif last_decision == 'z':
sys.exit('You have quit the code')
else:
print("Invalid letter")
elif take == 'q' or 'quite':
ender = True
else:
print('LOL, INVALID')
def main():
'''All the things of this program is starts from here'''
if os.stat("login_signup.txt").st_size == 0:
Account.create_account()
time.sleep(0.2)
main_senders()
else:
Account.login_account()
time.sleep(0.2)
if __name__ == '__main__':
main()