Add poll chat command with reaction voting

This commit is contained in:
Fisto
2026-09-11 15:59:08 +02:00
parent 8e8c15e8bc
commit ace0bb18ff
16 changed files with 291 additions and 9 deletions
+20
View File
@@ -187,6 +187,26 @@ export function parseTier(value: string): TrustTier | undefined {
return value === "user" || value === "trusted" || value === "admin" ? value : undefined;
}
/* Polls */
export const POLL_EMOJIS = ["1️⃣", "2️⃣", "3️⃣", "4️⃣"];
export interface ParsedPoll {
question: string;
options: string[];
}
/** Parse `question | option 1 | option 2 [| option 3 [| option 4]]`. */
export function parsePoll(text: string): ParsedPoll | undefined {
const parts = text.split("|").map(part => part.trim()).filter(Boolean);
if (parts.length < 3 || parts.length > 5) return undefined;
const [question, ...options] = parts;
if (!question || options.length < 2 || options.some(option => option.length > 80)) return undefined;
return { question: question.slice(0, 200), options: options.map(option => option.slice(0, 80)) };
}
/* Secret redaction for persistent logs. Keep it minimal. */
const SECRET_PATTERNS = [