name formatting changes (initial + last_name; truncating)
This commit is contained in:
parent
a0c0941f74
commit
79f014ab69
1 changed files with 6 additions and 4 deletions
10
dudlebot.py
10
dudlebot.py
|
@ -12,6 +12,8 @@ from telegram.ext import Updater, CommandHandler, PicklePersistence
|
|||
|
||||
|
||||
class DudleBot:
|
||||
LINE_LIMIT = 9
|
||||
|
||||
def __init__(self, token):
|
||||
self.logger = logging.getLogger("dudle")
|
||||
|
||||
|
@ -80,7 +82,7 @@ class DudleBot:
|
|||
responses.append(PlanResponse.UNKNOWN)
|
||||
|
||||
user = update.message.from_user
|
||||
name = user.username or f"{user.first_name} {user.last_name}"
|
||||
name = user.username or ((user.first_name[0] + ". ") if user.first_name else '') + user.last_name
|
||||
|
||||
context.chat_data['plan'].entries[user.id] = PlanEntry(name=name, responses=responses)
|
||||
|
||||
|
@ -113,8 +115,7 @@ class DudleBot:
|
|||
|
||||
update.message.reply_text(response)
|
||||
|
||||
@staticmethod
|
||||
def _reply_with_plan(update, context):
|
||||
def _reply_with_plan(self, update, context):
|
||||
plan: Plan = context.chat_data['plan']
|
||||
|
||||
formatted_plan = f"Poll: {plan.start.strftime('%d.%m.%Y')} -> " \
|
||||
|
@ -138,7 +139,8 @@ class DudleBot:
|
|||
for response in responses:
|
||||
formatted_plan += f"{str(response)} "
|
||||
|
||||
formatted_plan += f" {entry.name}"
|
||||
formatted_plan += entry.name if len(entry.name) < self.LINE_LIMIT \
|
||||
else entry[:self.LINE_LIMIT - 2] + "…"
|
||||
formatted_plan += "\n"
|
||||
|
||||
formatted_plan += "```"
|
||||
|
|
Loading…
Reference in a new issue