Properly report gains and losses

This commit is contained in:
Nexus 2024-07-05 00:27:59 +01:00
parent 54c49727dc
commit a8f5ae145a

View file

@ -113,7 +113,15 @@ class ElectionCog(commands.Cog):
try:
party, extra = span.get_text().strip().split(":", 1)
seats, extra = extra.split(",", 1)
seats = change = int(seats.split()[0])
extra = extra.strip()
if extra.lower() == "no change":
change = 0
else:
_values = extra.split()
change = int(_values[0])
if _values[-1] != "gained":
change *= -1
seats = int(seats.split()[0])
except ValueError:
self.log.error("failed to parse %r", span)
continue