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

components.Member

orchestra

The orchestra, this instance is associated with.

Type

components.Orchestra

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]

number_of_questions

Number of questions to ask the user.

Type

int

number_of_questions_asked

Number of questions already asked.

Type

int

current_question

Optional. The question currently presented to the user.

Type

components.Question

bot

The bot to use for asking questions.

Type

telegram.Bot

multiple_choice

Whether the question to be asked are multiple choice or free text.

Type

bool

score

The score for this game.

Type

components.Score

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 in components.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 in components.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 to True.

  • Notefe/male_first_names is valid for neither hint_attributes nor question_attributes.

ask_question()

Asks the next question, if there is another.

Raises

RuntimeError – If there are no more questions to be asked.

Return type

None

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 return False, if there is no current question.

Parameters

update (Update) – The telegram.Update to be tested.

Return type

bool

handle_update(update)

Handles the given update. Call only, if check_update() returned True.

Parameters

update (Update) – The telegram.Update to be tested.

Return type

None

questionable()

Gives a list of tuples of components.AttributeManager instances, each representing a pair of hint attribute and question attribute, which is questionable for orchestra and is allowed for this questioner instance.

Return type

List[Tuple[AttributeManager, AttributeManager]]