diff --git a/nomen/notifications.py b/nomen/notifications.py index b69a4f3..f1a0bf3 100644 --- a/nomen/notifications.py +++ b/nomen/notifications.py @@ -5,7 +5,6 @@ from typing import Union from disnake import Embed, Member, Thread, User from disnake.abc import GuildChannel -from disnake.errors import Forbidden from disnake.ext.commands import Cog, group, guild_only from .utils import can_view, confirm, test_keyword @@ -65,16 +64,10 @@ async def handle_notification(db_updates, ctx, message, keyword, user_id, use_em icon_url=message.author.display_avatar, ) - try: - await member.send(header, embed=embed) - except Forbidden: - log.warning("Cannot send messages to this user") + await member.send(header, embed=embed) else: log.debug("Sending plain message") - try: - await member.send("\n".join((header, indent(message.content, "> ", lambda line: True).strip(), footer))) - except Forbidden: - log.warning("Cannot send messages to this user") + await member.send("\n".join((header, indent(message.content, "> ", lambda line: True).strip(), footer))) log.debug("Sent") diff --git a/nomen/settings.py b/nomen/settings.py index ee6f7da..b86434c 100644 --- a/nomen/settings.py +++ b/nomen/settings.py @@ -148,10 +148,6 @@ You may want to `{ctx.clean_prefix}nomen export` first""" You will not trigger anyone else's notifications, and you will not receive any notifications """ - if await ctx.bot.get_setting(ctx.author.id, "disabled"): - await ctx.send("You are already opted-out") - return - log.debug(f"Opting-out: {ctx.author} ({ctx.author.id})") await ctx.send( @@ -167,10 +163,6 @@ You may want to `{ctx.clean_prefix}nomen export` first""" Opt-in to Nomen processing your messages """ - if not await ctx.bot.get_setting(ctx.author.id, "disabled"): - await ctx.send("You are already opted-in") - return - log.debug(f"Opting-in: {ctx.author} ({ctx.author.id})") await ctx.send( diff --git a/nomen/utils.py b/nomen/utils.py index 29a77ef..417a9c8 100644 --- a/nomen/utils.py +++ b/nomen/utils.py @@ -4,7 +4,6 @@ from itertools import chain import re2 as re from disnake import ChannelType -from disnake.ext.commands import BadArgument log = logging.getLogger("nomen.utils") @@ -88,14 +87,9 @@ def compile_keyword(keyword, regex): if not regex: keyword = re.escape(keyword) - try: - reg = re.compile(rf"(?i)\b{keyword}\b") - regex_cache[(keyword, regex)] = reg - return reg - except re._re2.Error: - raise BadArgument( - "Invalid regex. Nomen only supports regexes that [re2]() can parse." - ) + reg = re.compile(rf"(?i)\b{keyword}\b") + regex_cache[(keyword, regex)] = reg + return reg def contains(string, keyword, regex):