components.Questioner¶
- class components.Questioner(user_id, orchestra, hint_attributes, question_attributes, number_of_questions, bot, multiple_choice=True)¶
Bases:
object
Helper class generating and tracking the questions of a single game for a single user.
- member¶
The member, this instance is associated with.
- Type
- orchestra¶
The orchestra, this instance is associated with.
- Type
- hint_attributes¶
Subset of the keys of
components.Question.SUPPORTED_ATTRIBUTES
. These will be given as hints for the questions.- Type
List[
str
]
- question_attributes¶
Subset of the keys of
components.Question.SUPPORTED_ATTRIBUTES
. These will be asked for in the questions.- Type
List[
str
]
- current_question¶
Optional. The question currently presented to the user.
- Type
- bot¶
The bot to use for asking questions.
- Type
- score¶
The score for this game.
- Type
- Parameters
user_id (
int
) – The ID of the user this instance is associated with.orchestra (
Orchestra
) – The orchestra, this instance is associated with.hint_attributes (
List
[str
]) – List of strings, appearing either incomponents.Question.SUPPORTED_ATTRIBUTES
. These will be given as hints for the questions. May be empty, in which case all available attributes are allowed.question_attributes (
List
[str
]) – List of strings, appearing either incomponents.Question.SUPPORTED_ATTRIBUTES
. These will be asked for in the questions. May be empty, in which case all available attributes are allowed.number_of_questions (
int
) – Number of questions to ask the user.bot (
Bot
) – The bot to use for asking questions.multiple_choice (
bool
) – Whether the question to be asked are multiple choice or free text. Defaults toTrue
.Note –
fe/male_first_names
is valid for neitherhint_attributes
norquestion_attributes
.
- ask_question()¶
Asks the next question, if there is another.
- Raises
RuntimeError – If there are no more questions to be asked.
- Return type
- check_update(update)¶
Checks, if th given update is a valid response to the current question and can be handled by
current_question.check_answer()
. Will returnFalse
, if there is no current question.- Parameters
update (
Update
) – Thetelegram.Update
to be tested.- Return type
- handle_update(update)¶
Handles the given update. Call only, if
check_update()
returnedTrue
.- Parameters
update (
Update
) – Thetelegram.Update
to be tested.- Return type