Skip to content

Commit 94325ac

Browse files
authored
Merge pull request #117 from andresdelfino/bold_project_titles
Print project titles in /proyectos with bold style
2 parents 6aba3ac + d7640f0 commit 94325ac

File tree

1 file changed

+17
-9
lines changed

1 file changed

+17
-9
lines changed

src/pycamp_bot/commands/projects.py

+17-9
Original file line numberDiff line numberDiff line change
@@ -457,28 +457,36 @@ async def show_projects(update, context):
457457
await update.message.reply_text(msg_text, link_preview_options=LinkPreviewOptions(is_disabled=True))
458458

459459
msg_text = ""
460+
PROJECT_FIELDS = [
461+
'*{}*',
462+
'Owner: @{}',
463+
'Temática: {}',
464+
'Nivel: {}',
465+
'Repositorio: {}',
466+
'Grupo de Telegram: {}',
467+
]
460468
for project in projects:
461-
project_text = "{}\n Owner: @{}\n Temática: {}\n Nivel: {}\n Repositorio: {}\n Grupo de Telegram: {}".format(
462-
project.name,
463-
project.owner.username,
464-
project.topic,
469+
project_text = '\n'.join(PROJECT_FIELDS).format(
470+
escape_markdown(project.name),
471+
escape_markdown(project.owner.username),
472+
escape_markdown(project.topic),
465473
DIFFICULTY_LEVEL_NAMES[project.difficult_level],
466-
project.repository_url or '(ninguno)',
467-
project.group_url or '(ninguno)',
474+
escape_markdown(project.repository_url or '(ninguno)'),
475+
escape_markdown(project.group_url or '(ninguno)'),
468476
)
469477
participants_count = Vote.select().where(
470478
(Vote.project == project) & (Vote.interest)).count()
471479
if participants_count > 0:
472-
project_text += "\n Interesades: {}".format(participants_count)
480+
project_text += "\nInteresades: {}".format(participants_count)
473481

474482
if len(msg_text) + len(project_text) > 4096:
475-
await update.message.reply_text(msg_text, link_preview_options=LinkPreviewOptions(is_disabled=True))
483+
await update.message.reply_text(msg_text, link_preview_options=LinkPreviewOptions(is_disabled=True), parse_mode='MarkdownV2')
476484
msg_text = ""
477485

478486
msg_text += "\n\n" + project_text
479487

480488
if msg_text:
481-
await update.message.reply_text(msg_text, link_preview_options=LinkPreviewOptions(is_disabled=True))
489+
await update.message.reply_text(msg_text, link_preview_options=LinkPreviewOptions(is_disabled=True), parse_mode='MarkdownV2')
482490

483491

484492
async def show_participants(update, context):

0 commit comments

Comments
 (0)