diff options
| author | 2018-12-01 10:07:56 -0800 | |
|---|---|---|
| committer | 2018-12-01 18:07:56 +0000 | |
| commit | afa163b6354a699cebbcf41bbb0f14351d6f674b (patch) | |
| tree | 0acf8915245523b19f7b3bbbd7b7cb55ee808ccc /bot | |
| parent | Docker: build-base. I love alpine but it's so easy to forget stuff. (diff) | |
Fix global lb display to respect ties (#79)
Update member name regex to properly handle hyphens
Remove session cookie from global leaderboard request
Diffstat (limited to 'bot')
| -rw-r--r-- | bot/seasons/christmas/adventofcode.py | 11 | 
1 files changed, 8 insertions, 3 deletions
| diff --git a/bot/seasons/christmas/adventofcode.py b/bot/seasons/christmas/adventofcode.py index ba1e3242..59467f20 100644 --- a/bot/seasons/christmas/adventofcode.py +++ b/bot/seasons/christmas/adventofcode.py @@ -428,7 +428,7 @@ class AocGlobalLeaderboard:          aoc_url = f"https://adventofcode.com/{AocConfig.year}/leaderboard" -        async with aiohttp.ClientSession(cookies=AOC_SESSION_COOKIE, headers=AOC_REQUEST_HEADER) as session: +        async with aiohttp.ClientSession(headers=AOC_REQUEST_HEADER) as session:              async with session.get(aoc_url) as resp:                  if resp.status == 200:                      raw_html = await resp.text() @@ -439,7 +439,7 @@ class AocGlobalLeaderboard:          soup = BeautifulSoup(raw_html, "html.parser")          ele = soup.find_all("div", class_="leaderboard-entry") -        exp = r"(?:[ ]{,2}(\d+)\))?[ ]+(\d+)\s+([\w\(\)#\d ]+)" +        exp = r"(?:[ ]{,2}(\d+)\))?[ ]+(\d+)\s+([\w\(\)#\-\d ]+)"          lb_list = []          for entry in ele: @@ -475,7 +475,12 @@ class AocGlobalLeaderboard:          header = f"{' '*4}{'Score'} {'Name':^25}\n{'-'*36}"          table = ""          for member in members_to_print: -            table += f"{member[0]:3}) {member[1]:4} {member[2]:25.25}\n" +            # In the event of a tie, rank is None +            if member[0]: +                rank = f"{member[0]:3})" +            else: +                rank = f"{' ':4}" +            table += f"{rank} {member[1]:4} {member[2]:25.25}\n"          else:              table = f"```{header}\n{table}```" | 
