Task fetcher updates, state update repeater frequency increased for restricted IPs to not timeout cookie session
This commit is contained in:
parent
c57bf99976
commit
a1c6fb06a0
@ -509,7 +509,7 @@ class BaseCitizen(access_points.CitizenAPI):
|
||||
self.write_log(f"Resumed as: {self.name}")
|
||||
if re.search('<div id="accountSecurity" class="it-hurts-when-ip">', resp.text):
|
||||
self.restricted_ip = True
|
||||
self.report_error("eRepublik has blacklisted IP. Limited functionality!", True)
|
||||
# self.report_error("eRepublik has blacklisted IP. Limited functionality!", True)
|
||||
|
||||
self.logged_in = True
|
||||
self.get_csrf_token()
|
||||
@ -733,7 +733,7 @@ class BaseCitizen(access_points.CitizenAPI):
|
||||
self.get_csrf_token()
|
||||
if re.search('<div id="accountSecurity" class="it-hurts-when-ip">', self.r.text):
|
||||
self.restricted_ip = True
|
||||
self.report_error("eRepublik has blacklisted IP. Limited functionality!", True)
|
||||
# self.report_error("eRepublik has blacklisted IP. Limited functionality!", True)
|
||||
|
||||
self.logged_in = True
|
||||
|
||||
@ -2709,13 +2709,14 @@ class _Citizen(CitizenAnniversary, CitizenCompanies, CitizenLeaderBoard,
|
||||
|
||||
def state_update_repeater(self):
|
||||
try:
|
||||
start_time = self.now.replace(second=0, microsecond=0)
|
||||
if start_time.minute <= 30:
|
||||
start_time = start_time.replace(minute=30)
|
||||
else:
|
||||
start_time = utils.good_timedelta(start_time.replace(minute=0), timedelta(hours=1))
|
||||
start_time = self.now.replace(minute=(self.now.minute // 10) * 10, second=0, microsecond=0)
|
||||
if not self.restricted_ip:
|
||||
if start_time.minute <= 30:
|
||||
start_time = start_time.replace(minute=30)
|
||||
else:
|
||||
start_time = utils.good_timedelta(start_time.replace(minute=0), timedelta(hours=1))
|
||||
while not self.stop_threads.is_set():
|
||||
start_time = utils.good_timedelta(start_time, timedelta(minutes=30))
|
||||
start_time = utils.good_timedelta(start_time, timedelta(minutes=10 if self.restricted_ip else 30))
|
||||
self.update_citizen_info()
|
||||
self.update_weekly_challenge()
|
||||
self.send_state_update()
|
||||
|
@ -3,7 +3,7 @@ import hashlib
|
||||
import threading
|
||||
import weakref
|
||||
from decimal import Decimal
|
||||
from typing import Any, Dict, Generator, Iterable, List, NamedTuple, NoReturn, Tuple, Union
|
||||
from typing import Any, Dict, Generator, Iterable, List, NamedTuple, NoReturn, Union
|
||||
|
||||
from requests import Response, Session, post
|
||||
|
||||
@ -670,11 +670,14 @@ class Reporter:
|
||||
except: # noqa
|
||||
return []
|
||||
|
||||
def fetch_tasks(self) -> List[Union[str, Tuple[Any]]]:
|
||||
def fetch_tasks(self) -> List[Dict[str, Any]]:
|
||||
try:
|
||||
task_response = self._req.get(f'{self.url}/api/v1/command',
|
||||
params=dict(citizen=self.citizen_id, key=self.key))
|
||||
return task_response.json().get('task_collection')
|
||||
task_response = self._req.post(
|
||||
f'{self.url}/api/v1/command', data=dict(citizen=self.citizen_id, key=self.key)).json()
|
||||
if task_response.get('status'):
|
||||
return task_response.get('data')
|
||||
else:
|
||||
return []
|
||||
except: # noqa
|
||||
return []
|
||||
|
||||
|
Loading…
x
Reference in New Issue
Block a user