Implement 3 plans
This commit is contained in:
@@ -9,6 +9,7 @@ from core.commands.handlers.bp import (
|
||||
bp_subcommands_enabled,
|
||||
bp_trigger_matches,
|
||||
)
|
||||
from core.commands.handlers.claude import ClaudeCommandHandler, claude_trigger_matches
|
||||
from core.commands.handlers.codex import CodexCommandHandler, codex_trigger_matches
|
||||
from core.commands.policies import ensure_variant_policies_for_profile
|
||||
from core.commands.registry import get as get_handler
|
||||
@@ -123,11 +124,36 @@ def _ensure_codex_profile(user_id: int) -> CommandProfile:
|
||||
return profile
|
||||
|
||||
|
||||
def _ensure_claude_profile(user_id: int) -> CommandProfile:
|
||||
profile, _ = CommandProfile.objects.get_or_create(
|
||||
user_id=user_id,
|
||||
slug="claude",
|
||||
defaults={
|
||||
"name": "Claude",
|
||||
"enabled": True,
|
||||
"trigger_token": ".claude",
|
||||
"reply_required": False,
|
||||
"exact_match_only": False,
|
||||
"window_scope": "conversation",
|
||||
"visibility_mode": "status_in_source",
|
||||
},
|
||||
)
|
||||
if not profile.enabled:
|
||||
profile.enabled = True
|
||||
profile.save(update_fields=["enabled", "updated_at"])
|
||||
if str(profile.trigger_token or "").strip() != ".claude":
|
||||
profile.trigger_token = ".claude"
|
||||
profile.save(update_fields=["trigger_token", "updated_at"])
|
||||
return profile
|
||||
|
||||
|
||||
def _ensure_profile_for_slug(user_id: int, slug: str) -> CommandProfile | None:
|
||||
if slug == "bp":
|
||||
return _ensure_bp_profile(user_id)
|
||||
if slug == "codex":
|
||||
return _ensure_codex_profile(user_id)
|
||||
if slug == "claude":
|
||||
return _ensure_claude_profile(user_id)
|
||||
return None
|
||||
|
||||
|
||||
@@ -137,6 +163,8 @@ def _detected_bootstrap_slugs(message_text: str) -> list[str]:
|
||||
slugs.append("bp")
|
||||
if codex_trigger_matches(message_text, ".codex", False):
|
||||
slugs.append("codex")
|
||||
if claude_trigger_matches(message_text, ".claude", False):
|
||||
slugs.append("claude")
|
||||
return slugs
|
||||
|
||||
|
||||
@@ -202,6 +230,7 @@ def ensure_handlers_registered():
|
||||
return
|
||||
register(BPCommandHandler())
|
||||
register(CodexCommandHandler())
|
||||
register(ClaudeCommandHandler())
|
||||
_REGISTERED = True
|
||||
|
||||
|
||||
@@ -271,6 +300,12 @@ def _matches_trigger(profile: CommandProfile, text: str) -> bool:
|
||||
trigger_token=profile.trigger_token,
|
||||
exact_match_only=profile.exact_match_only,
|
||||
)
|
||||
if profile.slug == "claude":
|
||||
return claude_trigger_matches(
|
||||
message_text=text,
|
||||
trigger_token=profile.trigger_token,
|
||||
exact_match_only=profile.exact_match_only,
|
||||
)
|
||||
body = str(text or "").strip()
|
||||
trigger = str(profile.trigger_token or "").strip()
|
||||
if not trigger:
|
||||
|
||||
Reference in New Issue
Block a user