Skip to content

Commit 6563f28

Browse files
authored
Feat disallow streams (#374)
* Feat: add stream warning * Typos * push * push
1 parent 81349cd commit 6563f28

File tree

2 files changed

+15
-0
lines changed

2 files changed

+15
-0
lines changed

src/kernelbot/api/api_utils.py

Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -272,6 +272,11 @@ async def to_submit_info(
272272

273273
try:
274274
submission_code = submission_content.decode("utf-8")
275+
if "stream" in submission_code.lower():
276+
raise HTTPException(
277+
status_code=500,
278+
detail="Your code contains work on another stream. This is not allowed and may result in your disqualification. If you think this is a mistake, please contact us.", # noqa: E501
279+
)
275280
submission_request = SubmissionRequest(
276281
code=submission_code,
277282
file_name=file.filename or "submission.py",
@@ -285,6 +290,8 @@ async def to_submit_info(
285290
status_code=400,
286291
detail="Failed to decode submission file content as UTF-8.",
287292
) from None
293+
except HTTPException:
294+
raise
288295
except Exception as e:
289296
raise HTTPException(
290297
status_code=500,

src/kernelbot/cogs/leaderboard_cog.py

Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -109,6 +109,14 @@ async def submit(
109109
if not interaction.response.is_done():
110110
await interaction.response.defer(ephemeral=True)
111111

112+
if "stream" in submission_content.lower():
113+
await send_discord_message(
114+
interaction,
115+
"Your code contains work on another stream. This is not allowed and may result in your disqualification. If you think this is a mistake, please contact us.", # noqa: E501
116+
ephemeral=True,
117+
)
118+
return -1
119+
112120
req = SubmissionRequest(
113121
code=submission_content,
114122
file_name=script.filename,

0 commit comments

Comments
 (0)