Skip to content

Commit

Permalink
Merge pull request #2 from domints/newline-as-description
Browse files Browse the repository at this point in the history
Treat first newline as separator between Title and Description
  • Loading branch information
hbrylkowski authored Nov 20, 2023
2 parents b0adb21 + c14a65e commit 47fbf1b
Showing 1 changed file with 11 additions and 3 deletions.
14 changes: 11 additions & 3 deletions main.py
Original file line number Diff line number Diff line change
Expand Up @@ -30,12 +30,20 @@ def handler_add_task(update, context):
if len(context.args) < 3:
update.message.reply_text('Podaj, proszę, tytuł jako argument')
return

msg_text = update.message.text_markdown.lstrip('/add\\_task').strip() # need to work on this, because context.args doesn't indicate new lines
first_newline = msg_text.find('\n')

context.args[0] = context.args[0].capitalize()
title = ''
description = ''

title = ' '.join(context.args)
if first_newline == -1:
title = msg_text.capitalize()
else:
title = msg_text[:first_newline].capitalize()
description = msg_text[first_newline + 1:].strip()
description += '\n\n'

description = ''
description += ' *Dodane przez:* {} '.format(update.message.from_user.name)
description += '\nlink do wiadomości: {} '.format(update.message.link)

Expand Down

0 comments on commit 47fbf1b

Please sign in to comment.