Preparation for new year of PIC
This commit is contained in:
15
Dockerfile
Normal file
15
Dockerfile
Normal file
@@ -0,0 +1,15 @@
|
||||
FROM python:3.14-slim
|
||||
|
||||
# Copy your code
|
||||
WORKDIR /app
|
||||
RUN pip install --no-cache-dir discord asyncio requests
|
||||
|
||||
COPY main.py .
|
||||
COPY PICable.py .
|
||||
|
||||
# Drop privileges (optional but good practice)
|
||||
RUN useradd -m appuser
|
||||
USER appuser
|
||||
|
||||
# Start the scheduler script
|
||||
CMD ["python", "main.py"]
|
||||
@@ -1,2 +1,3 @@
|
||||
# PICable
|
||||
|
||||
Simple script to determine if a project is eligible as the final PIC of LEIC-T.
|
||||
|
||||
8
docker-compose.yml
Normal file
8
docker-compose.yml
Normal file
@@ -0,0 +1,8 @@
|
||||
services:
|
||||
picable:
|
||||
build: .
|
||||
container_name: picable
|
||||
environment:
|
||||
- PICABLE_DISCORD_TOKEN=yourdiscordtoken
|
||||
- PICABLE_GITHUB_TOKEN=yourgithubtoken
|
||||
restart: unless-stopped
|
||||
16
main.py
16
main.py
@@ -1,5 +1,6 @@
|
||||
from asyncio import Condition, Lock, create_task, shield, to_thread, wait_for
|
||||
from sys import argv
|
||||
from os import getenv
|
||||
|
||||
import requests
|
||||
from discord import Game, Intents, Interaction, app_commands
|
||||
@@ -8,20 +9,24 @@ from discord.ext import commands
|
||||
from PICable import PICable
|
||||
|
||||
MAX_STORAGE_KB = 10 * 1024 * 1024 # 10GB
|
||||
|
||||
if __name__ == "__main__":
|
||||
current_storage_kb = 0
|
||||
storage_condition = Condition()
|
||||
current_repositories = set()
|
||||
current_repositories_lock = Lock()
|
||||
|
||||
if len(argv) != 3:
|
||||
print("Usage:\n\t" + argv[0] + " <discord_token> <github_token>")
|
||||
discord_token = getenv("PICABLE_DISCORD_TOKEN")
|
||||
github_token = getenv("PICABLE_GITHUB_TOKEN")
|
||||
|
||||
if not discord_token or not github_token:
|
||||
print("Discord or Github tokens not set in env. Use variables PICABLE_DISCORD_TOKEN and PICABLE_GITHUB_TOKEN")
|
||||
exit(1)
|
||||
discord_token = argv[1]
|
||||
github_token = argv[2]
|
||||
|
||||
intents = Intents.default()
|
||||
intents.message_content = True
|
||||
client = commands.Bot(command_prefix="/", intents=intents)
|
||||
client.run(discord_token)
|
||||
|
||||
|
||||
@client.event
|
||||
@@ -109,6 +114,3 @@ async def picable(interaction: Interaction, owner: str, repository: str):
|
||||
async with storage_condition:
|
||||
current_storage_kb -= repository_size_kb
|
||||
storage_condition.notify_all()
|
||||
|
||||
|
||||
client.run(discord_token)
|
||||
|
||||
Reference in New Issue
Block a user