Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Updates and corrections #67

Merged
merged 5 commits into from
Sep 5, 2024
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
2 changes: 1 addition & 1 deletion Dockerfile
Original file line number Diff line number Diff line change
Expand Up @@ -51,4 +51,4 @@ COPY poetry.lock pyproject.toml ./
RUN poetry install --only=main

COPY . /app/
ENTRYPOINT poetry run python -O launcher.py
ENTRYPOINT ["poetry", "run", "python", "-O", "launcher.py" ]
4 changes: 4 additions & 0 deletions config.template.toml
Original file line number Diff line number Diff line change
Expand Up @@ -31,3 +31,7 @@ url = 'http://snekbox:8060/eval' # default url

[GITHUB] # optional
bot_secret = ""

[WEBSERVER] # optional
host = "127.0.0.1"
port = 2332
2 changes: 0 additions & 2 deletions dev-requirements.txt

This file was deleted.

17 changes: 6 additions & 11 deletions docker-compose.yml
Original file line number Diff line number Diff line change
@@ -1,14 +1,15 @@
services:
bot:
container_name: pythonista-bot
depends_on:
- database
image: ghcr.io/pythonistaguild/pythonista-bot:latest
container_name: pythonista-bot
restart: unless-stopped
volumes:
- ./config.toml:/app/config.toml:ro
depends_on:
- database

database:
image: postgres
container_name: pythonista-bot-db
env_file:
- .env
Expand All @@ -19,21 +20,16 @@ services:
healthcheck:
interval: 1s
retries: 10
test:
[
"CMD-SHELL",
"pg_isready -d $${POSTGRES_DB} -U $${POSTGRES_USER}"
]
test: ["CMD-SHELL", "pg_isready -d $${POSTGRES_DB} -U $${POSTGRES_USER}"]
timeout: 5s
image: postgres
restart: always
volumes:
- pgdata:/var/lib/postgresql/data
- ./database/schema.sql:/docker-entrypoint-initdb.d/schema.sql:ro

snekbox:
container_name: snekbox-eval
image: ghcr.io/python-discord/snekbox
container_name: snekbox-eval
ipc: "none"
ports:
- "127.0.0.1:8060:8060"
Expand All @@ -42,6 +38,5 @@ services:
- "snekbox"
restart: always

version: "3"
volumes:
pgdata:
14 changes: 8 additions & 6 deletions launcher.py
Original file line number Diff line number Diff line change
Expand Up @@ -63,12 +63,14 @@ async def main() -> None:
extension.name,
)

app: Application = Application(bot=bot)
config: uvicorn.Config = uvicorn.Config(app, port=2332)
server: uvicorn.Server = uvicorn.Server(config)

tasks.add(asyncio.create_task(bot.start(core.CONFIG["TOKENS"]["bot"])))
await server.serve()
server_config = core.CONFIG.get("WEBSERVER")
if server_config:
app: Application = Application(bot=bot)
config: uvicorn.Config = uvicorn.Config(app, host=server_config["host"], port=server_config["port"])
server: uvicorn.Server = uvicorn.Server(config)

tasks.add(asyncio.create_task(server.serve()))
await bot.start(core.CONFIG["TOKENS"]["bot"])


try:
Expand Down
825 changes: 608 additions & 217 deletions poetry.lock

Large diffs are not rendered by default.

9 changes: 3 additions & 6 deletions pyproject.toml
Original file line number Diff line number Diff line change
Expand Up @@ -12,7 +12,9 @@ readme = "README.md"

[tool.poetry.dependencies]
python = "^3.11"
"discord.py" = { git = "https://github.com/Rapptz/discord.py.git"}
"discord.py" = { git = "https://github.com/Rapptz/discord.py.git", extras = [
"speed",
] }
aiohttp = "*"
asyncpg = "*"
toml = "*"
Expand All @@ -26,16 +28,11 @@ ruff = "*"
"asyncpg-stubs" = "*"
"typing-extensions" = "*"

[tool.black]
line-length = 125
preview = true

[tool.ruff]
line-length = 125
target-version = "py311"

[tool.ruff.lint]
exclude = ["docs/extensions/*.py"]
select = [
"C4",
"F",
Expand Down
9 changes: 0 additions & 9 deletions requirements.txt

This file was deleted.

6 changes: 6 additions & 0 deletions types_/config.py
Original file line number Diff line number Diff line change
Expand Up @@ -34,6 +34,11 @@ class Suggestions(TypedDict):
webhook_url: str


class Webserver(TypedDict):
host: str
port: int


class Config(TypedDict):
prefix: str
owner_ids: NotRequired[list[int]]
Expand All @@ -43,3 +48,4 @@ class Config(TypedDict):
SNEKBOX: NotRequired[Snekbox]
BADBIN: BadBin
SUGGESTIONS: NotRequired[Suggestions]
WEBSERVER: NotRequired[Webserver]
Loading