Make the GQL claim operation treat request errors as a failed claiming operation
This commit is contained in:
1 parent
99359a7a69
commit
1dac01b141
2 files changed
+11
-5
No files matched your search
+10
-4
@@ -8,6 +8,7 @@ from functools import cached_property
|
|||||||
from datetime import datetime, timedelta, timezone
|
from datetime import datetime, timedelta, timezone
|
||||||
|
|
||||||
from channel import Channel
|
from channel import Channel
|
||||||
|
from exceptions import GQLException
|
||||||
from constants import GQL_OPERATIONS, URLType
|
from constants import GQL_OPERATIONS, URLType
|
||||||
from utils import timestamp, invalidate_cache, Game
|
from utils import timestamp, invalidate_cache, Game
|
||||||
|
|
||||||
@@ -155,11 +156,16 @@ class BaseDrop:
|
|||||||
return True
|
return True
|
||||||
if not self.can_claim:
|
if not self.can_claim:
|
||||||
return False
|
return False
|
||||||
response = await self._twitch.gql_request(
|
try:
|
||||||
GQL_OPERATIONS["ClaimDrop"].with_variables(
|
response = await self._twitch.gql_request(
|
||||||
{"input": {"dropInstanceID": self.claim_id}}
|
GQL_OPERATIONS["ClaimDrop"].with_variables(
|
||||||
|
{"input": {"dropInstanceID": self.claim_id}}
|
||||||
|
)
|
||||||
)
|
)
|
||||||
)
|
except GQLException:
|
||||||
|
# regardless of the error, we have to assume
|
||||||
|
# the claiming operation has potentially failed
|
||||||
|
return False
|
||||||
data = response["data"]
|
data = response["data"]
|
||||||
if "errors" in data and data["errors"]:
|
if "errors" in data and data["errors"]:
|
||||||
return False
|
return False
|
||||||
|
|||||||
@@ -1179,7 +1179,7 @@ class Twitch:
|
|||||||
self.print(_("status", "claimed_drop").format(drop=claim_text.replace('\n', ' ')))
|
self.print(_("status", "claimed_drop").format(drop=claim_text.replace('\n', ' ')))
|
||||||
self.gui.tray.notify(claim_text, _("gui", "tray", "notification_title"))
|
self.gui.tray.notify(claim_text, _("gui", "tray", "notification_title"))
|
||||||
else:
|
else:
|
||||||
logger.error(f"Drop claim failed! Drop ID: {drop_id}")
|
logger.error(f"Drop claim has potentially failed! Drop ID: {drop_id}")
|
||||||
# About 4-20s after claiming the drop, next drop can be started
|
# About 4-20s after claiming the drop, next drop can be started
|
||||||
# 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.
|
||||||
|
|||||||
Reference in new issue
Block a user