Skip to content

Commit

Permalink
Improve Highscore Layout (#19)
Browse files Browse the repository at this point in the history
  • Loading branch information
Bibo-Joshi committed Aug 31, 2020
1 parent 921f03c commit 6e843c7
Showing 1 changed file with 17 additions and 7 deletions.
24 changes: 17 additions & 7 deletions bot/highscore.py
Original file line number Diff line number Diff line change
Expand Up @@ -30,16 +30,26 @@

BUTTON_TEXTS = {
OVERALL_SCORE: 'Gesamter Highscore',
TODAYS_SCORE: 'Highscore von heute',
WEEKS_SCORE: 'Highscore der aktuellen Woche',
MONTHS_SCORE: 'Highscore des aktuellen Monats',
YEARS_SCORE: 'Highscore des aktuellen Jahres',
TODAYS_SCORE: 'Heute',
WEEKS_SCORE: 'Woche',
MONTHS_SCORE: 'Monats',
YEARS_SCORE: 'Jahr',
}
"""Dict[str, str]: Mapping giving for each callback data a corresponding text for the keyboard.
"""

HIGHSCORE_KEYBOARD = InlineKeyboardMarkup.from_column(
[InlineKeyboardButton(t, callback_data=d) for d, t in BUTTON_TEXTS.items()])
# yapf: disable
HIGHSCORE_KEYBOARD = InlineKeyboardMarkup([
[InlineKeyboardButton(BUTTON_TEXTS[OVERALL_SCORE], callback_data=OVERALL_SCORE)],
[
InlineKeyboardButton(BUTTON_TEXTS[TODAYS_SCORE], callback_data=TODAYS_SCORE),
InlineKeyboardButton(BUTTON_TEXTS[WEEKS_SCORE], callback_data=WEEKS_SCORE)
],
[
InlineKeyboardButton(BUTTON_TEXTS[MONTHS_SCORE], callback_data=MONTHS_SCORE),
InlineKeyboardButton(BUTTON_TEXTS[YEARS_SCORE], callback_data=YEARS_SCORE)
]])
# yapf: enable
"""
:class:`telegram.InlineKeyboardMarkup`: Keyboard to switch between the different highscores.
"""
Expand All @@ -54,7 +64,7 @@ def build_text(orchestra: Orchestra, interval: str) -> str:
interval: The requested interval.
"""
method = getattr(orchestra, "{}_score_text".format(interval))
return f'<b>{HEADINGS["{} highscore".format(interval)]}</b>\n\n{method(length=25, html=True)}'
return f'<b>{HEADINGS["{} highscore".format(interval)]}</b>\n\n{method(length=10, html=True)}'


def show_highscore(update: Update, context: CallbackContext) -> None:
Expand Down

0 comments on commit 6e843c7

Please sign in to comment.