From 56420334428cc970755eb49326f2746faeeade52 Mon Sep 17 00:00:00 2001 From: Infinidoge Date: Wed, 1 Jan 2025 23:19:49 -0500 Subject: [PATCH] check contents of embeds --- nomen/notifications.py | 21 ++++++++++++++++----- 1 file changed, 16 insertions(+), 5 deletions(-) diff --git a/nomen/notifications.py b/nomen/notifications.py index 4724631..10b822b 100644 --- a/nomen/notifications.py +++ b/nomen/notifications.py @@ -56,17 +56,18 @@ async def handle_notification(db_updates, ctx, message, keyword, user_id, use_em header = f"🔔 `{message.author.display_name}` mentioned `{keyword}` on `{ctx.guild}`:" footer = f" | [Show]({message.jump_url}) | <#{ctx.channel.id}>" + content = message.content or "(*Keyword in embed*)" if use_embed: log.debug("Sending embed") - embed = Embed(description=message.content + "\n\n" + footer) + embed = Embed(description=content + "\n\n" + footer) embed.set_author( name=f"{message.author.display_name} ({message.author})", icon_url=message.author.display_avatar, ) try: - await member.send(header, embed=embed) + await member.send(header, embeds=[embed] + message.embeds[:9]) except Forbidden: log.warning("Cannot send messages to this user") else: @@ -74,7 +75,7 @@ async def handle_notification(db_updates, ctx, message, keyword, user_id, use_em paginator = Paginator(prefix="", suffix="") paginator.add_line(header) paginator.add_line() - for line in indent(message.content, "> ", lambda line: True).strip().split("\n"): + for line in indent(content, "> ", lambda line: True).strip().split("\n"): if len(line) < 1990: paginator.add_line(line) else: @@ -82,8 +83,9 @@ async def handle_notification(db_updates, ctx, message, keyword, user_id, use_em paginator.add_line() paginator.add_line(footer) try: - for page in paginator.pages: + for page in paginator.pages[:-1]: await member.send(page) + await member.send(paginator.pages[-1], embeds=message.embeds[:10]) except Forbidden: log.warning("Cannot send messages to this user") @@ -97,12 +99,21 @@ async def handle_triggers(ctx, message): log.debug(f"Handling triggers for '{message.content}' from {ctx.author}") + contents = [message.content] + for embed in message.embeds: + contents.append(embed.title or "") + contents.append(embed.description or "") + for field in embed.fields: + contents.append(field.name or "") + contents.append(field.value or "") + contents.append(embed.footer.text or "") + params = { "author": ctx.author.id, "channel": ctx.channel.id, "category": ctx.channel.category_id, "guild": ctx.guild.id, - "content": message.content, + "content": " ".join(contents), "is_bot": ctx.author.bot, "parent": 0, }