-
Notifications
You must be signed in to change notification settings - Fork 1
/
Copy pathresponses.py
54 lines (39 loc) · 1.16 KB
/
responses.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
import json
def sample_responses(input_text):
user_message = str(input_text).lower()
if user_message == "startcourse":
return "Course started..."
def update_status(user_id, status):
with open("users.json", encoding="utf-8") as file:
users_list = json.load(file)['users']
for user in users_list:
if user["id"] == user_id:
user["status"] = status
json_data = {
"users": users_list
}
with open("users.json", "w") as file:
json.dump(json_data, file, indent=4)
# def save_name(name):
# new_user = {
# "name": name,
# "email": None
# }
# message = f"Hy {name}, What is your email address?"
# return f"Hy {name}, What is your email address?"
def save_user(user):
with open("users.json",encoding="utf-8") as file:
users_list = json.load(file)['users']
users_list.append(user)
json_data = {
"users": users_list
}
with open("users.json", "w") as file:
json.dump(json_data, file, indent=4)
help_message = """
I understand the following commands:
/start
/signup
/help
/start_course
"""