From 50381a11c3d8fe6d5c9f9b2d61a1d8009e255fe7 Mon Sep 17 00:00:00 2001 From: nexy7574 Date: Fri, 3 May 2024 20:34:56 +0100 Subject: [PATCH] Account for commas --- src/cogs/election.py | 8 ++++---- 1 file changed, 4 insertions(+), 4 deletions(-) diff --git a/src/cogs/election.py b/src/cogs/election.py index db32c2b..2a9667f 100644 --- a/src/cogs/election.py +++ b/src/cogs/election.py @@ -13,7 +13,7 @@ from discord.ext import commands SPAN_REGEX = re.compile( - r"^(?P[a-zA-Z]+)\s(?P\d+)\scouncillors\s(?P\d+)\scouncillors\s(?P(gained|lost))$" + r"^(?P(\D+)(?P[0-9,]+)\scouncillors\s(?P[0-9,]+)\scouncillors\s(?P(gained|lost))$" ) MULTI: dict[str, int] = { "gained": 1, @@ -89,9 +89,9 @@ class ElectionCog(commands.Cog): ) continue - results[str(groups["party"])] = [ - int(groups["councillors"]), - int(groups["net"]) * MULTI[groups["net_change"]], + results[str(groups["party"]).strip()] = [ + int(groups["councillors"].strip().strip(",")), + int(groups["net"].strip().strip(",")) * MULTI[groups["net_change"]], int(find_colour(child_ul.next["class"][0])[1:], base=16) ] return results