components.Orchestra

class components.Orchestra

Bases: components.picklablebase.PicklableBase

An orchestra. Keeps tracks of its members.

Note

Orchestra instance support subscription for all attribute managers listed as keys of SUBSCRIPTABLE.

attribute_managers

A dictionary of attribute managers keeping track of the members

Type

Dict[str, components.AttributeManager]

SUBSCRIPTABLE = ['address', 'addresses', 'age', 'ages', 'birthday', 'birthdays', 'first_name', 'first_names', 'full_name', 'full_names', 'instruments', 'last_name', 'last_names', 'nickname', 'nicknames', 'photo_file_id', 'photo_file_ids', 'joined', 'functions']

Attribute managers supported by subscription.

Type

List[str]

TO_HR: Dict[str, str] = {'address': 'Adresse', 'addresses': 'Adresse', 'age': 'Alter', 'ages': 'Alter', 'birthday': 'Geburtstag', 'birthdays': 'Geburtstag', 'first_name': 'Vorname', 'first_names': 'Vorname', 'full_name': 'Ganzer Name', 'full_names': 'Ganzer Name', 'functions': 'Ämter', 'instruments': 'Instrument', 'joined': 'Beitrittsjahr', 'last_name': 'Nachname', 'last_names': 'Nachname', 'nickname': 'Spitzname', 'nicknames': 'Spitzname', 'photo_file_id': 'Foto', 'photo_file_ids': 'Foto'}

A map from the names of the different properties of this class to the human readable strings.

Type

Dict[str, str]

copy()

Returns a (deep) copy of this orchestra.

Return type

Orchestra

kick_member(member)

Kicks a member from the orchestra.

Parameters

member (Member) – The member to kick.

Raises

ValueError – If member is not registered.

Return type

None

property members: Dict[int, components.member.Member]

All the members of the orchestra. The keys are the components.Member.user_id s, the values are the actual members.

Return type

Dict[int, Member]

property months_score: List[components.score.Score]

Gives a list of each members score of the current month sorted descending by components.Score.ratio .

Return type

List[Score]

months_score_text(length=None, html=False)

String representation of months_score.

Parameters
  • length (Optional[int]) – Maximum number of members to display. If not passed, will write down all members.

  • html (Optional[bool]) – If True, will embed HTML tags in the string. Use this to send the string with a Telegram bot using telegram.ParseMode.HTML.

Return type

str

property overall_score: List[components.score.Score]

Gives a list of each members overall score sorted descending by components.Score.ratio .

Return type

List[Score]

overall_score_text(length=None, html=False)

String representation of overall_score.

Parameters
  • length (Optional[int]) – Maximum number of members to display. If not passed, will write down all members.

  • html (Optional[bool]) – If True, will embed HTML tags in the string. Use this to send the string with a Telegram bot using telegram.ParseMode.HTML.

Return type

str

questionable(multiple_choice=True, exclude_members=None)

Gives a list of tuples of components.AttributeManager instances, each representing a pair of hint attribute and question attribute, which have enough different values for the orchestras members to generate questions from it.

Parameters
  • multiple_choice (bool) – Optional. Whether the questions will be multiple choice or free text. Defaults to True.

  • exclude_members (Optional[Iterable[Member]]) – Optional. Members to exclude from serving as hint.

Return type

List[Tuple[AttributeManager, AttributeManager]]

register_member(member)

Registers a new member for this orchestra.

Note

Copies the member so changes to the instance wont directly affect the orchestra. Use update_member() to update the information about this member.

Parameters

member (Member) – The new member

Raises

ValueError – If member is already registered.

Return type

None

property todays_score: List[components.score.Score]

Gives a list of each members score of today sorted descending by components.Score.ratio .

Return type

List[Score]

todays_score_text(length=None, html=False)

String representation of todays_score.

Parameters
  • length (Optional[int]) – Maximum number of members to display. If not passed, will write down all members.

  • html (Optional[bool]) – If True, will embed HTML tags in the string. Use this to send the string with a Telegram bot using telegram.ParseMode.HTML.

Return type

str

update_member(member)

Updates the information of a member. As register_user(), this will copy the member. To update the information again, call this method again.

Parameters

member (Member) – The member with new information.

Return type

None

property weeks_score: List[components.score.Score]

Gives a list of each members score of the current week sorted descending by components.Score.ratio .

Return type

List[Score]

weeks_score_text(length=None, html=False)

String representation of weeks_score.

Parameters
  • length (Optional[int]) – Maximum number of members to display. If not passed, will write down all members.

  • html (Optional[bool]) – If True, will embed HTML tags in the string. Use this to send the string with a Telegram bot using telegram.ParseMode.HTML.

Return type

str

property years_score: List[components.score.Score]

Gives a list of each members score of the current year sorted descending by components.Score.ratio .

Return type

List[Score]

years_score_text(length=None, html=False)

String representation of years_score.

Parameters
  • length (Optional[int]) – Maximum number of members to display. If not passed, will write down all members.

  • html (Optional[bool]) – If True, will embed HTML tags in the string. Use this to send the string with a Telegram bot using telegram.ParseMode.HTML.

Return type

str