Telegram: fix /think command to show current level when no arg

This commit is contained in:
Lutro
2026-01-07 12:21:20 +01:00
committed by Peter Steinberger
parent 0d34f330b8
commit 36b443f4f3
4 changed files with 78 additions and 3 deletions

View File

@@ -16,9 +16,9 @@ export function extractThinkDirective(body?: string): {
hasDirective: boolean;
} {
if (!body) return { cleaned: "", hasDirective: false };
// Match the longest keyword first to avoid partial captures (e.g. "/think:high")
// Match with optional argument - require word boundary via lookahead after keyword
const match = body.match(
/(?:^|\s)\/(?:thinking|think|t)\s*:?\s*([a-zA-Z-]+)\b/i,
/(?:^|\s)\/(?:thinking|think|t)(?=$|\s|:)(?:\s*:?\s*([a-zA-Z-]+)\b)?/i,
);
const thinkLevel = normalizeThinkLevel(match?.[1]);
const cleaned = match