Implement tasks

This commit is contained in:
2026-03-02 12:45:24 +00:00
parent 6986c1b5ab
commit e1de6d016d
29 changed files with 2970 additions and 172 deletions

View File

@@ -1,9 +1,14 @@
from __future__ import annotations
from asgiref.sync import sync_to_async
from django.conf import settings
from core.commands.base import CommandContext, CommandResult
from core.commands.handlers.bp import BPCommandHandler
from core.commands.handlers.bp import (
BPCommandHandler,
bp_reply_is_optional_for_trigger,
bp_trigger_matches,
)
from core.commands.registry import get as get_handler
from core.commands.registry import register
from core.messaging.reply_sync import is_mirrored_origin
@@ -86,6 +91,12 @@ async def _eligible_profiles(ctx: CommandContext) -> list[CommandProfile]:
def _matches_trigger(profile: CommandProfile, text: str) -> bool:
if profile.slug == "bp" and bool(getattr(settings, "BP_SUBCOMMANDS_V1", True)):
return bp_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:
@@ -111,15 +122,22 @@ async def process_inbound_message(ctx: CommandContext) -> list[CommandResult]:
if not _matches_trigger(profile, ctx.message_text):
continue
if profile.reply_required and trigger_message.reply_to_id is None:
results.append(
CommandResult(
ok=False,
status="skipped",
error="reply_required",
payload={"profile": profile.slug},
if (
profile.slug == "bp"
and bool(getattr(settings, "BP_SUBCOMMANDS_V1", True))
and bp_reply_is_optional_for_trigger(ctx.message_text)
):
pass
else:
results.append(
CommandResult(
ok=False,
status="skipped",
error="reply_required",
payload={"profile": profile.slug},
)
)
)
continue
continue
handler = get_handler(profile.slug)
if handler is None:
results.append(