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
+15 -9
+15 -9
View File
@@ -1103,6 +1103,7 @@ class Twitch:
return return
drop_id: str = message["data"]["drop_id"] drop_id: str = message["data"]["drop_id"]
drop: TimedDrop | None = self._drops.get(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 msg_type == "drop-claim":
if drop is None: if drop is None:
logger.error( logger.error(
@@ -1129,15 +1130,20 @@ class Twitch:
# by re-sending the watch payload. We can test for it by fetching the current drop # by re-sending the watch payload. We can test for it by fetching the current drop
# via GQL, and then comparing drop IDs. # via GQL, and then comparing drop IDs.
await asyncio.sleep(4) await asyncio.sleep(4)
for attempt in range(8): if watching_channel is not None:
context = await self.gql_request(GQL_OPERATIONS["CurrentDrop"]) for attempt in range(8):
drop_data: JsonType | None = ( context = await self.gql_request(
context["data"]["currentUser"]["dropCurrentSession"] GQL_OPERATIONS["CurrentDrop"].with_variables(
) {"channelID": str(watching_channel.id)}
if drop_data is None or drop_data["dropID"] != drop.id: )
break )
await asyncio.sleep(2) drop_data: JsonType | None = (
if campaign.can_earn(self.watching_channel.get_with_default(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(watching_channel):
self.restart_watching() self.restart_watching()
else: else:
self.change_state(State.INVENTORY_FETCH) self.change_state(State.INVENTORY_FETCH)