Update CurrentDrop tracking elsewhere in the code

This commit is contained in:
DevilXD committed 2024-06-23 09:54:27 +02:00
1 parent 7b0f25d5d0
commit e34d1bb2da
1 file changed
+8 -2
+8 -2
View File
@@ -1103,6 +1103,7 @@ class Twitch:
return
drop_id: str = message["data"]["drop_id"]
drop: TimedDrop | None = self._drops.get(drop_id)
watching_channel: Channel | None = self.watching_channel.get_with_default(None)
if msg_type == "drop-claim":
if drop is None:
logger.error(
@@ -1129,15 +1130,20 @@ class Twitch:
# by re-sending the watch payload. We can test for it by fetching the current drop
# via GQL, and then comparing drop IDs.
await asyncio.sleep(4)
if watching_channel is not None:
for attempt in range(8):
context = await self.gql_request(GQL_OPERATIONS["CurrentDrop"])
context = await self.gql_request(
GQL_OPERATIONS["CurrentDrop"].with_variables(
{"channelID": str(watching_channel.id)}
)
)
drop_data: JsonType | None = (
context["data"]["currentUser"]["dropCurrentSession"]
)
if drop_data is None or drop_data["dropID"] != drop.id:
break
await asyncio.sleep(2)
if campaign.can_earn(self.watching_channel.get_with_default(None)):
if campaign.can_earn(watching_channel):
self.restart_watching()
else:
self.change_state(State.INVENTORY_FETCH)