예제 #1
0
def delete_user(session, context):
    """Delete everything of a user and ban them forever."""
    user = context.user

    for poll in user.polls:
        remove_poll_messages(session, context.bot, poll)
        session.delete(poll)
        session.commit()

    polls_for_update = []
    # Delete all votes, but only update non-closed polls
    for vote in user.votes:
        if vote.poll not in polls_for_update and not vote.poll.closed:
            polls_for_update.append(vote.poll)
        session.delete(vote)
    session.commit()

    for poll in polls_for_update:
        update_poll_messages(session, context.bot, poll)
    session.commit()

    user.delete()
    session.commit()

    context.query.message.chat.send_message(
        i18n.t("settings.user.deleted", locale=user.locale),
    )
예제 #2
0
def delete_poll_with_messages(session, context, poll):
    """Permanently delete the poll."""
    remove_poll_messages(session, context.bot, poll, remove_all=True)
    session.commit()
    session.delete(poll)
    session.commit()

    return i18n.t("callback.deleted", locale=context.user.locale)
예제 #3
0
def delete_all(session, context):
    """Delete all polls of the user."""
    for poll in context.user.polls:
        remove_poll_messages(session, context.bot, poll, False)
        session.delete(poll)
        session.commit()

    open_user_settings(session, context)
    return i18n.t("deleted.polls", locale=context.user.locale)