diff --git a/GearBot/Bot/TheRealGearBot.py b/GearBot/Bot/TheRealGearBot.py index 59e21249..de03a690 100644 --- a/GearBot/Bot/TheRealGearBot.py +++ b/GearBot/Bot/TheRealGearBot.py @@ -135,9 +135,9 @@ async def on_message(bot, message:Message): await ctx.author.send("Hey, you tried triggering a command in a channel I'm not allowed to send messages in. Please grant me permissions to reply and try again.") except Forbidden: pass # closed DMs - elif ctx.author.id in Configuration.get_persistent_var("user_blacklist", []): + elif ctx.author.id in Configuration.get_persistent_var("user_blocklist", []): try: - await MessageUtils.send_to(ctx, "BAD_USER", "You have been globally blacklisted from using this bot due to abuse", translate=False) + await MessageUtils.send_to(ctx, "BAD_USER", "You have been globally blocked from using this bot due to abuse", translate=False) except Forbidden: pass # closed DMs else: @@ -145,18 +145,18 @@ async def on_message(bot, message:Message): async def on_guild_join(guild): - blocked = Configuration.get_persistent_var("server_blacklist", []) + blocked = Configuration.get_persistent_var("server_blocklist", []) if guild.id in blocked: - GearbotLogging.info(f"Someone tried to add me to blacklisted guild {guild.name} ({guild.id})") + GearbotLogging.info(f"Someone tried to add me to blocked guild {guild.name} ({guild.id})") try: - await guild.owner.send("Someone tried adding me to {guild.name} (``{guild.id}``) but the server has been blacklisted") + await guild.owner.send("Someone tried adding me to {guild.name} (``{guild.id}``) but the server has been blocked") except Exception: pass await guild.leave() - elif guild.owner.id in Configuration.get_persistent_var("user_blacklist", []): - GearbotLogging.info(f"Someone tried to add me to {guild.name} ({guild.id}) but the owner ({guild.owner} ({guild.owner.id})) is blacklisted") + elif guild.owner.id in Configuration.get_persistent_var("user_blocklist", []): + GearbotLogging.info(f"Someone tried to add me to {guild.name} ({guild.id}) but the owner ({guild.owner} ({guild.owner.id})) is blocked") try: - await guild.owner.send(f"Someone tried adding me to {guild.name} (``{guild.id}``) but you have been blacklisted due to bot abuse, so i left") + await guild.owner.send(f"Someone tried adding me to {guild.name} (``{guild.id}``) but you have been blocked due to bot abuse, so i left") except Exception: pass await guild.leave() @@ -167,19 +167,19 @@ async def on_guild_join(guild): await GearbotLogging.bot_log(f"{Emoji.get_chat_emoji('JOIN')} A new guild came up: {name} ({guild.id}).", embed=server_info.server_info_embed(guild)) async def on_guild_remove(guild): - blocked = Configuration.get_persistent_var("server_blacklist", []) - blocked_users = Configuration.get_persistent_var("user_blacklist", []) + blocked = Configuration.get_persistent_var("server_blocklist", []) + blocked_users = Configuration.get_persistent_var("user_blocklist", []) if guild.id not in blocked and guild.owner.id not in blocked_users: GearbotLogging.info(f"I was removed from a guild: {guild.name} ({guild.id}).") await GearbotLogging.bot_log(f"{Emoji.get_chat_emoji('LEAVE')} I was removed from a guild: {guild.name} ({guild.id}).", embed=server_info.server_info_embed(guild)) async def on_guild_update(before, after): - if after.owner is not None and after.owner.id in Configuration.get_persistent_var("user_blacklist", []): + if after.owner is not None and after.owner.id in Configuration.get_persistent_var("user_blocklist", []): GearbotLogging.info( - f"Someone transferred {after.name} ({after.id}) to ({after.owner} ({after.owner.id})) but they are blacklisted") + f"Someone transferred {after.name} ({after.id}) to ({after.owner} ({after.owner.id})) but they are blocked") try: - await after.owner.send(f"Someone transferred {after.name} (``{after.id}``) to you, but you have been blacklisted due to bot abuse, so i left") + await after.owner.send(f"Someone transferred {after.name} (``{after.id}``) to you, but you have been blocked due to bot abuse, so i left") except Exception: pass await after.leave() diff --git a/GearBot/Cogs/Admin.py b/GearBot/Cogs/Admin.py index 18e7550a..d16413e1 100644 --- a/GearBot/Cogs/Admin.py +++ b/GearBot/Cogs/Admin.py @@ -7,7 +7,7 @@ from discord.ext import commands from Cogs.BaseCog import BaseCog -from Util import GearbotLogging, Utils, Configuration, Pages, Emoji, MessageUtils, Update +from Util import GearbotLogging, Utils, Configuration, Pages, Emoji, MessageUtils, Update, DocUtils from Util.Converters import UserID, Guild, DiscordUser @@ -23,6 +23,10 @@ def cog_unload(self): async def cog_check(self, ctx): return await ctx.bot.is_owner(ctx.author) or ctx.author.id in Configuration.get_master_var("BOT_ADMINS", []) + @commands.command() + async def commandlist(self, ctx): + await DocUtils.generate_command_list2(self.bot, ctx.message) + @commands.command(hidden=True) async def restart(self, ctx): @@ -141,25 +145,25 @@ async def update(self, ctx): await ctx.invoke(self.bot.get_command("hotreload")) @commands.command() - async def blacklist_server(self, ctx, guild: Guild): - blocked = Configuration.get_persistent_var("server_blacklist", []) + async def block_server(self, ctx, guild: Guild): + blocked = Configuration.get_persistent_var("server_blocklist", []) blocked.append(guild.id) - Configuration.set_persistent_var("server_blacklist", blocked) + Configuration.set_persistent_var("server_blocklist", blocked) await guild.leave() - await MessageUtils.send_to(ctx, "YES", f"{Utils.escape_markdown(guild.name)} (``{guild.id}``) has been added to the blacklist", translate=False) + await MessageUtils.send_to(ctx, "YES", f"{Utils.escape_markdown(guild.name)} (``{guild.id}``) has been added to the blocked servers list", translate=False) await GearbotLogging.bot_log( - f"{Utils.escape_markdown(guild.name)} (``{guild.id}``) has been added to the blacklist by {Utils.clean_user(ctx.author)}") + f"{Utils.escape_markdown(guild.name)} (``{guild.id}``) has been added to the blocked server list by {Utils.clean_user(ctx.author)}") @commands.command() - async def blacklist_user(self, ctx, user:DiscordUser): + async def block_user(self, ctx, user:DiscordUser): for guild in self.bot.guilds: if guild.owner is not None and guild.owner.id == user.id: await guild.leave() - blocked = Configuration.get_persistent_var("user_blacklist", []) + blocked = Configuration.get_persistent_var("user_blocklist", []) blocked.append(user.id) - Configuration.set_persistent_var("user_blacklist", blocked) - await MessageUtils.send_to(ctx, "YES", f"{Utils.clean_user(user)} (``{user.id}``) has been added to the blacklist", translate=False) - await GearbotLogging.bot_log(f"{Utils.clean_user(user)} (``{user.id}``) has been added to the blacklist by {Utils.clean_user(ctx.author)}") + Configuration.set_persistent_var("user_blocklist", blocked) + await MessageUtils.send_to(ctx, "YES", f"{Utils.clean_user(user)} (``{user.id}``) has been added to the blocked users list", translate=False) + await GearbotLogging.bot_log(f"{Utils.clean_user(user)} (``{user.id}``) has been added to the blocked users list by {Utils.clean_user(ctx.author)}") @commands.command() async def pendingchanges(self, ctx): diff --git a/GearBot/Cogs/Censor.py b/GearBot/Cogs/Censor.py index 9ecaf8f5..9f57c38c 100644 --- a/GearBot/Cogs/Censor.py +++ b/GearBot/Cogs/Censor.py @@ -47,11 +47,11 @@ async def check_message(self, message: discord.Message): ctx = await self.bot.get_context(message) if Permissioncheckers.get_user_lvl(ctx.guild, ctx.author) >= 2: return - blacklist = Configuration.get_var(message.guild.id, "CENSORING", "TOKEN_BLACKLIST") - word_blacklist = Configuration.get_var(message.guild.id, "CENSORING", "WORD_BLACKLIST") - guilds = Configuration.get_var(message.guild.id, "CENSORING", "INVITE_WHITELIST") + censorlist = Configuration.get_var(message.guild.id, "CENSORING", "TOKEN_CENSORLIST") + word_censorlist = Configuration.get_var(message.guild.id, "CENSORING", "WORD_CENSORLIST") + guilds = Configuration.get_var(message.guild.id, "CENSORING", "ALLOWED_INVITE_LIST") domain_list = Configuration.get_var(message.guild.id, "CENSORING", "DOMAIN_LIST") - domain_whitelist = Configuration.get_var(message.guild.id, "CENSORING", "DOMAIN_WHITELIST") + domains_allowed = Configuration.get_var(message.guild.id, "CENSORING", "DOMAIN_LIST_ALLOWED") content = message.content.replace('\\', '') decoded_content = parse.unquote(content) censored = False @@ -73,15 +73,15 @@ async def check_message(self, message: discord.Message): if not censored: content = content.lower() - for bad in (w.lower() for w in blacklist): + for bad in (w.lower() for w in censorlist): if bad in content: await self.censor_message(message, bad) censored = True break - if not censored and len(word_blacklist) > 0: + if not censored and len(word_censorlist) > 0: if ctx.guild.id not in self.regexes: - regex = re.compile(r"\b(" + '|'.join(re.escape(word) for word in word_blacklist) + r")\b", re.IGNORECASE) + regex = re.compile(r"\b(" + '|'.join(re.escape(word) for word in word_censorlist) + r")\b", re.IGNORECASE) self.regexes[ctx.guild.id] = regex else: regex = self.regexes[ctx.guild.id] @@ -95,8 +95,8 @@ async def check_message(self, message: discord.Message): for link in link_list: url = urlparse(link) domain = url.hostname - if (domain in domain_list) is not domain_whitelist: - await self.censor_message(message, url.hostname, "_domain_whitelist" if domain_whitelist else "_domain_blacklist") + if (domain in domain_list) is not domains_allowed: + await self.censor_message(message, url.hostname, "_domain_blocked") print(domain) diff --git a/GearBot/Cogs/Moderation.py b/GearBot/Cogs/Moderation.py index f11f4c05..6134aedc 100644 --- a/GearBot/Cogs/Moderation.py +++ b/GearBot/Cogs/Moderation.py @@ -170,8 +170,8 @@ async def role_handler(self, ctx, user, role, action): if Actions.can_act(f"role_{action}", ctx, user): role_list = Configuration.get_var(ctx.guild.id, "ROLES", "ROLE_LIST") - mode = Configuration.get_var(ctx.guild.id, "ROLES", "ROLE_WHITELIST") - mode_name = "whitelist" if mode else "blacklist" + mode = Configuration.get_var(ctx.guild.id, "ROLES", "ROLE_LIST_MODE") + mode_name = "allow" if mode else "block" if (drole.id in role_list) is mode: if drole < ctx.me.top_role: if drole < ctx.author.top_role or user == ctx.guild.owner: diff --git a/GearBot/Cogs/ServerAdmin.py b/GearBot/Cogs/ServerAdmin.py index 5aa1a8f6..917d6b50 100644 --- a/GearBot/Cogs/ServerAdmin.py +++ b/GearBot/Cogs/ServerAdmin.py @@ -94,8 +94,8 @@ def __init__(self, bot): super().__init__(bot) bot.to_cache = [] - Pages.register("blacklist", self._blacklist_init, self._blacklist_update) - Pages.register("word_blacklist", self._word_blacklist_init, self._word_blacklist_update) + Pages.register("censorlist", self._censorlist_init, self._censorklist_update) + Pages.register("word_censorlist", self._word_censorlist_init, self._word_censor_list_update) @@ -217,18 +217,18 @@ async def remove(self, ctx:commands.Context, *, role:discord.Role): self.bot.dispatch("self_roles_update", ctx.guild.id) @configure.group() - async def invite_whitelist(self, ctx: commands.Context): - """configure_invite_whitelist_help""" + async def allowed_invites(self, ctx: commands.Context): + """configure_allowed_invite_list_help""" if ctx.invoked_subcommand is None: - await list_list(ctx, "invite", list_name="whitelist", wrapper="{item}", config_section="CENSORING") + await list_list(ctx, "allowed", list_name="invite_list", wrapper="{item}", config_section="CENSORING") - @invite_whitelist.command(name="add") - async def add_to_whitelist(self, ctx: commands.Context, server:int): - await add_item(ctx, ServerHolder(server), "invite", list_name="whitelist", config_section="CENSORING") + @allowed_invites.command(name="add") + async def add_to_allowed_list(self, ctx: commands.Context, server:int): + await add_item(ctx, ServerHolder(server), "allowed", list_name="invite_list", config_section="CENSORING") - @invite_whitelist.command(name="remove") - async def remove_from_whitelist(self, ctx: commands.Context, server:int): - await remove_item(ctx, ServerHolder(server), "invite", list_name="whitelist", config_section="CENSORING") + @allowed_invites.command(name="remove") + async def remove_from_allowed_list(self, ctx: commands.Context, server:int): + await remove_item(ctx, ServerHolder(server), "allowed", list_name="invite_list", config_section="CENSORING") @configure.command(name="censortrustedbypass") async def enable_trusted_bypass(self, ctx: commands.Context, enabled_status: bool): @@ -857,81 +857,81 @@ async def log_embeds(self, ctx, value: bool): await ctx.send( f"{Emoji.get_chat_emoji('YES')} {Translator.translate('embed_log_' + ('enabled' if value else 'disabled'), ctx.guild.id)}") - @configure.group() - async def blacklist(self, ctx): + @configure.group(aliases=["censorlist"]) + async def censor_list(self, ctx): if ctx.invoked_subcommand is None: - await Pages.create_new(self.bot, "blacklist", ctx) + await Pages.create_new(self.bot, "censor_list", ctx) @staticmethod - async def _blacklist_init(ctx): - pages = Pages.paginate("\n".join(Configuration.get_var(ctx.guild.id, "CENSORING", "TOKEN_BLACKLIST"))) - return f"**{Translator.translate(f'blacklist_list', ctx, server=ctx.guild.name, page_num=1, pages=len(pages))}**```\n{pages[0]}```", None, len(pages) > 1 + async def _censorlist_init(ctx): + pages = Pages.paginate("\n".join(Configuration.get_var(ctx.guild.id, "CENSORING", "TOKEN_CENSORLIST"))) + return f"**{Translator.translate(f'censor_list', ctx, server=ctx.guild.name, page_num=1, pages=len(pages))}**```\n{pages[0]}```", None, len(pages) > 1 @staticmethod - async def _blacklist_update(ctx, message, page_num, action, data): - pages = Pages.paginate("\n".join(Configuration.get_var(message.channel.guild.id, "CENSORING", "TOKEN_BLACKLIST"))) + async def _censorklist_update(ctx, message, page_num, action, data): + pages = Pages.paginate("\n".join(Configuration.get_var(message.channel.guild.id, "CENSORING", "TOKEN_CENSORLIST"))) page, page_num = Pages.basic_pages(pages, page_num, action) data["page"] = page_num - return f"**{Translator.translate(f'blacklist_list', message.channel.guild.id, server=message.channel.guild.name, page_num=page_num + 1, pages=len(pages))}**```\n{page}```", None, data + return f"**{Translator.translate(f'censor_list', message.channel.guild.id, server=message.channel.guild.name, page_num=page_num + 1, pages=len(pages))}**```\n{page}```", None, data - @blacklist.command("add") - async def blacklist_add(self, ctx, *, word: str): - blacklist = Configuration.get_var(ctx.guild.id, "CENSORING", "TOKEN_BLACKLIST") - if word.lower() in blacklist: - await MessageUtils.send_to(ctx, "NO", "already_blacklisted", word=word) + @censor_list.command("add") + async def censor_list_add(self, ctx, *, word: str): + censor_list = Configuration.get_var(ctx.guild.id, "CENSORING", "TOKEN_CENSORLIST") + if word.lower() in censor_list: + await MessageUtils.send_to(ctx, "NO", "already_censored", word=word) else: - blacklist.append(word.lower()) + censor_list.append(word.lower()) await MessageUtils.send_to(ctx, "YES", "entry_added", entry=word) Configuration.save(ctx.guild.id) - @blacklist.command("remove") - async def blacklist_remove(self, ctx, *, word: str): - blacklist = Configuration.get_var(ctx.guild.id, "CENSORING", "TOKEN_BLACKLIST") - if word not in blacklist: - await MessageUtils.send_to(ctx, "NO", "not_blacklisted", word=word) + @censor_list.command("remove") + async def censor_list_remove(self, ctx, *, word: str): + censor_list = Configuration.get_var(ctx.guild.id, "CENSORING", "TOKEN_CENSORLIST") + if word not in censor_list: + await MessageUtils.send_to(ctx, "NO", "not_censored", word=word) else: - blacklist.remove(word) + censor_list.remove(word) await MessageUtils.send_to(ctx, "YES", "entry_removed", entry=word) Configuration.save(ctx.guild.id) @configure.group() - async def word_blacklist(self, ctx): + async def word_censor_list(self, ctx): if ctx.invoked_subcommand is None: - await Pages.create_new(self.bot, "word_blacklist", ctx) + await Pages.create_new(self.bot, "word_censor_list", ctx) @staticmethod - async def _word_blacklist_init(ctx): - pages = Pages.paginate("\n".join(Configuration.get_var(ctx.guild.id, "CENSORING", "WORD_BLACKLIST"))) - return f"**{Translator.translate(f'blacklist_list', ctx, server=ctx.guild.name, page_num=1, pages=len(pages))}**```\n{pages[0]}```", None, len( + async def _word_censorlist_init(ctx): + pages = Pages.paginate("\n".join(Configuration.get_var(ctx.guild.id, "CENSORING", "WORD_CENSORLIST"))) + return f"**{Translator.translate(f'censor_list', ctx, server=ctx.guild.name, page_num=1, pages=len(pages))}**```\n{pages[0]}```", None, len( pages) > 1 @staticmethod - async def _word_blacklist_update(ctx, message, page_num, action, data): + async def _word_censor_list_update(ctx, message, page_num, action, data): pages = Pages.paginate( - "\n".join(Configuration.get_var(message.channel.guild.id, "CENSORING", "WORD_BLACKLIST"))) + "\n".join(Configuration.get_var(message.channel.guild.id, "CENSORING", "WORD_CENSORLIST"))) page, page_num = Pages.basic_pages(pages, page_num, action) data["page"] = page_num - return f"**{Translator.translate(f'blacklist_list', message.channel.guild.id, server=message.channel.guild.name, page_num=page_num + 1, pages=len(pages))}**```\n{page}```", None, data + return f"**{Translator.translate(f'censor_list', message.channel.guild.id, server=message.channel.guild.name, page_num=page_num + 1, pages=len(pages))}**```\n{page}```", None, data - @word_blacklist.command("add") - async def word_blacklist_add(self, ctx, *, word: str): - blacklist = Configuration.get_var(ctx.guild.id, "CENSORING", "WORD_BLACKLIST") - if word.lower() in blacklist: - await MessageUtils.send_to(ctx, "NO", "already_blacklisted", word=word) + @word_censor_list.command("add") + async def word_censor_list_add(self, ctx, *, word: str): + censor_list = Configuration.get_var(ctx.guild.id, "CENSORING", "WORD_CENSORLIST") + if word.lower() in censor_list: + await MessageUtils.send_to(ctx, "NO", "already_censored", word=word) else: - blacklist.append(word.lower()) + censor_list.append(word.lower()) await MessageUtils.send_to(ctx, "YES", "entry_added", entry=word) Configuration.save(ctx.guild.id) if ctx.guild.id in self.bot.get_cog("Censor").regexes: del self.bot.get_cog("Censor").regexes[ctx.guild.id] - @word_blacklist.command("remove") - async def word_blacklist_remove(self, ctx, *, word: str): - blacklist = Configuration.get_var(ctx.guild.id, "CENSORING", "WORD_BLACKLIST") - if word not in blacklist: - await MessageUtils.send_to(ctx, "NO", "not_blacklisted", word=word) + @word_censor_list.command("remove") + async def word_censor_list_remove(self, ctx, *, word: str): + censor_list = Configuration.get_var(ctx.guild.id, "CENSORING", "WORD_CENSORLIST") + if word not in censor_list: + await MessageUtils.send_to(ctx, "NO", "not_censored", word=word) else: - blacklist.remove(word) + censor_list.remove(word) await MessageUtils.send_to(ctx, "YES", "entry_removed", entry=word) Configuration.save(ctx.guild.id) if ctx.guild.id in self.bot.get_cog("Censor").regexes: @@ -945,23 +945,23 @@ async def role_list(self, ctx): """configure_role_list_help""" if ctx.invoked_subcommand is None: items = Configuration.get_var(ctx.guild.id, "ROLES", f"ROLE_LIST") - mode = "whitelist" if Configuration.get_var(ctx.guild.id, "ROLES", "ROLE_WHITELIST") else "blacklist" + mode = "allow" if Configuration.get_var(ctx.guild.id, "ROLES", "ROLE_LIST_MODE") else "block" if len(items) == 0: desc = Translator.translate(f"no_role_{mode}", ctx) else: desc = "\n".join(f"<@&{item}>" for item in items) - embed = discord.Embed(title=Translator.translate(f"current_role_{mode}", ctx), description=desc) + embed = discord.Embed(title=Translator.translate(f"current_role_{mode}_list", ctx), description=desc) await ctx.send(embed=embed) @role_list.command("add") async def role_list_add(self, ctx, *, role:discord.Role): """configure_role_list_add""" roles = Configuration.get_var(ctx.guild.id, "ROLES", "ROLE_LIST") - mode = "whitelist" if Configuration.get_var(ctx.guild.id, "ROLES", "ROLE_WHITELIST") else "blacklist" + mode = "allow" if Configuration.get_var(ctx.guild.id, "ROLES", "ROLE_LIST_MODE") else "block" if role == ctx.guild.default_role: await MessageUtils.send_to(ctx, "NO", "default_role_forbidden") elif role.id in roles: - await MessageUtils.send_to(ctx, "NO", f"role_list_add_fail_{mode}", role=Utils.escape_markdown(role.name)) + await MessageUtils.send_to(ctx, "NO", f"role_list_add_fail", role=Utils.escape_markdown(role.name)) else: roles.append(role.id) Configuration.save(ctx.guild.id) @@ -972,7 +972,7 @@ async def role_list_add(self, ctx, *, role:discord.Role): async def role_list_remove(self, ctx, *, role: discord.Role): """configure_role_list_remove""" roles = Configuration.get_var(ctx.guild.id, "ROLES", "ROLE_LIST") - mode = "whitelist" if Configuration.get_var(ctx.guild.id, "ROLES", "ROLE_WHITELIST") else "blacklist" + mode = "allow" if Configuration.get_var(ctx.guild.id, "ROLES", "ROLE_LIST_MODE") else "block" if role.id not in roles: await MessageUtils.send_to(ctx, "NO", f"role_list_rmv_fail_{mode}", role=Utils.escape_markdown(role.name)) else: @@ -983,8 +983,8 @@ async def role_list_remove(self, ctx, *, role: discord.Role): @role_list.command("mode") async def role_list_mode(self, ctx, mode:ListMode): """configure_role_list_mode""" - Configuration.set_var(ctx.guild.id, "ROLES", "ROLE_WHITELIST", mode) - mode = "whitelist" if mode else "blacklist" + Configuration.set_var(ctx.guild.id, "ROLES", "ROLE_LIST_MODE", mode) + mode = "allowed" if mode else "blocked" await MessageUtils.send_to(ctx, "YES", f"role_list_mode_{mode}") @@ -996,12 +996,12 @@ async def domain_list(self, ctx): """configure_domain_list_help""" if ctx.invoked_subcommand is None: items = Configuration.get_var(ctx.guild.id, "CENSORING", "DOMAIN_LIST") - mode = "whitelist" if Configuration.get_var(ctx.guild.id, "CENSORING", "DOMAIN_WHITELIST") else "blacklist" + mode = "allowed" if Configuration.get_var(ctx.guild.id, "CENSORING", "DOMAIN_LIST_ALLOWED") else "blocked" if len(items) == 0: desc = Translator.translate(f"empty_domain_list", ctx) else: desc = "\n".join(f"{item}" for item in items) - embed = discord.Embed(title=Translator.translate(f"current_domain_{mode}", ctx), description=desc) + embed = discord.Embed(title=Translator.translate(f"current_domain_list_{mode}", ctx), description=desc) await ctx.send(embed=embed) @domain_list.command("add") @@ -1009,7 +1009,7 @@ async def domain_list_add(self, ctx, *, domain): """configure_domain_list_add""" domain = domain.lower() domains = Configuration.get_var(ctx.guild.id, "CENSORING", "DOMAIN_LIST") - mode = "whitelist" if Configuration.get_var(ctx.guild.id, "CENSORING", "DOMAIN_WHITELIST") else "blacklist" + mode = "allow" if Configuration.get_var(ctx.guild.id, "CENSORING", "DOMAIN_LIST_ALLOWED") else "block" if domain in domains: await MessageUtils.send_to(ctx, "NO", f"domain_list_add_fail_{mode}", domain=domain) else: @@ -1022,7 +1022,7 @@ async def domain_list_add(self, ctx, *, domain): async def domain_list_remove(self, ctx, *, domain): """configure_domain_list_remove""" domains = Configuration.get_var(ctx.guild.id, "CENSORING", "DOMAIN_LIST") - mode = "whitelist" if Configuration.get_var(ctx.guild.id, "CENSORING", "DOMAIN_WHITELIST") else "blacklist" + mode = "allow" if Configuration.get_var(ctx.guild.id, "CENSORING", "DOMAIN_LIST_ALLOWED") else "block" if domain not in domains: await MessageUtils.send_to(ctx, "NO", f"domain_list_rmv_fail_{mode}", domain=domain) else: @@ -1033,8 +1033,8 @@ async def domain_list_remove(self, ctx, *, domain): @domain_list.command("mode") async def domain_list_mode(self, ctx, mode:ListMode): """configure_domain_list_mode""" - Configuration.set_var(ctx.guild.id, "CENSORING", "DOMAIN_WHITELIST", mode) - mode = "whitelist" if mode else "blacklist" + Configuration.set_var(ctx.guild.id, "CENSORING", "DOMAIN_LIST_ALLOWED", mode) + mode = "allow" if mode else "block" await MessageUtils.send_to(ctx, "YES", f"domain_list_mode_{mode}") @configure.command() diff --git a/GearBot/Util/Configuration.py b/GearBot/Util/Configuration.py index 32c381c5..4b971e69 100644 --- a/GearBot/Util/Configuration.py +++ b/GearBot/Util/Configuration.py @@ -307,6 +307,19 @@ def v23(config): config["CENSORING"]["DOMAIN_WHITELIST"] = False config["CENSORING"]["DOMAIN_LIST"] = [] +def v24(config): + config["CENSORING"]["WORD_CENSORLIST"] = config["CENSORING"]["WORD_BLACKLIST"] + del config["CENSORING"]["WORD_BLACKLIST"] + config["CENSORING"]["TOKEN_CENSORLIST"] = config["CENSORING"]["TOKEN_BLACKLIST"] + del config["CENSORING"]["TOKEN_BLACKLIST"] + config["CENSORING"]["ALLOWED_INVITE_LIST"] = config["CENSORING"]["INVITE_WHITELIST"] + del config["CENSORING"]["INVITE_WHITELIST"] + config["CENSORING"]["DOMAIN_LIST_ALLOWED"] = config["CENSORING"]["DOMAIN_WHITELIST"] + del config["CENSORING"]["DOMAIN_WHITELIST"] + config["CENSORING"]["ROLE_LIST_MODE"] = config["ROLES"]["ROLE_WHITELIST"] + del config["ROLES"]["ROLE_WHITELIST"] + + def add_logging(config, *args): for cid, info in config["LOG_CHANNELS"].items(): if "FUTURE_LOGS" in info: @@ -327,9 +340,8 @@ def move_keys(config, section, *keys): config[section][key] = config[key] del config[key] - # migrators for the configs, do NOT increase the version here, this is done by the migration loop -MIGRATORS = [initial_migration, v2, v3, v4, v5, v6, v7, v8, v9, v10, v11, v12, v13, v14, v15, v16, v17, v18, v19, v20, v21, v22, v23] +MIGRATORS = [initial_migration, v2, v3, v4, v5, v6, v7, v8, v9, v10, v11, v12, v13, v14, v15, v16, v17, v18, v19, v20, v21, v22, v23, v24] BOT = None diff --git a/GearBot/Util/Converters.py b/GearBot/Util/Converters.py index ce8cb3cf..0cd192ef 100644 --- a/GearBot/Util/Converters.py +++ b/GearBot/Util/Converters.py @@ -247,9 +247,9 @@ def __init__(self, ) -> None: class ListMode(Converter): async def convert(self, ctx, argument): argument = argument.lower() - if argument == "whitelist": + if argument == "allow": return True - elif argument == "blacklist": + elif argument == "block" or argument == "censor": return False else: raise TranslatedBadArgument("invalid_mode", ctx) diff --git a/GearBot/Util/DocUtils.py b/GearBot/Util/DocUtils.py index de44aef1..ff8bd7c1 100644 --- a/GearBot/Util/DocUtils.py +++ b/GearBot/Util/DocUtils.py @@ -1,7 +1,7 @@ import os import re -from Util import Configuration, Pages, GearbotLogging, Permissioncheckers, Translator +from Util import Configuration, Pages, GearbotLogging, Permissioncheckers, Translator, Utils image_pattern = re.compile("(?:!\[)([A-z ]+)(?:\]\()(?:\.*/*)(.*)(?:\))(.*)") @@ -49,3 +49,49 @@ def gen_command_listing(bot, cog, command, code): GearbotLogging.error(command.qualified_name) raise ex return listing + + + +async def generate_command_list2(bot, message): + ctx = await bot.get_context(message) + ctx.prefix = "!" + bot.help_command.context = ctx + # for code in Translator.LANGS.keys(): + out = dict() + handled = set() + for cog in sorted(bot.cogs): + cog_commands = dict() + cogo = bot.get_cog(cog) + if cogo.permissions is not None: + for command in sorted([c for c in cogo.walk_commands()], key= lambda c:c.qualified_name): + if command.qualified_name not in handled: + location = cog_commands + for c in command.full_parent_name.split(' '): + if c == '': + break + location = location[c]["subcommands"] + location[command.name] = gen_command_listing2(bot, cogo, command) + handled.add(command.qualified_name) + if len(cog_commands) > 0: + out[cog] = cog_commands + Utils.save_to_disk("temp", out) + +def gen_command_listing2(bot, cog, command): + command_listing = dict() + try: + perm_lvl = Permissioncheckers.get_perm_dict(command.qualified_name.split(' '), cog.permissions)['required'] + command_listing["commandlevel"] = perm_lvl + command_listing["description"] = command.short_doc + command_listing["aliases"] = command.aliases + example = bot.help_command.get_command_signature(command).strip() + parts = str(example).split(' ') + parts[0] = ''.join(parts[0][1:]) + for i in range(0, len(parts)-1): + if "[" == parts[i][0]: + parts[i] = ''.join(parts[i].split('|')[0][1:]) + command_listing["example"] = '!' + ' '.join(parts) + command_listing["subcommands"] = {} + return command_listing + except Exception as ex: + GearbotLogging.error(command.qualified_name) + raise ex diff --git a/GearBot/Util/GearbotLogging.py b/GearBot/Util/GearbotLogging.py index e67d60a6..4783dcbd 100644 --- a/GearBot/Util/GearbotLogging.py +++ b/GearBot/Util/GearbotLogging.py @@ -42,8 +42,7 @@ "censored_invite": "WARNING", "censored_message": "WARNING", "censored_message_word": "WARNING", - "censored_message_domain_whitelist": "WARNING", - "censored_message_domain_blacklist": "WARNING", + "censored_message_domain_blocked": "WARNING", } }, "CHANNEL_CHANGES": { diff --git a/config/template.json b/config/template.json index 84db292d..a2c2c39c 100644 --- a/config/template.json +++ b/config/template.json @@ -1,5 +1,5 @@ { - "VERSION": 23, + "VERSION": 24, "GENERAL": { "LANG": "en_US", "PERM_DENIED_MESSAGE": true, @@ -11,7 +11,7 @@ "ROLES": { "SELF_ROLES": [], "ROLE_LIST": [], - "ROLE_WHITELIST": true, + "ROLE_LIST_MODE": true, "MUTE_ROLE": 0 }, "LOG_CHANNELS": {}, @@ -25,10 +25,10 @@ "CENSORING": { "ENABLED": false, "ALLOW_TRUSTED_BYPASS": false, - "WORD_BLACKLIST": [], - "TOKEN_BLACKLIST": [], - "INVITE_WHITELIST": [], - "DOMAIN_WHITELIST": false, + "WORD_CENSORLIST": [], + "TOKEN_CENSORLIST": [], + "ALLOWED_INVITE_LIST": [], + "DOMAIN_LIST_ALLOWED": false, "DOMAIN_LIST": [] }, "INFRACTIONS": { diff --git a/docs/pages/03.docs/02.setup/08.censoring/doc.md b/docs/pages/03.docs/02.setup/08.censoring/doc.md index ea5b39ef..b364c71a 100644 --- a/docs/pages/03.docs/02.setup/08.censoring/doc.md +++ b/docs/pages/03.docs/02.setup/08.censoring/doc.md @@ -24,15 +24,15 @@ Invite censoring does not kick in until there are servers on the whitelist. If y To add a server to the whitelist: ``` -!configure invite_whitelist add +!configure allowed_invites add ``` Similar story to remove one: ``` -!configure invite_whitelist remove +!configure allowed_invites remove ``` And to view the entire list: ``` -!configure invite_whitelist +!configure allowed_invites ``` ## Setting up text censoring @@ -40,11 +40,11 @@ Text censoring works with partial text matches and is case insensitive. **WARNING:** Be very careful for partial matches as this does not differentiate if it's in the middle of a word or a word on it's own. -To add something to the blacklist: +To add something to the censor_list: ``` -!configure blacklist add +!configure censor_list add ``` To remove: ``` -!configure blacklist remove +!configure censor_list remove ``` diff --git a/lang/en_US.json b/lang/en_US.json index a9f71374..53a60961 100644 --- a/lang/en_US.json +++ b/lang/en_US.json @@ -149,12 +149,12 @@ "voice_channel": "Voice channel {channel}", "mute_setup_failures": "I was unable to configure muting in the following channels, there probably is an explicit deny on that channel for `manage channel` on those channels or their category (if they are synced) for one of my roles (includes everyone role). Please make sure I can manage those channels and run this command again or deny the `send_messages` and `add_reactions` permissions for {role} manually.", "mute_setup_complete": "Automatic mute setup complete.", - "no_invite_whitelist": "Invite censoring is disabled, add servers to the list to enable it.", - "current_invite_whitelist": "Current invite whitelist (Server IDs):", - "already_invite_whitelist": "`{item}` is already on the invite whitelist.", - "invite_whitelist_added": "`{item}` is now a whitelisted server. Invites leading to this server will not be removed when posted.", - "was_no_invite_whitelist": "`{item}` was not on the whitelist.", - "invite_whitelist_removed": "`{item}` is no longer a whitelisted server. Invites leading to this server will be removed when posted.", + "no_allowed_invite_list": "Invite censoring is disabled, add servers to the list to enable it.", + "current_allowed_invite_list": "Current allowed invite liset (Server IDs):", + "already_allowed_invite_list": "`{item}` is already on the allowed invite list.", + "allowed_invite_list_added": "`{item}` is now a allowed server. Invites leading to this server will not be removed when posted.", + "was_no_allowed_invite_list": "`{item}` was not on the allowed invite list.", + "allowed_invite_list_removed": "`{item}` is no longer an allowed server. Invites leading to this server will be removed when posted.", "no_ignored_users": "No ignored users configured, I will log edits and deletions by all users.", "current_ignored_users": "Current users which I will not log edits and deleted messages for:", "already_ignored_user": "`{item}` is already on my ignore list.", @@ -253,14 +253,14 @@ "logs_already_disabled_channel": "The following logging types were already disabled for {channel}: ", "command_used": "{user} (``{user_id}``) used a command in {channel}:", "purge_fail_not_found": "Whoops, something went wrong there, I tried purging a message but Discord said it was already removed, do you have another bot in here who also responded to that purge command?", - "censored_message": "Censored message by {user} (``{user_id}``) in {channel}, blacklisted char sequence ``{sequence}`` is not allowed.\n```{message}```", - "censor_message_failed": "Failed to censor a message by {user} (``{user_id}``), blacklisted char sequence `{sequence}` is not allowed but I was unable to remove it.\n```{message}\n```<{link}>", - "censored_message_word": "Censored message by {user} (``{user_id}``) in {channel}, blacklisted word ``{sequence}`` is not allowed.\n```{message}```", - "censored_message_failed_word": "Failed to censor a message by {user} (``{user_id}``), blacklisted word`{sequence}` is not allowed but I was unable to remove it.\n```{message}\n```<{link}>", - "censored_message_domain_whitelist": "Censored message by {user} (``{user_id}``) in {channel}, domain ``{sequence}`` is not whitelisted.\n```{message}```", - "censored_message_failed_domain_whitelist": "Censored message by {user} (``{user_id}``) in {channel}, domain ``{sequence}`` is not whitelisted but I was unable to remove it\n```{message}```<{link}>", - "censored_message_domain_blacklist": "Censored message by {user} (``{user_id}``) in {channel}, domain ``{sequence}`` is blacklisted.\n```{message}```", - "censored_message_failed_domain_blacklist": "Censored message by {user} (``{user_id}``) in {channel}, domain ``{sequence}`` is blacklisted but I was unable to remove it\n```{message}```<{link}>", + "censored_message": "Censored message by {user} (``{user_id}``) in {channel}, char sequence ``{sequence}`` is not allowed.\n```{message}```", + "censor_message_failed": "Failed to censor a message by {user} (``{user_id}``), char sequence `{sequence}` is not allowed but I was unable to remove it.\n```{message}\n```<{link}>", + "censored_message_word": "Censored message by {user} (``{user_id}``) in {channel}, word ``{sequence}`` is not allowed.\n```{message}```", + "censored_message_failed_word": "Failed to censor a message by {user} (``{user_id}``), word`{sequence}` is not allowed but I was unable to remove it.\n```{message}\n```<{link}>", + "censored_message_domain_allowed": "Censored message by {user} (``{user_id}``) in {channel}, domain ``{sequence}`` is not on the allowed domains list.\n```{message}```", + "censored_message_failed_domain_allowed": "Censored message by {user} (``{user_id}``) in {channel}, domain ``{sequence}`` is not on the allowed domains list but I was unable to remove it\n```{message}```<{link}>", + "censored_message_domain_blocked": "Censored message by {user} (``{user_id}``) in {channel}, domain ``{sequence}`` is not allowed.\n```{message}```", + "censored_message_failed_domain_blocked": "Censored message by {user} (``{user_id}``) in {channel}, domain ``{sequence}`` is not allowed but I was unable to remove it\n```{message}```<{link}>", "censor_trusted_bypass": "Censor Trusted Bypass has been {status}", "censor_trusted_bypass_unchanged": "Trusted Censor Bypass is already {status}", "warning_dm": "You have been warned in **{server}**!", @@ -300,12 +300,11 @@ "mass_failures_ban": "I was unable to ban the following users ({page_num}/{pages}):", "mass_failures_unban": "I was unable to unban the following users ({page_num}/{pages}):", "processing": "Processing...", - "already_blacklisted": "``{word}`` was already on the blacklist.", - "entry_too_short": "Blacklist entries must be at least 3 chars.", - "entry_added": "Successfully added ``{entry}`` to the blacklist.", - "not_blacklisted": "``{word}`` was not blacklisted.", - "entry_removed": "Successfully removed ``{entry}`` from the blacklist.", - "blacklist_list": "Blacklist for {server} ({page_num}/{pages})", + "already_censored": "``{word}`` was already on the censor list.", + "entry_added": "Successfully added ``{entry}`` to the censor list.", + "not_censored": "``{word}`` was not on the censor list.", + "entry_removed": "Successfully removed ``{entry}`` from the censor list.", + "censor_list": "Censor list for {server} ({page_num}/{pages})", "inf_delete_confirmation": "Are you sure you would like to delete infraction #{id}?\n\nUser: {user} (``{user_id}``)\nReason: {reason}\n\n*This can not be undone.*", "inf_delete_deleted": "Infraction #{id} has been deleted.", "inf_delete_log": "{user} (``{user_id}``) deleted infraction #{id} to {target} (``{target_id}``) given by {mod} (``{mod_id}``) with reason:``{reason}``", @@ -384,26 +383,25 @@ "role_remove_not_allowed": "You are not authorized to remove roles from {user}", "role_add_confirmation": "Added the **{role}** role to {user}", "role_remove_confirmation": "Removed the **{role}** role from {user}", - "role_denied_whitelist": "The **{role}** role is not on the role whitelist", + "role_denied_allow": "The **{role}** role is not on the allowed roles list.", "configure_role_list_add": "Adds a role to the configuration list", "configure_role_list_remove": "Removes a role from the configuration list", - "configure_role_list_mode": "Sets if the list is a whitelist or blacklist", - "invalid_mode": "Not a valid list mode, please use 'whitelist' or 'blacklist'", - "role_list_mode_whitelist": "Role configuration list is now a whitelist.", - "role_list_mode_blacklist": "Role configuration list is now a blacklist.", + "configure_role_list_mode": "Sets if the list is a a list of allowed or disallowed roles to manage", + "invalid_mode": "Not a valid list mode, please use 'allowed' or 'blocked'", + "role_list_mode_allowed": "Role configuration list is now a list of allowed roles.", + "role_list_mode_blocked": "Role configuration list is now a blocked roles.", "role_too_high_add": "I need a role that is higher than the **{role}** role to be able to add it to people.", "role_too_high_remove": "I need a role that is higher than the **{role}** role to be able to remove it from people.", - "role_list_add_confirmation_whitelist": "The **{role}** role has been added to the whitelist.", - "role_list_add_confirmation_blacklist": "The **{role}** role has been added to the blacklist.", - "current_role_whitelist": "Role management whitelist", - "current_role_blacklist": "Role management blacklist", - "no_role_whitelist": "There are no roles on the whitelist, so no roles can be added/removed by the role command.", - "no_role_blacklist": "There are no roles on the blacklist, so all roles can be added/removed by the role command.", - "role_list_add_fail_whitelist": "The **{role}** role is already on the whitelist!", - "role_list_add_fail_blacklist": "The **{role}** role is already on the blacklist!", - "role_list_rmv_confirmation_whitelist": "The **{role}** role has been removed from the whitelist.", - "role_list_rmv_confirmation_blacklist": "The **{role}** role has been removed from the blacklist.", + "role_list_add_confirmation_allow": "The **{role}** role has been added to the allowed roles list.", + "role_list_add_confirmation_block": "The **{role}** role has been added to the blocked roles list.", + "current_role_allow_list": "Role management allowed list", + "current_role_block_list": "Role management blocked list", + "no_role_allow": "There are no roles on the allowed roles list, so no roles can be added/removed by the role command.", + "no_role_block": "There are no roles on the blocked roles list, so all roles can be added/removed by the role command.", + "role_list_add_fail": "The **{role}** role is already on the role list!", + "role_list_rmv_confirmation_allow": "The **{role}** role has been removed from the allowed roles list.", + "role_list_rmv_confirmation_block": "The **{role}** role has been removed from the blocked roles list.", "user_role_too_low_add": "You need to have a role above the **{role}** role to add this role to others.", "user_role_too_low_remove": "You need to have a role above the **{role}** role to remove it from others.", "message_wrong_channel": "The specified message was from another channel instead of this one.", @@ -523,9 +521,9 @@ "emoji_update_success": "Emoji name is now `{new_name}`", "emoji_delete_success": "Emoji removed.", "emoji_roles_add_role_already_in_list": "The following roles were already on the list: {roles}", - "emoji_roles_add_success": "Succesfully added the following roles to the emoji role whitelist: {roles}", - "emoji_roles_remove_role_not_in_list": "The following roles were not on the whitelist: {roles}", - "emoji_roles_remove_success": "Successfully removed the following roles from the whitelist: {roles}", + "emoji_roles_add_success": "Succesfully added the following roles to the emoji role list: {roles}", + "emoji_roles_remove_role_not_in_list": "The following roles were not on the list: {roles}", + "emoji_roles_remove_success": "Successfully removed the following roles from the list: {roles}", "emoji_upload_no_attachments": "Your message did not have any attachments to be uploaded as emoji", "emoji_name_space": "Emoji names can not have spaces", @@ -742,7 +740,8 @@ "clean_bots_help": "Removes messages sent by any bot", "clean_all_help": "Just clean everything","clean_until_help": "Cleans until the given message (message is also removed)", "clean_last_help": "Cleans all messages send in the last x time (5 m for example)", - "clean_between_help": "Cleans both messages given and everything in between","role_denied_blacklist": "The **{role}** role is on the role blacklist", + "clean_between_help": "Cleans both messages given and everything in between", + "role_denied_block": "The **{role}** role is on the blocked roles list", "cat_help": "Random cats!", "dog_help": "Random dogs!", "role_add_help": "Adds a role to someone", @@ -777,7 +776,7 @@ "configure_mod_roles_help": "Show or configure server mod roles", "configure_trusted_roles_help": "Show or configure server trusted roles", "configure_self_roles_help": "Allows adding/removing roles from the self assignable list", - "configure_invite_whitelist_help": "Allows adding/removing servers from the invite whitelist, only enforced when there are servers on the list", + "configure_allowed_invite_list_help": "Allows adding/removing servers from the allowed invite list, when there are servers on this list all invites to servers not on the list will be removed", "configure_ignored_users_help": "Configures users to ignore for edit/delete logs (like bots spamming the logs with edits)", "command_create_help": "Create a new command", "command_remove_help": "Removes a custom command", @@ -790,22 +789,22 @@ "too_many_many_roles": "An absolute ridiculous amount of roles", "user_not_on_server": "This user is not on the server", "unban_unable": "This user is on the server so can't be unbanned", - "configure_domain_list_help": "Configure whitelisted/blacklisted domains", + "configure_domain_list_help": "Configure domains to allow or block", "empty_domain_list": "The domain list is empty", - "current_domain_whitelist": "Current domain whitelist:", - "current_domain_blacklist": "Current domain blacklist:", - "domain_list_add_fail_blacklist": "The **``{domain}``** domain was already blacklisted", - "domain_list_add_fail_whitelisted": "The **``{domain}``** domain was already whitelisted", - "domain_list_add_confirmation_blacklist": "The **``{domain}``** domain was added to the blacklist", - "domain_list_add_confirmation_whitelist": "The **``{domain}``** domain was added to the whitelist", + "current_domain_list_allowed": "Current allowed domains list:", + "current_domain_list_blocked": "Current blocked domains list:", + "domain_list_add_fail_block": "The **``{domain}``** domain was already blocked", + "domain_list_add_fail_allow": "The **``{domain}``** domain was already allowed", + "domain_list_add_confirmation_block": "The **``{domain}``** domain was added to the blocked domains list.", + "domain_list_add_confirmation_allow": "The **``{domain}``** domain was added to the allowed domains list.", "configure_domain_list_add": "Add a domain to the domain list", "configure_domain_list_remove": "Remove a domain from the domain list", - "domain_list_rmv_fail_blacklist": "**``{domain}``** was not on the blacklist", - "domain_list_rmv_fail_whitelist": "**``{domain}``** was not on the whitelist", - "domain_list_rmv_confirmation_blacklist": "**``{domain}``** has been removed from the blacklist", - "domain_list_rmv_confirmation_whitelist": "**``{domain}``** has been removed from the whitelist", - "configure_domain_list_mode": "Set the domain list to whitelist or blacklist mode", - "domain_list_mode_blacklist": "The domain list is now a blacklist", - "domain_list_mode_whitelist": "The domain list is now a whitelist" + "domain_list_rmv_fail_block": "**``{domain}``** was not on the blocked domains list.", + "domain_list_rmv_fail_allow": "**``{domain}``** was not on the allowed domains list.", + "domain_list_rmv_confirmation_block": "**``{domain}``** has been removed from the blocked domains list.", + "domain_list_rmv_confirmation_allow": "**``{domain}``** has been removed from the allowed domains list.", + "configure_domain_list_mode": "Set if the domains on the list should be censored or only those domains should be allowed", + "domain_list_mode_block": "All domains on the list will now be censored.", + "domain_list_mode_allow": "All domains not on the list will now be censored" }