diff --git a/pkgs/matrix-bot/.gitignore b/pkgs/matrix-bot/.gitignore index 8b897a3..7020ffe 100644 --- a/pkgs/matrix-bot/.gitignore +++ b/pkgs/matrix-bot/.gitignore @@ -1,2 +1,3 @@ *.json **/data +**/__pycache__ diff --git a/pkgs/matrix-bot/matrix_bot/__init__.py b/pkgs/matrix-bot/matrix_bot/__init__.py index eb4935a..ee1b443 100644 --- a/pkgs/matrix-bot/matrix_bot/__init__.py +++ b/pkgs/matrix-bot/matrix_bot/__init__.py @@ -119,6 +119,9 @@ def create_parser(prog: str | None = None) -> argparse.ArgumentParser: def matrix_password() -> str: + matrix_password = environ.get("MATRIX_PASSWORD") + if matrix_password is not None: + return matrix_password matrix_password_file = environ.get("MATRIX_PASSWORD_FILE", default=None) if matrix_password_file is None: raise Exception("MATRIX_PASSWORD_FILE environment variable is not set") diff --git a/pkgs/matrix-bot/matrix_bot/__pycache__/__init__.cpython-311.pyc b/pkgs/matrix-bot/matrix_bot/__pycache__/__init__.cpython-311.pyc deleted file mode 100644 index f943ede..0000000 Binary files a/pkgs/matrix-bot/matrix_bot/__pycache__/__init__.cpython-311.pyc and /dev/null differ diff --git a/pkgs/matrix-bot/matrix_bot/__pycache__/bot.cpython-311.pyc b/pkgs/matrix-bot/matrix_bot/__pycache__/bot.cpython-311.pyc deleted file mode 100644 index ac094c8..0000000 Binary files a/pkgs/matrix-bot/matrix_bot/__pycache__/bot.cpython-311.pyc and /dev/null differ diff --git a/pkgs/matrix-bot/matrix_bot/__pycache__/changelog_bot.cpython-311.pyc b/pkgs/matrix-bot/matrix_bot/__pycache__/changelog_bot.cpython-311.pyc deleted file mode 100644 index 9c3bd79..0000000 Binary files a/pkgs/matrix-bot/matrix_bot/__pycache__/changelog_bot.cpython-311.pyc and /dev/null differ diff --git a/pkgs/matrix-bot/matrix_bot/__pycache__/custom_logger.cpython-311.pyc b/pkgs/matrix-bot/matrix_bot/__pycache__/custom_logger.cpython-311.pyc deleted file mode 100644 index 21b0c49..0000000 Binary files a/pkgs/matrix-bot/matrix_bot/__pycache__/custom_logger.cpython-311.pyc and /dev/null differ diff --git a/pkgs/matrix-bot/matrix_bot/__pycache__/gitea.cpython-311.pyc b/pkgs/matrix-bot/matrix_bot/__pycache__/gitea.cpython-311.pyc deleted file mode 100644 index 6b16dfe..0000000 Binary files a/pkgs/matrix-bot/matrix_bot/__pycache__/gitea.cpython-311.pyc and /dev/null differ diff --git a/pkgs/matrix-bot/matrix_bot/__pycache__/locked_open.cpython-311.pyc b/pkgs/matrix-bot/matrix_bot/__pycache__/locked_open.cpython-311.pyc deleted file mode 100644 index b835597..0000000 Binary files a/pkgs/matrix-bot/matrix_bot/__pycache__/locked_open.cpython-311.pyc and /dev/null differ diff --git a/pkgs/matrix-bot/matrix_bot/__pycache__/main.cpython-311.pyc b/pkgs/matrix-bot/matrix_bot/__pycache__/main.cpython-311.pyc deleted file mode 100644 index 5c46ee1..0000000 Binary files a/pkgs/matrix-bot/matrix_bot/__pycache__/main.cpython-311.pyc and /dev/null differ diff --git a/pkgs/matrix-bot/matrix_bot/__pycache__/matrix.cpython-311.pyc b/pkgs/matrix-bot/matrix_bot/__pycache__/matrix.cpython-311.pyc deleted file mode 100644 index ae374ee..0000000 Binary files a/pkgs/matrix-bot/matrix_bot/__pycache__/matrix.cpython-311.pyc and /dev/null differ diff --git a/pkgs/matrix-bot/matrix_bot/__pycache__/openai.cpython-311.pyc b/pkgs/matrix-bot/matrix_bot/__pycache__/openai.cpython-311.pyc deleted file mode 100644 index 4b3ce15..0000000 Binary files a/pkgs/matrix-bot/matrix_bot/__pycache__/openai.cpython-311.pyc and /dev/null differ diff --git a/pkgs/matrix-bot/matrix_bot/__pycache__/review_bot.cpython-311.pyc b/pkgs/matrix-bot/matrix_bot/__pycache__/review_bot.cpython-311.pyc deleted file mode 100644 index e56b6a6..0000000 Binary files a/pkgs/matrix-bot/matrix_bot/__pycache__/review_bot.cpython-311.pyc and /dev/null differ diff --git a/pkgs/matrix-bot/matrix_bot/changelog_bot.py b/pkgs/matrix-bot/matrix_bot/changelog_bot.py index 40069ad..a760757 100644 --- a/pkgs/matrix-bot/matrix_bot/changelog_bot.py +++ b/pkgs/matrix-bot/matrix_bot/changelog_bot.py @@ -133,7 +133,7 @@ async def changelog_bot( return # If you made a new room and haven't joined as that user, you can use - room: JoinResponse = await client.join(matrix.review_room) + room: JoinResponse = await client.join(matrix.changelog_room) if not room.transport_response.ok: log.error("This can happen if the room doesn't exist or the bot isn't invited") @@ -160,17 +160,17 @@ async def changelog_bot( log.info(f"Generating changelog from {fromdate} to {todate}") system_prompt = f""" -Generate a concise changelog for the past week from {fromdate} to {todate}, -focusing only on new features and summarizing bug fixes into a single entry. -Ensure the following: +Create a concise changelog for the past week from {fromdate} to {todate}, focusing on new features and summarizing bug fixes into a single entry. Follow these guidelines: -- Deduplicate entries +- Discard duplicate entries - Discard uninteresting changes -- Keep the summary as brief as possible - Use present tense -- Our commit messages are in the format: "scope: message". For example: "changelog: Add a new feature" -- Only ever mention the same feature once -The changelog is as follows: +- Keep the summary brief +- Follow commit message format: "scope: message (#number)" +- Link pull requests as: '{gitea.url}/{gitea.owner}/{gitea.repo}/pull/' +- Mention each feature only once + +Changelog: --- """ diff --git a/pkgs/matrix-bot/matrix_bot/openai.py b/pkgs/matrix-bot/matrix_bot/openai.py index 593bf44..acdaa00 100644 --- a/pkgs/matrix-bot/matrix_bot/openai.py +++ b/pkgs/matrix-bot/matrix_bot/openai.py @@ -12,6 +12,10 @@ url: str = "https://api.openai.com/v1/chat/completions" def api_key() -> str: + openapi_key = environ.get("OPENAI_API_KEY") + if openapi_key is not None: + return openapi_key + openai_key_file = environ.get("OPENAI_API_KEY_FILE", default=None) if openai_key_file is None: raise Exception("OPENAI_API_KEY_FILE environment variable is not set")