Skip to content

Commit

Permalink
Improve readability of bridged messages
Browse files Browse the repository at this point in the history
  • Loading branch information
Tina-otoge committed May 15, 2024
1 parent 867fa99 commit bb83ad2
Showing 1 changed file with 19 additions and 6 deletions.
25 changes: 19 additions & 6 deletions mechadon/cogs/bridge.py
Original file line number Diff line number Diff line change
Expand Up @@ -66,9 +66,20 @@ async def on_message(self, message: Message):
replies_to = await message.channel.fetch_message(
message.reference.message_id
)
if not replies_to.author.bot:
author = replies_to.author.display_name
else:
author = str(replies_to.author)
if "#" in author and "(" in author and ")" in author:
last_paren = author.rfind("(")
author = author[:last_paren].strip()

content = (
f"{replies_to.author}:"
+ f"\n{escape_links(replies_to.clean_content)}"
f"Replying to {author}:\n"
+ "> "
+ "\n> ".join(
escape_links(replies_to.clean_content).split("\n")
)
+ "\n\n"
+ content
)
Expand All @@ -83,9 +94,11 @@ async def on_message(self, message: Message):
bridge.webhook,
{
"content": content,
"username": f"{message.author} (#{message.channel} @ {message.guild})",
"avatar_url": message.author.avatar.url
if message.author.avatar
else None,
"username": f"{message.author.display_name} (#{message.channel} @ {message.guild})",
"avatar_url": (
message.author.avatar.url
if message.author.avatar
else None
),
},
)

0 comments on commit bb83ad2

Please sign in to comment.