Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
3 changes: 2 additions & 1 deletion .env.example
Original file line number Diff line number Diff line change
Expand Up @@ -19,4 +19,5 @@ PORT=your_health_check_port
# Other Environment Variables
# Add any additional configuration here
# Hermes config
EXECUTION_API_URL=your_code_execution_url
EXECUTION_API_URL=your_code_execution_url
EXECUTION_API_KEY=your_code_execution_token
11 changes: 8 additions & 3 deletions bot/cogs/hermes.py
Original file line number Diff line number Diff line change
Expand Up @@ -11,13 +11,16 @@
from bot.constants import tortoise_guild_id

EXECUTE_URL = os.getenv("EXECUTION_API_URL")
API_TOKEN = os.getenv("EXECUTION_API_KEY")


LANG_ALIASES = {
"py": "python",
"python": "python",
"js": "javascript",
"javascript": "javascript",
"java": "java",
"cpp": "cpp",
}

view = discord.ui.View()
Expand Down Expand Up @@ -69,8 +72,10 @@ async def _execute(self, language: str, code: str):
"language": language,
"code": code,
}

async with self.session.post(EXECUTE_URL, json=payload, timeout=30) as resp:
headers = {
"Authorization": f"Bearer {API_TOKEN}",
}
async with self.session.post(EXECUTE_URL, json=payload, headers=headers, timeout=30) as resp:
if resp.status == 429:
return {
"code": -1,
Expand Down Expand Up @@ -154,7 +159,7 @@ async def on_message(self, message: discord.Message):

if not lang:
await message.channel.send(
embed=failure("Unsupported language. Use python, javascript or java in the code block header.")
embed=failure("Unsupported language. Use python, javascript, java or cpp in the code block header.")
)
return

Expand Down
Loading