Allow the bad bot detection to pass, but print a warning
This commit is contained in:
1 parent
0075e8eb8d
commit
406635babb
1 file changed
+19
-14
@@ -80,18 +80,21 @@ class _AuthState:
|
|||||||
and datetime.now(timezone.utc) >= self.integrity_expires
|
and datetime.now(timezone.utc) >= self.integrity_expires
|
||||||
)
|
)
|
||||||
|
|
||||||
def _delattr(self, attr: str) -> None:
|
def _delattrs(self, *attrs: str) -> None:
|
||||||
if hasattr(self, attr):
|
for attr in attrs:
|
||||||
delattr(self, attr)
|
if hasattr(self, attr):
|
||||||
|
delattr(self, attr)
|
||||||
|
|
||||||
def clear(self) -> None:
|
def clear(self) -> None:
|
||||||
self._delattr("user_id")
|
self._delattrs(
|
||||||
self._delattr("device_id")
|
"user_id",
|
||||||
self._delattr("session_id")
|
"device_id",
|
||||||
self._delattr("access_token")
|
"session_id",
|
||||||
self._delattr("client_version")
|
"access_token",
|
||||||
self._delattr("integrity_token")
|
"client_version",
|
||||||
self._delattr("integrity_expires")
|
"integrity_token",
|
||||||
|
"integrity_expires",
|
||||||
|
)
|
||||||
self._logged_in.clear()
|
self._logged_in.clear()
|
||||||
|
|
||||||
async def _login(self) -> str:
|
async def _login(self) -> str:
|
||||||
@@ -276,16 +279,18 @@ class _AuthState:
|
|||||||
raise MinerException("Unable to parse the integrity token")
|
raise MinerException("Unable to parse the integrity token")
|
||||||
decoded_header: JsonType = json.loads(match.group(1))
|
decoded_header: JsonType = json.loads(match.group(1))
|
||||||
if decoded_header.get("is_bad_bot", "false") != "false":
|
if decoded_header.get("is_bad_bot", "false") != "false":
|
||||||
raise MinerException(
|
self._twitch.print(
|
||||||
"Twitch considers this miner as a \"Bad Bot\". "
|
"Twitch has detected this miner as a \"Bad Bot\", and may try to stop you "
|
||||||
"Try deleting the cookie file and try again."
|
"from claiming drops. You're proceeding at your own risk!"
|
||||||
)
|
)
|
||||||
|
await asyncio.sleep(7)
|
||||||
self._logged_in.set()
|
self._logged_in.set()
|
||||||
|
|
||||||
def invalidate(self, *, auth: bool = False, integrity: bool = False):
|
def invalidate(self, *, auth: bool = False, integrity: bool = False):
|
||||||
if auth:
|
if auth:
|
||||||
self._delattr("access_token")
|
self._delattrs("access_token")
|
||||||
if integrity:
|
if integrity:
|
||||||
|
self._delattrs("client_version")
|
||||||
self.integrity_expires = datetime.now(timezone.utc)
|
self.integrity_expires = datetime.now(timezone.utc)
|
||||||
|
|
||||||
|
|
||||||
|
|||||||
Reference in new issue
Block a user