From 67d126ea3c66b1c2df2412e3cd9dd96cfb6beb04 Mon Sep 17 00:00:00 2001 From: AG_1436 <45149585+AG4lyf@users.noreply.github.com> Date: Tue, 7 Jan 2020 00:15:22 +0530 Subject: Add exception where relayed message.content length exceed 2048 characters --- bot/seasons/evergreen/bookmark.py | 5 ++++- 1 file changed, 4 insertions(+), 1 deletion(-) (limited to 'bot') diff --git a/bot/seasons/evergreen/bookmark.py b/bot/seasons/evergreen/bookmark.py index 9962186f..5b399739 100644 --- a/bot/seasons/evergreen/bookmark.py +++ b/bot/seasons/evergreen/bookmark.py @@ -25,11 +25,14 @@ class Bookmark(commands.Cog): ) -> None: """Send the author a link to `target_message` via DMs.""" log.info(f"{ctx.author} bookmarked {target_message.jump_url} with title '{title}'") + content = target_message.content + if len(content) > 250: + content = content[:250]+'......' embed = discord.Embed( title=title, colour=Colours.soft_green, description=( - f"{target_message.content}\n\n" + f"{content}\n\n" f"[Visit original message]({target_message.jump_url})" ) ) -- cgit v1.2.3 From 9735b0ad3bbfc98df5f48b0fe3e0c7fdf3c4be6c Mon Sep 17 00:00:00 2001 From: AG_1436 <45149585+AG4lyf@users.noreply.github.com> Date: Tue, 7 Jan 2020 20:30:44 +0530 Subject: Moved jump url into a field. --- bot/seasons/evergreen/bookmark.py | 8 ++------ 1 file changed, 2 insertions(+), 6 deletions(-) (limited to 'bot') diff --git a/bot/seasons/evergreen/bookmark.py b/bot/seasons/evergreen/bookmark.py index 5b399739..56c436d6 100644 --- a/bot/seasons/evergreen/bookmark.py +++ b/bot/seasons/evergreen/bookmark.py @@ -26,16 +26,12 @@ class Bookmark(commands.Cog): """Send the author a link to `target_message` via DMs.""" log.info(f"{ctx.author} bookmarked {target_message.jump_url} with title '{title}'") content = target_message.content - if len(content) > 250: - content = content[:250]+'......' embed = discord.Embed( title=title, colour=Colours.soft_green, - description=( - f"{content}\n\n" - f"[Visit original message]({target_message.jump_url})" - ) + description=content ) + embed.add_field(name="Wanna give it a visit?", value=f"[Visit original message]({target_message.jump_url})") embed.set_author(name=target_message.author, icon_url=target_message.author.avatar_url) embed.set_thumbnail(url=bookmark_icon_url) -- cgit v1.2.3 From b4846a9e5262f0b86045d81da5ccb1be33f294e8 Mon Sep 17 00:00:00 2001 From: AG_1436 <45149585+AG4lyf@users.noreply.github.com> Date: Tue, 7 Jan 2020 20:31:46 +0530 Subject: Removed unnacessary `content` variable usage --- bot/seasons/evergreen/bookmark.py | 3 +-- 1 file changed, 1 insertion(+), 2 deletions(-) (limited to 'bot') diff --git a/bot/seasons/evergreen/bookmark.py b/bot/seasons/evergreen/bookmark.py index 56c436d6..0197f9f4 100644 --- a/bot/seasons/evergreen/bookmark.py +++ b/bot/seasons/evergreen/bookmark.py @@ -25,11 +25,10 @@ class Bookmark(commands.Cog): ) -> None: """Send the author a link to `target_message` via DMs.""" log.info(f"{ctx.author} bookmarked {target_message.jump_url} with title '{title}'") - content = target_message.content embed = discord.Embed( title=title, colour=Colours.soft_green, - description=content + description=target_message.content ) embed.add_field(name="Wanna give it a visit?", value=f"[Visit original message]({target_message.jump_url})") embed.set_author(name=target_message.author, icon_url=target_message.author.avatar_url) -- cgit v1.2.3 From 9c4cf670fff767569fb4d29c7c4108f88e82015b Mon Sep 17 00:00:00 2001 From: AG_1436 <45149585+AG4lyf@users.noreply.github.com> Date: Sat, 25 Jan 2020 15:33:59 +0530 Subject: Added permission check for staff channels message leak. --- bot/seasons/evergreen/bookmark.py | 12 ++++++++++++ 1 file changed, 12 insertions(+) (limited to 'bot') diff --git a/bot/seasons/evergreen/bookmark.py b/bot/seasons/evergreen/bookmark.py index 0197f9f4..3fe1d12c 100644 --- a/bot/seasons/evergreen/bookmark.py +++ b/bot/seasons/evergreen/bookmark.py @@ -25,6 +25,18 @@ class Bookmark(commands.Cog): ) -> None: """Send the author a link to `target_message` via DMs.""" log.info(f"{ctx.author} bookmarked {target_message.jump_url} with title '{title}'") + permissions = ctx.author.permissions_in(target_message.channel) + if not permissions.read_messages: + embed = discord.Embed( + title=random.choice(ERROR_REPLIES), + color=Colours.soft_red, + description="You don't have permission to see what's in the channel so you can't " + "bookmark a message from it." + ) + embed.set_author(name=ctx.author.name, icon_url=ctx.author.avatar_url) + await ctx.send(embed=embed) + return + embed = discord.Embed( title=title, colour=Colours.soft_green, -- cgit v1.2.3 From a5f74d417c665c8ac5699d557aebf19c61d0f588 Mon Sep 17 00:00:00 2001 From: "S. Co1" Date: Mon, 27 Jan 2020 18:08:19 -0500 Subject: Shorten description & remove author override in permission error embed Update logging events so they follow the correct chain of execution --- bot/seasons/evergreen/bookmark.py | 8 ++++---- 1 file changed, 4 insertions(+), 4 deletions(-) (limited to 'bot') diff --git a/bot/seasons/evergreen/bookmark.py b/bot/seasons/evergreen/bookmark.py index 3fe1d12c..7bdd362c 100644 --- a/bot/seasons/evergreen/bookmark.py +++ b/bot/seasons/evergreen/bookmark.py @@ -24,16 +24,15 @@ class Bookmark(commands.Cog): title: str = "Bookmark" ) -> None: """Send the author a link to `target_message` via DMs.""" - log.info(f"{ctx.author} bookmarked {target_message.jump_url} with title '{title}'") + # Prevent users from bookmarking a message in a channel they don't have access to permissions = ctx.author.permissions_in(target_message.channel) if not permissions.read_messages: + log.info(f"{ctx.author} tried to bookmark a message in #{target_message.channel} but has no permissions") embed = discord.Embed( title=random.choice(ERROR_REPLIES), color=Colours.soft_red, - description="You don't have permission to see what's in the channel so you can't " - "bookmark a message from it." + description="You don't have permission to view this channel." ) - embed.set_author(name=ctx.author.name, icon_url=ctx.author.avatar_url) await ctx.send(embed=embed) return @@ -56,6 +55,7 @@ class Bookmark(commands.Cog): ) await ctx.send(embed=error_embed) else: + log.info(f"{ctx.author} bookmarked {target_message.jump_url} with title '{title}'") await ctx.message.add_reaction(Emojis.envelope) -- cgit v1.2.3