Added ellipsis truncation to system list descriptions

This commit is contained in:
Bella | Nightshade
2019-03-23 21:13:43 +09:30
committed by Astrid
parent 0aea658af9
commit 0266db5589
2 changed files with 18 additions and 10 deletions

View File

@@ -25,6 +25,12 @@ def truncate_description(s: str) -> str:
return s[:2048]
def truncate_description_list(s: str) -> str:
if len(s) > 512:
return s[:512-45] + "..."
return s
def truncate_title(s: str) -> str:
return s[:256]
@@ -238,8 +244,10 @@ def member_list(system: System, all_members: List[Member], current_page: int, pa
member_description += "**Birthday:** {}\n".format(member.birthday_string())
if member.pronouns:
member_description += "**Pronouns:** {}\n".format(member.pronouns)
if member.description:
if len(member.description) > 512:
member_description += "\n" + truncate_description_list(member.description) + "\n" + "Type `pk;member {}` for full description.".format(member.hid)
else:
member_description += "\n" + member.description
embed.add_field(name=member.name, value=truncate_field_body(member_description) or "\u200B", inline=False)
return embed
return embed