change tags formatting

master
bakatrouble 6 months ago
parent 7b8af45c0b
commit 446649fc7f

@ -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: <b>{" ".join(monitored_tags) or "None"}</b>',
artist_tags and f'Artist: <b>{" ".join(artist_tags)}</b>',
character_tags and f'Character: <b>{", ".join(character_tags)}</b>',
copyright_tags and f'Copyright: <b>{", ".join(copyright_tags)}</b>',
f'Monitored tags: <b>{format_tags(monitored_tags) or "None"}</b>',
artist_tags and f'Artist: <b>{format_tags(artist_tags)}</b>',
character_tags and f'Character: <b>{format_tags(character_tags)}</b>',
copyright_tags and f'Copyright: <b>{format_tags(copyright_tags)}</b>',
f'\nhttps://e621.net/posts/{post.id}'
] if l)
if post.file.url:

Loading…
Cancel
Save