A quiz to be sent.

Quiz is an extended version of a poll, but quizzes have correct answers, and votes can't be retracted from them

interface InputMediaQuiz {
    answers: (InputText | RawPollAnswer)[];
    caption?: InputText;
    closeDate?: number | Date;
    closePeriod?: number;
    closed?: boolean;
    correct: MaybeArray<number | Uint8Array>;
    multiple?: boolean;
    public?: boolean;
    question: InputText;
    solution?: InputText;
    type: "quiz";
}

Hierarchy

Properties

answers: (InputText | RawPollAnswer)[]

Answers of the poll.

You can either provide a string, or a TL object representing an answer. Strings will be transformed to TL objects, with a single=byte incrementing option value.

caption?: InputText

Caption of the media

closeDate?: number | Date

Point in time when the poll will be automatically closed.

Must be at least 5 and no more than 600 seconds in the future, can't be used together with closePeriod.

When number is used, UNIX time in ms is expected

closePeriod?: number

Amount of time in seconds the poll will be active after creation (5-600).

Can't be used together with closeDate.

closed?: boolean

Whether this is poll is closed (i.e. nobody can vote anymore)

correct: MaybeArray<number | Uint8Array>

Correct answer ID(s) or index(es).

Note: even though quizzes can actually only have exactly one correct answer, the API itself has the possibility to pass multiple or zero correct answers, but that would result in QUIZ_CORRECT_ANSWERS_TOO_MUCH and QUIZ_CORRECT_ANSWERS_EMPTY errors respectively.

But since the API has that option, we also provide it, maybe to future-proof this :shrug:

multiple?: boolean

Whether users can select multiple answers as an answer

public?: boolean

Whether this is a public poll (i.e. users who have voted are visible to everyone)

question: InputText

Question of the poll (1-255 chars for users, 1-300 chars for bots)

solution?: InputText

Explanation of the quiz solution

type: "quiz"