From cd60dd565308df3b695679af4958d7e2288efe6f Mon Sep 17 00:00:00 2001 From: Enzo Nunes Date: Tue, 18 Nov 2025 21:43:17 +0000 Subject: [PATCH] add env var handling --- PICable.py | 9 +++++---- main.py | 9 ++------- 2 files changed, 7 insertions(+), 11 deletions(-) diff --git a/PICable.py b/PICable.py index 39a6d69..2427144 100644 --- a/PICable.py +++ b/PICable.py @@ -5,11 +5,12 @@ from datetime import datetime, timedelta import requests -LIMIT_COMMITS_30_DAYS = 50 -LIMIT_STARS = 200 -LIMIT_NLOC = 100000 +LIMIT_COMMITS_30_DAYS = int(os.getenv("LIMIT_COMMITS_30_DAYS", "50")) +LIMIT_STARS = int(os.getenv("LIMIT_STARS", "200")) +LIMIT_NLOC = int(os.getenv("LIMIT_NLOC", "100000")) + MARGIN = 0.1 -CLONE_DIR = "~/temp/PICable" +CLONE_DIR = "/temp" EXCLUDED_LANGUAGES = ["CSV", "diff", "INI", "JSON", "Markdown", "reStructuredText", "SVG", "Text", "YAML"] diff --git a/main.py b/main.py index 6af23af..b6d12c4 100644 --- a/main.py +++ b/main.py @@ -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