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
.- date_of_birth¶
Optional. : Date of birth.
- Type
- allow_contact_sharing¶
Whether sharing this members contact information with others is allowed.
- Type
- user_score¶
A highscore associated with this member.
- Type
- Parameters
joined (
Optional
[int
]) – The year this member joined AkaBlas as for digit number.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 photofunctions (
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 toFalse
.
- 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 age: Optional[int]¶
The age of the member at evaluation time.
None
, ifdate_of_birth
is not set.
- property birthday: Optional[str]¶
The birthday of the member int he format
DD.MM.
.None
, ifdate_of_birth
is not set.
- 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
- 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
- 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
- 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
- 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
- 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
- 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
- Returns
Similarity in percentage.
- Raises
ValueError – If the member has no nickname.
- copy()¶
Returns: A (deep) copy of this member.
- Return type
- 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
- Returns
The distance in kilometers.
- Raises
ValueError – If the member has no address.
- property functions_str: Optional[str]¶
Stringified list of the function(s) the member holds. May be empty.
- 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
- property instruments: List[components.instruments.Instrument]¶
Instrument(s) this member plays. List may be empty
- Return type
- property instruments_str: Optional[str]¶
Stringified list of the instrument(s) the member plays. May be empty.
- 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.
- classmethod set_akadressen_credentials(url, url_active, username, password)¶
Set the credentials needed to retrieve the AkaDRessen
- 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
isFalse
.