From 311baa21e01d4aac11fb376389e807f1a07c985a Mon Sep 17 00:00:00 2001 From: SebClem Date: Thu, 25 Jan 2024 11:13:49 +0100 Subject: [PATCH] Add posts info on reply --- src/discord_tools/message.py | 12 ++++++++++-- src/main.py | 5 ++++- 2 files changed, 14 insertions(+), 3 deletions(-) diff --git a/src/discord_tools/message.py b/src/discord_tools/message.py index 949b27b..62270fd 100644 --- a/src/discord_tools/message.py +++ b/src/discord_tools/message.py @@ -9,7 +9,14 @@ IMAGE_NBR_LIMIT = 10 DEFAULT_UPLOAD_SIZE_LIMIT = 209715200 -async def send_message(message: discord.Message, files, tmp_dir: str, muted: bool): +async def send_message( + message: discord.Message, + files, + tmp_dir: str, + muted: bool, + title: str, + art_author: str, +): to_send_files = [] for file in files: joined = os.path.join(tmp_dir, file) @@ -32,7 +39,8 @@ async def send_message(message: discord.Message, files, tmp_dir: str, muted: boo to_send_files = to_send_files[1:] elif first: await message.reply( - files=splited_file, content=(TIPS_MESSAGE if not muted else None) + files=splited_file, + content=f"**{title}** by `{art_author}` {chr(10) + TIPS_MESSAGE if not muted else ''}", ) first = False else: diff --git a/src/main.py b/src/main.py index 7ba96f6..5afc13c 100644 --- a/src/main.py +++ b/src/main.py @@ -147,12 +147,15 @@ async def on_message(message: discord.Message): ) if data is None: return + (title, author) = data files = os.listdir(tmp_dir) files.sort() # await send_message.send_message_with_embed( # message, files, title, tmp_dir, match.group("url") # ) - await discord_tools.message.send_message(message, files, tmp_dir, muted) + await discord_tools.message.send_message( + message, files, tmp_dir, muted, title, author + ) client.run(DISCORD_TOKEN)