Beispiel #1
0
def list_closed_polls(bot, update, session, user):
    """Get a list of all active polls."""
    text = i18n.t('list.polls', locale=user.locale)
    polls = session.query(Poll) \
        .filter(Poll.user == user) \
        .filter(Poll.created.is_(True)) \
        .filter(Poll.closed.is_(True)) \
        .all()

    if len(polls) == 0:
        return i18n.t('list.no_closed_polls', locale=user.locale)

    keyboard = get_poll_list_keyboard(polls)
    update.message.chat.send_message(text, reply_markup=keyboard)
Beispiel #2
0
def get_poll_list(session, user, closed=False):
    """Get the a list of polls for the user."""
    polls = (session.query(Poll).filter(Poll.user == user).filter(
        Poll.created.is_(True)).filter(Poll.closed.is_(closed)).all())

    if len(polls) == 0 and closed:
        return i18n.t("list.no_closed_polls", locale=user.locale), None
    elif len(polls) == 0:
        return i18n.t("list.no_polls", locale=user.locale), None

    text = i18n.t("list.polls", locale=user.locale)
    keyboard = get_poll_list_keyboard(polls)

    return text, keyboard