fix /start and lastYear_or_1000games
This commit is contained in:
parent
9011b3015b
commit
d52e962022
5 changed files with 20 additions and 8 deletions
|
|
@ -188,7 +188,7 @@ class StatsFormatter:
|
|||
earliest_ts = data.get('earliest_game_ts')
|
||||
if isinstance(earliest_ts, int):
|
||||
earliest = datetime.fromtimestamp(earliest_ts).strftime("%d.%m.%Y")
|
||||
header += f"\nStart of these 1000 games: {earliest}"
|
||||
header += f"\n\n\nStart of these 1000 games: {earliest}"
|
||||
else:
|
||||
header = f"📈 {username}: last year (rated), games: {games_count}"
|
||||
# Use earliest actual game date instead of naive 'year ago'
|
||||
|
|
@ -196,7 +196,7 @@ class StatsFormatter:
|
|||
if isinstance(earliest_ts, int) and isinstance(period_end, int):
|
||||
start_str = datetime.fromtimestamp(earliest_ts).strftime("%d.%m.%Y")
|
||||
end_str = datetime.fromtimestamp(period_end).strftime("%d.%m.%Y")
|
||||
header += f"\nPeriod: {start_str}–{end_str}"
|
||||
header += f"\n\n\nPeriod: {start_str}–{end_str}"
|
||||
# Body per mode
|
||||
lines = []
|
||||
for mode in ["bullet", "blitz", "rapid", "classical", "correspondence"]:
|
||||
|
|
@ -217,7 +217,16 @@ class StatsFormatter:
|
|||
lines.append(
|
||||
f"{emoji} {mode.title()}: {games_played} Δ {rating_change_str} R {rating_str} ✅ {wins} ❌ {losses} 🤝 {draws}"
|
||||
)
|
||||
# Total
|
||||
# Do not print 'Итого' line per new requirement
|
||||
body = "\n".join(lines)
|
||||
return f"{header}\n{body}".rstrip()
|
||||
# Join lines with newlines between each mode
|
||||
# Between regular modes: one empty line (\n\n)
|
||||
# Before last mode: two empty lines (\n\n\n)
|
||||
if len(lines) == 0:
|
||||
body = ""
|
||||
elif len(lines) == 1:
|
||||
body = lines[0]
|
||||
else:
|
||||
# All modes except last joined with one empty line
|
||||
body = "\n\n".join(lines[:-1])
|
||||
# Add two empty lines before last mode
|
||||
body += "\n\n\n" + lines[-1]
|
||||
return f"{header}\n\n{body}"
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue