From 060b54f553f0818c6a505f4543297880daf1d775 Mon Sep 17 00:00:00 2001 From: Magic <82341152+MagicTheDev@users.noreply.github.com> Date: Sun, 28 Apr 2024 21:46:04 -0500 Subject: [PATCH] use war state --- bot/clan/utils.py | 14 ++------------ 1 file changed, 2 insertions(+), 12 deletions(-) diff --git a/bot/clan/utils.py b/bot/clan/utils.py index e7c9c4a..c2a526a 100644 --- a/bot/clan/utils.py +++ b/bot/clan/utils.py @@ -109,19 +109,9 @@ async def clan_war_track(clan_tag: str, db_client: MongoDatabase, coc_client: co previous_league_group: coc.ClanWarLeagueGroup | None = previous_war.league_group previous_league_group = previous_league_group._raw_data - # NEW WAR - if previous_war.preparation_start_time and war.preparation_start_time and previous_war.preparation_start_time.time != war.preparation_start_time.time: - if previous_war.state != "warEnded": - json_data = {"type": "war_ended", "war": previous_war._raw_data, "league_group": previous_league_group, "clan_tag": clan_tag} - producer.send("war", ujson.dumps(json_data).encode("utf-8"), key=clan_tag.encode("utf-8"), timestamp_ms=int(pend.now(tz=pend.UTC).timestamp() * 1000)) - json_data = {"type": "new_war", "war": war._raw_data, "league_group": league_group, "clan_tag": clan_tag} - producer.send("war", ujson.dumps(json_data).encode("utf-8"), key=clan_tag.encode("utf-8"), timestamp_ms=int(pend.now(tz=pend.UTC).timestamp() * 1000)) - elif war.preparation_start_time and not previous_war.preparation_start_time: - json_data = {"type": "new_war", "war": war._raw_data, "league_group": league_group, "clan_tag": clan_tag} - producer.send("war", ujson.dumps(json_data).encode("utf-8"), key=clan_tag.encode("utf-8"), timestamp_ms=int(pend.now(tz=pend.UTC).timestamp() * 1000)) - if war.state != previous_war.state: - json_data = {"type": "war_state", "old_war" : previous_war._raw_data, "new_war": war._raw_data, "league_group": previous_league_group, "clan_tag": clan_tag} + json_data = {"type": "war_state", "old_war" : previous_war._raw_data, "new_war": war._raw_data, "previous_league_group": previous_league_group, + "new_league_group" : league_group, "clan_tag": clan_tag} producer.send("war", ujson.dumps(json_data).encode("utf-8"), key=clan_tag.encode("utf-8"), timestamp_ms=int(pend.now(tz=pend.UTC).timestamp() * 1000))