[fix]. Reply on unsupported @codex commands
This commit is contained in:
@@ -17,7 +17,7 @@ from sqlalchemy.orm import Session
|
||||
from gitea_codex_bot.config import Settings, get_settings
|
||||
from gitea_codex_bot.db import get_session
|
||||
from gitea_codex_bot.models import JobStatus, ReviewJob
|
||||
from gitea_codex_bot.services.commands import parse_command
|
||||
from gitea_codex_bot.services.commands import detect_prefixed_command, parse_command
|
||||
from gitea_codex_bot.services.gitea import GiteaClient
|
||||
from gitea_codex_bot.services.jobs import cooldown_remaining_seconds, enqueue_job, persist_webhook_event
|
||||
from gitea_codex_bot.services.repo_config import RepoReviewConfig, parse_repo_review_config_text
|
||||
@@ -421,9 +421,31 @@ async def gitea_webhook(
|
||||
if sender_username == settings.gitea_bot_username:
|
||||
return {"accepted": False, "reason": "bot comment ignored"}
|
||||
|
||||
if repo not in settings.allowed_repo_set:
|
||||
logger.info(
|
||||
"Webhook ignored: repo not in ALLOWED_REPOS repo=%s pr=%s comment_id=%s sender=%s",
|
||||
repo,
|
||||
pr_number,
|
||||
comment_id,
|
||||
sender_username,
|
||||
)
|
||||
return {"accepted": False, "reason": "repo not allowed"}
|
||||
|
||||
comment_body = str(payload.get("comment", {}).get("body", "")).strip()
|
||||
parsed_command = parse_command(comment_body, aliases=settings.bot_command_aliases)
|
||||
if not parsed_command:
|
||||
attempted_command = detect_prefixed_command(comment_body, aliases=settings.bot_command_aliases)
|
||||
if attempted_command:
|
||||
gitea = GiteaClient(settings)
|
||||
if attempted_command == "fix":
|
||||
gitea.post_issue_comment(repo, pr_number, "⚠️ `@codex fix` is no longer supported on this bot.")
|
||||
return {"accepted": False, "reason": "unsupported command", "command": attempted_command}
|
||||
gitea.post_issue_comment(
|
||||
repo,
|
||||
pr_number,
|
||||
f"⚠️ Command `@codex {attempted_command}` is not supported. Try `@codex -h`.",
|
||||
)
|
||||
return {"accepted": False, "reason": "unsupported command", "command": attempted_command}
|
||||
logger.info(
|
||||
"Webhook ignored: no @codex review command repo=%s pr=%s comment_id=%s sender=%s",
|
||||
repo,
|
||||
@@ -442,16 +464,6 @@ async def gitea_webhook(
|
||||
parsed_command.name,
|
||||
)
|
||||
|
||||
if repo not in settings.allowed_repo_set:
|
||||
logger.info(
|
||||
"Webhook ignored: repo not in ALLOWED_REPOS repo=%s pr=%s comment_id=%s sender=%s",
|
||||
repo,
|
||||
pr_number,
|
||||
comment_id,
|
||||
sender_username,
|
||||
)
|
||||
return {"accepted": False, "reason": "repo not allowed"}
|
||||
|
||||
inserted = persist_webhook_event(
|
||||
session,
|
||||
delivery_id=x_gitea_delivery,
|
||||
|
||||
Reference in New Issue
Block a user