def delete_poll(session, context, poll): """Permanently delete the poll.""" remove_poll_messages(session, context.bot, poll) session.delete(poll) session.commit() return i18n.t('callback.deleted', locale=poll.user.locale)
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)
def delete_all(session, context): """Delete all polls of the user.""" for poll in context.user.polls: remove_poll_messages(session, context.bot, poll) session.delete(poll) session.commit() open_user_settings(session, context) return i18n.t("deleted.polls", locale=context.user.locale)
def delete_closed(session, context): """Delete all closed polls of the user.""" for poll in context.user.polls: if poll.closed: remove_poll_messages(session, context.bot, poll) session.delete(poll) session.commit() open_user_settings(session, context) return i18n.t('deleted.closed_polls', locale=context.user.locale)
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 = [] for vote in user.votes: if vote.poll not in polls_for_update: polls_for_update.append(vote.poll) if not vote.poll.closed: session.delete(vote) else: vote.user = None session.commit() for poll in polls_for_update: update_poll_messages(session, context.bot, poll) session.commit() user.started = False user.banned = True user.deleted = True user.current_poll = None user.username = "******" user.name = "GDPR removed user" user.locale = "English" user.european_date_format = False user.notifications_enabled = False session.commit() context.query.message.chat.send_message( i18n.t("settings.user.deleted", locale=user.locale), )