-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathmessage_user.py
More file actions
49 lines (44 loc) · 1.1 KB
/
message_user.py
File metadata and controls
49 lines (44 loc) · 1.1 KB
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
import datetime
class MessageUser():
user_details=[]
messages=[]
base_message="""Hi there {name}!!!
Thanks for a great work.
{date} was a good day
Your purchuase {total}
Support TEAM
"""
def add_user(self,name,amount,email=None):
name=name[0].upper()+name[1:].lower()
today=datetime.date.today()
date_text='{today.month}/{today.day}/{today.year}'.format(today=today)
amount="%.2f"%(amount)
detail={
"name":name,
"amount":amount,
"date":date_text
}
if email is not None:
detail["email"]=email
self.user_details.append(detail)
def get_details(self):
return self.user_details
def make_messages(self):
if len(self.user_details)>0:
for detail in self.get_details():
name=detail["name"]
date=detail["date"]
amount=detail["amount"]
message=self.base_message
new_msg=message.format(
name=name,
date=date,
total=amount
)
self.messages.append(new_msg)
return self.messages
return []
pizdez=MessageUser()
pizdez.add_user("igor",23.4)
pizdez.add_user("stePhan",2323.232)
pizdez.add_user("YuREZS",2323.232,email="yura@rambler.ru")