Skip to content

Commit 2e7f71b

Browse files
authored
Merge pull request #5 from UMLCloudComputing/bug-fixes
fix: remove updates, fix bugs from testing
2 parents 61553c9 + 2324bb5 commit 2e7f71b

File tree

2 files changed

+18
-13
lines changed

2 files changed

+18
-13
lines changed

commands/discord_commands.yaml

Lines changed: 4 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -59,4 +59,7 @@
5959
- name: user
6060
description: mention a user to get their stats (not required)
6161
type: 9 # mentionable
62-
required: false
62+
required: false
63+
64+
- name: warmup
65+
description: warm up the lambda function

src/app/main.py

Lines changed: 14 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -86,7 +86,7 @@ def interact(raw_request):
8686
# update(message: str, token)
8787
match command_name:
8888
case "attend":
89-
send("Submitting attendance...", id, token)
89+
# send("Submitting attendance...", id, token)
9090
code = str(data["options"][0]["value"])
9191
type = str(data["options"][1]["value"])
9292
status = validate_attendance(userID, code, type)
@@ -99,14 +99,14 @@ def interact(raw_request):
9999
message = "The attendance code you have entered you have already used."
100100
case AttendanceStatus.NONEXISTENT:
101101
message = "The attendance code you have entered does not exist."
102-
update(f"{message}", token)
102+
send(f"{message}", id, token)
103103
case "generate":
104104
if admin:
105-
send("Generating attendence code...", id, token)
105+
# send("Generating attendence code...", id, token)
106106
minutes = int(data["options"][0]["value"])
107107
event_name = str(data["options"][1]["value"])
108108
code = generate_code(minutes, event_name)
109-
update(f"Attendence Code for {event_name} is {code} and is valid for {minutes} minutes.", token)
109+
send(f"Attendence Code for {event_name} is {code} and is valid for {minutes} minutes.", id, token)
110110
else: send("Only administrators can generate attendance codes!", id, token)
111111
case "validate":
112112
code = str(data["options"][0]["value"])
@@ -122,10 +122,12 @@ def interact(raw_request):
122122
send_embed(embeds, id, token)
123123
case "reset":
124124
if admin:
125-
send(f"Deleting specified user...", id, token)
125+
# send(f"Deleting specified user...", id, token)
126126
db.delete_user(data["options"][0]["value"])
127-
update("Specified user has been reset.", token)
127+
send("Specified user has been reset.", id, token)
128128
else: send("Only administrators can reset a user!", id, token)
129+
case "warmup":
130+
send("Warming up!", id, token)
129131

130132
# Send a new message
131133
def send(message, id, token):
@@ -188,12 +190,11 @@ def generate_code(expiration_time: int, event_name: str) -> int:
188190
db.write_code(str(code), expire.strftime(DATETIME_FORMAT), event_name)
189191
return code
190192

191-
def validate_code(code: str, expiration=None) -> bool | tuple:
192-
if expiration != None:
193-
code = db.get_code(code)
193+
def validate_code(code: str) -> bool | tuple:
194+
code = db.get_code(code)
194195

195196
valid = False
196-
if code != None or expiration != None:
197+
if code != None:
197198
expiration_datetime = datetime.strptime(code['expiration'], DATETIME_FORMAT)
198199
valid = datetime.now() < expiration_datetime
199200

@@ -206,8 +207,9 @@ def validate_attendance(userid: str, code: str, type: str) -> AttendanceStatus:
206207
code_response = db.get_code(code)
207208

208209
status = AttendanceStatus.NONEXISTENT
209-
if code_response:
210-
active = validate_code(code, expiration=code_response['expiration'])
210+
if code_response:
211+
expiration_datetime = datetime.strptime(code_response['expiration'], DATETIME_FORMAT)
212+
active = datetime.now() < expiration_datetime
211213

212214
if active:
213215
user = db.get_user(userid)

0 commit comments

Comments
 (0)