diff --git a/main.py b/main.py
index ca4ee9b..87721f9 100644
--- a/main.py
+++ b/main.py
@@ -10,7 +10,7 @@ from io import BytesIO
from pathlib import Path
from tempfile import TemporaryDirectory
from time import time
-from typing import List
+from typing import List, Iterable
import boto3
import ffmpeg
@@ -38,6 +38,10 @@ dp = Dispatcher()
ChatFilter = F.chat.id.in_(set(map(int, os.environ['USERS'].split(','))))
+def format_tags(tags: Iterable[str]):
+ return ' '.join(f'#{tag}' for tag in tags) or 'None'
+
+
async def send_post(post: E621Post, tag_list: List[str]):
await bot.send_chat_action(int(os.environ['SEND_CHAT']), action=ChatAction.TYPING)
monitored_tags = set(post.tags.flatten()) & set(tag_list)
@@ -45,10 +49,10 @@ async def send_post(post: E621Post, tag_list: List[str]):
character_tags = post.tags.character
copyright_tags = post.tags.copyright
caption = '\n'.join(l for l in [
- f'Monitored tags: {" ".join(monitored_tags) or "None"}',
- artist_tags and f'Artist: {" ".join(artist_tags)}',
- character_tags and f'Character: {", ".join(character_tags)}',
- copyright_tags and f'Copyright: {", ".join(copyright_tags)}',
+ f'Monitored tags: {format_tags(monitored_tags) or "None"}',
+ artist_tags and f'Artist: {format_tags(artist_tags)}',
+ character_tags and f'Character: {format_tags(character_tags)}',
+ copyright_tags and f'Copyright: {format_tags(copyright_tags)}',
f'\nhttps://e621.net/posts/{post.id}'
] if l)
if post.file.url: