mirror of
https://github.com/Cog-Creators/Red-DiscordBot.git
synced 2025-11-21 02:16:09 -05:00
Begin work on a data request API (#4045)
[Core] Data Deletion And Disclosure APIs - Adds a Data Deletion API - Deletion comes in a few forms based on who is requesting - Deletion must be handled by 3rd party - Adds a Data Collection Disclosure Command - Provides a dynamically generated statement from 3rd party extensions - Modifies the always available commands to be cog compatible - Also prevents them from being unloaded accidentally
This commit is contained in:
@@ -3,7 +3,7 @@ import logging
|
||||
import random
|
||||
from collections import defaultdict, deque, namedtuple
|
||||
from enum import Enum
|
||||
from typing import cast, Iterable, Union
|
||||
from typing import cast, Iterable, Union, Literal
|
||||
|
||||
import discord
|
||||
|
||||
@@ -11,6 +11,7 @@ from redbot.cogs.bank import is_owner_if_bank_global
|
||||
from redbot.cogs.mod.converters import RawUserIds
|
||||
from redbot.core import Config, bank, commands, errors, checks
|
||||
from redbot.core.i18n import Translator, cog_i18n
|
||||
from redbot.core.utils import AsyncIter
|
||||
from redbot.core.utils.chat_formatting import box, humanize_number
|
||||
from redbot.core.utils.menus import menu, DEFAULT_CONTROLS
|
||||
|
||||
@@ -136,7 +137,6 @@ class Economy(commands.Cog):
|
||||
def __init__(self, bot: Red):
|
||||
super().__init__()
|
||||
self.bot = bot
|
||||
self.file_path = "data/economy/settings.json"
|
||||
self.config = Config.get_conf(self, 1256844281)
|
||||
self.config.register_guild(**self.default_guild_settings)
|
||||
self.config.register_global(**self.default_global_settings)
|
||||
@@ -145,6 +145,23 @@ class Economy(commands.Cog):
|
||||
self.config.register_role(**self.default_role_settings)
|
||||
self.slot_register = defaultdict(dict)
|
||||
|
||||
async def red_delete_data_for_user(
|
||||
self,
|
||||
*,
|
||||
requester: Literal["discord_deleted_user", "owner", "user", "user_strict"],
|
||||
user_id: int,
|
||||
):
|
||||
if requester != "discord_deleted_user":
|
||||
return
|
||||
|
||||
await self.config.user_from_id(user_id).clear()
|
||||
|
||||
all_members = await self.config.all_members()
|
||||
|
||||
async for guild_id, guild_data in AsyncIter(all_members.items(), steps=100):
|
||||
if user_id in guild_data:
|
||||
await self.config.member_from_ids(guild_id, user_id).clear()
|
||||
|
||||
@guild_only_check()
|
||||
@commands.group(name="bank")
|
||||
async def _bank(self, ctx: commands.Context):
|
||||
|
||||
Reference in New Issue
Block a user