Refine author display formatting in RSS and PostParser
This commit is contained in:
+2
-2
@@ -102,13 +102,13 @@ class PostParser:
|
||||
if message.sender_chat:
|
||||
title = getattr(message.sender_chat, 'title', '').strip()
|
||||
username = getattr(message.sender_chat, 'username', '').strip()
|
||||
return f"{title} by @{username}" if username else title
|
||||
return f"{title} (@{username})" if username else title
|
||||
elif message.from_user:
|
||||
first = getattr(message.from_user, 'first_name', '').strip()
|
||||
last = getattr(message.from_user, 'last_name', '').strip()
|
||||
username = getattr(message.from_user, 'username', '').strip()
|
||||
name = ' '.join(filter(None, [first, last]))
|
||||
return f"{name} by @{username}" if username else name
|
||||
return f"{name} (@{username})" if username else name
|
||||
return "Unknown author"
|
||||
|
||||
def _generate_title(self, message: Message) -> str:
|
||||
|
||||
+2
-4
@@ -50,9 +50,7 @@ async def generate_channel_rss(channel: str, post_parser: Optional[PostParser] =
|
||||
fg.link(href=f"https://t.me/{channel}", rel='alternate')
|
||||
fg.description(f'Telegram channel {channel} RSS feed')
|
||||
fg.language('ru')
|
||||
#fg.dc.dc_creator(f"@{channel}")
|
||||
|
||||
|
||||
|
||||
fg.id(f"{base_url}/rss/{channel}")
|
||||
|
||||
# First collect all posts
|
||||
@@ -127,7 +125,7 @@ async def generate_channel_rss(channel: str, post_parser: Optional[PostParser] =
|
||||
fe.pubDate(pub_date)
|
||||
fe.guid(post_link, permalink=True)
|
||||
|
||||
if post.get('author') and post['author'] != channel:
|
||||
if post.get('author') and post['author'] != main_name:
|
||||
fe.author(name="", email=post['author'])
|
||||
|
||||
rss_feed = fg.rss_str(pretty=True)
|
||||
|
||||
Reference in New Issue
Block a user