Exemplo n.º 1
0
def orchestra(members, bot, chat_id, skip=None):
    if skip is None:
        skip = []
    orchestra_ = Orchestra()

    for i in range(1, members):
        gender = random.choice([Gender.MALE, Gender.FEMALE])
        phone_number_ = phone_number() if 'phone_number' not in skip else None
        first_name_ = first_name(gender) if 'first_name' not in skip else None
        last_name_ = last_name() if 'last_name' not in skip else None
        nickname_ = nickname() if 'nickname' not in skip else None
        date_of_birth_ = date_of_birth(
        ) if 'date_of_birth' not in skip else None
        instruments_ = instrument() if 'instruments' not in skip else None
        address_ = address() if 'address' not in skip else None
        photo_file_id_ = (PhotoFileID.photo_file_id(bot, chat_id)
                          if 'photo_file_id' not in skip else None)
        orchestra_.register_member(
            Member(
                user_id=i,
                phone_number=phone_number_,
                first_name=first_name_,
                last_name=last_name_,
                nickname=nickname_,
                gender=gender,
                date_of_birth=date_of_birth_,
                instruments=instruments_,
                address=address_,
                photo_file_id=photo_file_id_,
            ))
    return orchestra_
Exemplo n.º 2
0
def score_orchestra_anonymous(date):
    o = Orchestra()
    offset = dt.timedelta(weeks=100)
    m_1 = Member(1)
    m_1.user_score.add_to_score(8, 4, date)
    m_1.user_score.add_to_score(10, 10, date - offset)
    o.register_member(m_1)
    return o
Exemplo n.º 3
0
def rebuild_orchestra(update: Update, context: CallbackContext) -> None:
    """
    Builds a new orchestra by registering all members from the one in ``context.bot_data`` to a
    new instance of :class:`components.Orchestra`. Puts the new orchestra in ``bot_data``.
    Useful, if there have been changes to the attribute manager setup.

    Args:
        update: The update.
        context: The context as provided by the :class:`telegram.ext.Dispatcher`.
    """
    members = context.bot_data[ORCHESTRA_KEY].members.values()
    orchestra = Orchestra()

    for member in members:
        orchestra.register_member(member.copy())

    context.bot_data[ORCHESTRA_KEY] = orchestra
    update.message.reply_text('Orchester neu besetzt.')
Exemplo n.º 4
0
def score_orchestra(date):
    o = Orchestra()
    offset = dt.timedelta(weeks=100)
    m_1 = Member(1, first_name='One')
    m_1.user_score.add_to_score(8, 4, date)
    m_1.user_score.add_to_score(10, 10, date - offset)
    m_2 = Member(2, first_name='Two')
    m_2.user_score.add_to_score(4, 2, date)
    m_2.user_score.add_to_score(10, 10, date - offset)
    m_3 = Member(3, first_name='Three')
    m_3.user_score.add_to_score(3, 1, date)
    m_3.user_score.add_to_score(10, 10, date - offset)
    m_4 = Member(4, first_name='Four')
    m_4.user_score.add_to_score(4, 1, date)
    m_4.user_score.add_to_score(10, 10, date - offset)
    for m in [m_1, m_2, m_3, m_4]:
        o.register_member(m)
    return o