ask_user puts up to six questions on one card (radios for one pick, checkboxes for several, an optional typed Other) as a [question:ID] chip. The user's answers are checked against the questions, stored in bot_questions and sent to the bot as their chat message; Skip says so. Offered in chat replies and user-started tasks, never in routines, hook calls or chatroom sessions. Co-Authored-By: Claude Opus 5.5 <[email protected]>
29 lines
781 B
TypeScript
29 lines
781 B
TypeScript
type Params = {
|
|
id: number | string;
|
|
};
|
|
|
|
/**
|
|
* How a bot names questions it asked the user: `[question:4]`. The chat
|
|
* turns it into a link (`linkComputerRefs`) that renders as a chip opening
|
|
* the card the user answers them in.
|
|
*/
|
|
export default function botQuestionRef({ id }: Params) {
|
|
return `[question:${id}]`;
|
|
}
|
|
|
|
/**
|
|
* The link target a question ref becomes, e.g. `#question-4`.
|
|
*/
|
|
export const BotQuestionRefHrefPrefix = "#question-";
|
|
|
|
/**
|
|
* The id in a question ref's link target, or null.
|
|
*/
|
|
export function botQuestionRefId({ href }: { href?: string | null }) {
|
|
if (!href?.startsWith(BotQuestionRefHrefPrefix)) return null;
|
|
|
|
const id = Number(href.slice(BotQuestionRefHrefPrefix.length));
|
|
|
|
return Number.isInteger(id) && id > 0 ? id : null;
|
|
}
|