Add poll chat command with reaction voting
This commit is contained in:
@@ -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 = [
|
||||
|
||||
Reference in New Issue
Block a user