From ad61ad4643c8e39aa40c8210e92de2b0dc309536 Mon Sep 17 00:00:00 2001 From: Hazel Noack Date: Mon, 28 Jul 2025 17:27:41 +0200 Subject: [PATCH] fetching cargo mommy prompts on mommify --- pyproject.toml | 2 +- python_mommy_venv/responses.py | 15 +++++++++++---- 2 files changed, 12 insertions(+), 5 deletions(-) diff --git a/pyproject.toml b/pyproject.toml index 110eb7f..48b8a72 100644 --- a/pyproject.toml +++ b/pyproject.toml @@ -1,7 +1,7 @@ [project] description = "Mommy's here to support you when running python (in a virtual enviroment)~ ❤️" name = "python_mommy_venv" -dependencies = ["toml"] +dependencies = ["toml", "requests"] authors = [] readme = "README.md" requires-python = ">=3.9" diff --git a/python_mommy_venv/responses.py b/python_mommy_venv/responses.py index 8affb82..a222a90 100644 --- a/python_mommy_venv/responses.py +++ b/python_mommy_venv/responses.py @@ -5,12 +5,13 @@ import os import logging import toml import random +import requests logger = logging.Logger(__name__) PREFIX = "MOMMY" - +RESPONSES_URL = "https://raw.githubusercontent.com/diamondburned/go-mommy/refs/heads/main/responses.json" RESPONSES_FILE = Path(__file__).parent / "responses.json" ADDITIONAL_ENV_VARS = { "pronoun": "PRONOUNS", @@ -116,11 +117,17 @@ def _get_env_value(name: str) -> Optional[str]: return val - -def compile_config(): - global RESPONSES_FILE +def compile_config(disable_requests: bool = False): + global RESPONSES_FILE, RESPONSES_URL data = json.loads(RESPONSES_FILE.read_text()) + + if not disable_requests: + print("mommy downloads newest responses for her girl~") + print(RESPONSES_URL) + r = requests.get(RESPONSES_URL) + data = r.json() + config_definition: Dict[str, dict] = data["vars"] mood_definitions: Dict[str, dict] = data["moods"]