fix: improve message handling and formatting in build_message function
All checks were successful
Lint and Syntax Check / build (push) Successful in 11s

This commit is contained in:
Space-Banane
2026-04-04 16:17:58 +02:00
parent cd79af6599
commit 73335050aa

27
main.py
View File

@@ -102,19 +102,29 @@ def build_message(event_object, action_str, type_str):
print(
f"Custom prompt file not found at {AGENT_PROMPT_FILE_PATH}. Using default message."
)
message = fill_template(DEFAULT_PROMPT_TEMPLATE, event_object, action_str, type_str)
message = message.replace("You were [action_str] to an [type_str]", action_summary)
message = fill_template(
DEFAULT_PROMPT_TEMPLATE, event_object, action_str, type_str
)
message = message.replace(
"You were [action_str] to an [type_str]", action_summary
)
return message
with open(AGENT_PROMPT_FILE_PATH, "r") as f:
custom_prompt = f.read()
message = fill_template(custom_prompt, event_object, action_str, type_str)
message = message.replace("You were [action_str] to an [type_str]", action_summary)
message = message.replace(
"You were [action_str] to an [type_str]", action_summary
)
return message
else:
print("No custom prompt file specified. Using default message.")
message = fill_template(DEFAULT_PROMPT_TEMPLATE, event_object, action_str, type_str)
message = message.replace("You were [action_str] to an [type_str]", action_summary)
message = fill_template(
DEFAULT_PROMPT_TEMPLATE, event_object, action_str, type_str
)
message = message.replace(
"You were [action_str] to an [type_str]", action_summary
)
return message
@@ -135,7 +145,9 @@ def sendToAgent(event_object):
else:
action_str = "assigned"
type_str = "issue" if event_object["type"] == "issue" else "pull request"
assignees = event_object.get("assignees", [event_object.get("assignee", "Unknown")])
assignees = event_object.get(
"assignees", [event_object.get("assignee", "Unknown")]
)
if AGENT_USERNAME not in assignees:
print(
f"Agent {AGENT_USERNAME} is not among the assignees for this event. Skipping notification."
@@ -157,6 +169,7 @@ def sendToAgent(event_object):
"thinking": "low",
"timeoutSeconds": 45,
"model": OPENCLAW_MODEL,
"deliver": False,
},
auth=auth,
)
@@ -339,7 +352,7 @@ def main(args):
set_stored_assignees(
db, event_type, repo_id, event_object["number"], assignees_list
)
# Send to OpenClaw
if action == "assigned":
sendToAgent(event_object)