components.Member

class components.Member(user_id, phone_number=None, first_name=None, last_name=None, nickname=None, gender=None, date_of_birth=None, instruments=None, address=None, latitude=None, longitude=None, photo_file_id=None, allow_contact_sharing=False, joined=None, functions=None)

Bases: object

A member of AkaBlas.

Note

Orchestra instance support subscription for all properties and attributes listed in SUBSCRIPTABLE.

user_id

The Telegram user_id.

Type

int

phone_number

Optional. Phone number.

Type

str

first_name

Optional. First name.

Type

str

last_name

Optional. Last name.

Type

str

nickname

Optional. Nickname.

Type

str

gender

Optional. Gender.

Type

str

date_of_birth

Optional. : Date of birth.

Type

datetime.date

joined

Optional. The year this member joined AkaBlas.

Type

int

photo_file_id

Optional. Telegram file ID of the user photo

Type

str

allow_contact_sharing

Whether sharing this members contact information with others is allowed.

Type

bool

user_score

A highscore associated with this member.

Type

components.UserScore

Parameters
  • user_id (Union[str, int]) – The Telegram user_id.

  • phone_number (Optional[str]) – Phone number.

  • first_name (Optional[str]) – First name.

  • last_name (Optional[str]) – Last name.

  • nickname (Optional[str]) – Nickname.

  • gender (Optional[str]) – Gender.

  • joined (Optional[int]) – The year this member joined AkaBlas as for digit number.

  • date_of_birth (Optional[date]) – Date of birth.

  • instruments (Union[List[Instrument], Instrument, None]) – Instrument(s) this member plays.

  • address (Optional[str]) – Address. Only address or` latitude and longitude may be passed.

  • latitude (Optional[float]) – Latitude of address. Only address or` latitude and longitude may be passed.

  • longitude (Optional[float]) – Longitude of address. Only address or` latitude and longitude may be passed.

  • photo_file_id (Optional[str]) – Telegram file ID of the user photo

  • functions (Union[List[str], str, None]) – Function(s) this member holds.

  • allow_contact_sharing (Optional[bool]) – Whether sharing this users contact information with others is allowed. Defaults to False.

ALLOWED_INSTRUMENTS: List[components.instruments.Instrument] = [Percussion, Querflöte, Klarinette, Oboe, Fagott, Sopransaxophon, Altsaxophon, Tenorsaxophon, Baritonsaxophon, Euphonium, Tenorhorn, Bariton, Posaune, Tuba, Trompete, Flügelhorn, Horn, Schlagzeug, Gitarre, Bass-Gitarre]

Instruments that members are allowed to play.

Type

List[components.Instrument]

SUBSCRIPTABLE = ['address', 'age', 'allow_contact_sharing', 'birthday', 'date_of_birth', 'first_name', 'full_name', 'functions', 'gender', 'instruments', 'joined', 'last_name', 'latitude', 'longitude', 'nickname', 'phone_number', 'photo_file_id']

Attributes supported by subscription.

Type

List[str]

property address: Optional[str]

Address of the member.

Return type

Optional[str]

property age: Optional[int]

The age of the member at evaluation time. None, if date_of_birth is not set.

Return type

Optional[int]

property birthday: Optional[str]

The birthday of the member int he format DD.MM.. None, if date_of_birth is not set.

Return type

Optional[str]

clear_address()

Deletes the address of this member.

Return type

None

compare_address_to(string)

Compares the members address to the given string. The comparison is case insensitive.

Parameters

string (str) – The string to compare to.

Return type

float

Returns

Similarity in percentage.

Raises

ValueError – If the member has no address.

compare_first_name_to(string)

Compares the members first name to the given string. The comparison is case insensitive.

Parameters

string (str) – The string to compare to.

Return type

float

Returns

Similarity in percentage.

Raises

ValueError – If the member has no first name.

compare_full_name_to(string)

Compares the members full name to the given string. The comparison is case insensitive.

Parameters

string (str) – The string to compare to.

Return type

float

Returns

Similarity in percentage.

Raises

ValueError – If the member has no full name.

compare_functions_to(string)

Compares the members functions to the given string. The comparison is case insensitive.

Parameters

string (str) – The string to compare to.

Return type

float

Returns

Similarity in percentage.

Raises

ValueError – If the member holds no functions.

compare_instruments_to(string)

Compares the members instruments to the given string. The comparison is case insensitive.

Parameters

string (str) – The string to compare to.

Return type

float

Returns

Similarity in percentage.

Raises

ValueError – If the member has no instruments.

compare_last_name_to(string)

Compares the members last name to the given string. The comparison is case insensitive.

Parameters

string (str) – The string to compare to.

Return type

float

Returns

Similarity in percentage.

Raises

ValueError – If the member has no last name.

compare_nickname_to(string)

Compares the members nickname to the given string. The comparison is case insensitive.

Parameters

string (str) – The string to compare to.

Return type

float

Returns

Similarity in percentage.

Raises

ValueError – If the member has no nickname.

copy()

Returns: A (deep) copy of this member.

Return type

ForwardRef

distance_of_address_to(coordinates)

Computes the distance between the members address and the given coordinates.

Parameters

coordinates (Tuple[float, float]) – A tuple of latitude and longitude to compare to.

Return type

float

Returns

The distance in kilometers.

Raises

ValueError – If the member has no address.

property full_name: Optional[str]

Full name of the member. May be None.

Return type

Optional[str]

property functions: List[str]

Function(s) this member holds. List may be empty

Return type

List[str]

property functions_str: Optional[str]

Stringified list of the function(s) the member holds. May be empty.

Return type

Optional[str]

classmethod guess_member(user)

Tries to guess a components.Member from the AkaDressen based on the Telegram users attributes. May return no or several hits.

Parameters

user (User) – A Telegram user.

Return type

Optional[List[ForwardRef]]

property instruments: List[components.instruments.Instrument]

Instrument(s) this member plays. List may be empty

Return type

List[Instrument]

property instruments_str: Optional[str]

Stringified list of the instrument(s) the member plays. May be empty.

Return type

Optional[str]

property latitude: Optional[float]

Latitude of the members address.

Return type

Optional[float]

property longitude: Optional[float]

Longitude of the members address.

Return type

Optional[float]

set_address(address=None, coordinates=None)

Tries to get the missing data from the Open Street Map API. Exactly one of the optional parameters must be passed.

Parameters
Return type

Optional[str]

Returns

The found address.

classmethod set_akadressen_credentials(url, url_active, username, password)

Set the credentials needed to retrieve the AkaDRessen

Parameters
  • url (str) – The URL of the AkaDressen.

  • url_active (str) – The URL of the AkaDressen containing only the active members.

  • username (str) – Username.

  • password (str) – Password.

Return type

None

vcard(bot, admin=False)

Gives a vCard of the member.

Parameters
  • bot (Bot) – A Telegram bot to retrieve the members photo (if set). Must be the same bot that retrieved the file ID.

  • admin (bool) – Whether this method is invoked with admin rights.

Return type

BytesIO

Returns

The vCard as bytes stream. Make sure to close it!

Raises

ValueError – If sharing contact information is not allowed and admin is False.

property vcard_filename: str

Gives a filename of the vcard generated by vcard.

Return type

str