add env var handling

This commit is contained in:
Enzo Nunes
2025-11-18 21:43:17 +00:00
parent 75fcbb4452
commit cd60dd5653
2 changed files with 7 additions and 11 deletions

View File

@@ -1,5 +1,4 @@
from asyncio import Condition, Lock, create_task, shield, to_thread, wait_for
from sys import argv
from os import getenv
import requests
@@ -8,7 +7,7 @@ from discord.ext import commands
from PICable import PICable
MAX_STORAGE_KB = 10 * 1024 * 1024 # 10GB
MAX_STORAGE_KB = 50 * 1024 * 1024 # 50GB
if __name__ == "__main__":
current_storage_kb = 0
@@ -28,7 +27,6 @@ if __name__ == "__main__":
client = commands.Bot(command_prefix="/", intents=intents)
client.run(discord_token)
@client.event
async def on_ready():
print(f"We have logged in as {client.user}")
@@ -39,13 +37,11 @@ if __name__ == "__main__":
except Exception as e:
print(f"Failed to sync commands: {e}")
@client.tree.command(name="ping", description="Check the bot's latency.")
async def ping(interaction: Interaction):
latency = client.latency * 1000
await interaction.response.send_message(f"Pong! Latency: {latency:.2f}ms")
async def handle_picable(owner: str, repository: str, repository_size_kb: int, github_token: str):
global current_storage_kb
async with storage_condition:
@@ -55,7 +51,6 @@ if __name__ == "__main__":
print(f"Storage is {current_storage_kb / MAX_STORAGE_KB * 100:.2f}% full.")
return await to_thread(PICable, owner, repository, github_token)
@client.tree.command(name="picable", description="Check if a Github repository is eligible for PIC.")
@app_commands.describe(owner="The owner of the repository", repository="The name of the repository")
async def picable(interaction: Interaction, owner: str, repository: str):
@@ -77,7 +72,7 @@ if __name__ == "__main__":
if not response.status_code == 200:
await interaction.followup.send(
f"Invalid Repository. Please check the repository name and owner and try again. :x:"
"Invalid Repository. Please check the repository name and owner and try again. :x:"
)
return