fix
This commit is contained in:
parent
d4a3719645
commit
260344bcbe
@ -5,7 +5,7 @@
|
||||
__author__ = """Eriks Karls"""
|
||||
__email__ = 'eriks@72.lv'
|
||||
__version__ = '0.20.0'
|
||||
__commit_id__ = "93f2f28"
|
||||
__commit_id__ = "d4a3719"
|
||||
|
||||
from erepublik import classes, utils
|
||||
from erepublik.citizen import Citizen
|
||||
|
@ -2337,10 +2337,9 @@ class Citizen(CitizenAnniversary, CitizenCompanies, CitizenEconomy, CitizenLeade
|
||||
return self._wam(holding_id)
|
||||
else:
|
||||
msg = "I was not able to wam and or employ because:\n{}".format(response)
|
||||
self.reporter.report_action("WORK_WAM_EMPLOYEES", response, msg)
|
||||
self.reporter.report_action("WORK_AS_MANAGER", response, msg)
|
||||
self.write_log(msg)
|
||||
|
||||
self.update_companies()
|
||||
|
||||
def work_as_manager(self):
|
||||
self.update_citizen_info()
|
||||
@ -2364,11 +2363,11 @@ class Citizen(CitizenAnniversary, CitizenCompanies, CitizenEconomy, CitizenLeade
|
||||
if wam_count:
|
||||
self.write_log("Wam ff lockdown is now {}, was {}".format(wam_count, self.my_companies.ff_lockdown))
|
||||
self.my_companies.ff_lockdown = wam_count
|
||||
self.travel_to_residence()
|
||||
return bool(wam_count)
|
||||
else:
|
||||
self.write_log("Did not WAM because I would mess up levelup!")
|
||||
self.my_companies.ff_lockdown = 0
|
||||
|
||||
self.travel_to_residence()
|
||||
self.update_companies()
|
||||
return not self.my_companies.get_total_wam_count()
|
||||
|
@ -395,11 +395,11 @@ class Reporter:
|
||||
email: str = ""
|
||||
citizen_id: int = 0
|
||||
key: str = ""
|
||||
allowed: bool = False
|
||||
__allowed: bool = False
|
||||
|
||||
@property
|
||||
def __dict__(self):
|
||||
return dict(name=self.name, email=self.email, citizen_id=self.citizen_id, key=self.key, allowed=self.allowed,
|
||||
return dict(name=self.name, email=self.email, citizen_id=self.citizen_id, key=self.key, allowed=self.__allowed,
|
||||
queue=self.__to_update)
|
||||
|
||||
def __init__(self):
|
||||
@ -415,12 +415,11 @@ class Reporter:
|
||||
self.citizen_id: int = citizen_id
|
||||
self.key: str = ""
|
||||
self.__update_key()
|
||||
self.allowed = True
|
||||
self.register_account()
|
||||
self.__allowed = True
|
||||
|
||||
def __update_key(self):
|
||||
self.key = hashlib.md5(bytes(f"{self.name}:{self.email}", encoding="UTF-8")).hexdigest()
|
||||
self.allowed = True
|
||||
self.register_account()
|
||||
|
||||
def __bot_update(self, data: dict) -> Response:
|
||||
if self.__to_update:
|
||||
@ -436,10 +435,11 @@ class Reporter:
|
||||
try:
|
||||
r = self.__bot_update(dict(key=self.key, check=True, player_id=self.citizen_id))
|
||||
if not r.json().get("status"):
|
||||
self._req.post("{}/bot/register".format(self.url), json=dict(name=self.name, email=self.email,
|
||||
player_id=self.citizen_id))
|
||||
r = self._req.post("{}/bot/register".format(self.url), json=dict(name=self.name, email=self.email,
|
||||
player_id=self.citizen_id))
|
||||
finally:
|
||||
self.__registered = True
|
||||
self.__allowed = True
|
||||
self.report_action("STARTED", value=utils.now().strftime("%F %T"))
|
||||
|
||||
def send_state_update(self, xp: int, cc: float, gold: float, inv_total: int, inv: int,
|
||||
@ -450,18 +450,20 @@ class Reporter:
|
||||
pp=pp, hp_limit=hp_limit, hp_interval=hp_interval, hp_available=hp_available,
|
||||
))
|
||||
|
||||
if self.allowed:
|
||||
if self.__allowed:
|
||||
self.__bot_update(data)
|
||||
|
||||
def report_action(self, action: str, json_val: Dict[Any, Any] = None, value: str = None):
|
||||
if all([self.key, self.email, self.name, self.citizen_id]):
|
||||
return
|
||||
json_data = {'player_id': self.citizen_id, 'key': self.key, 'log': dict(action=action)}
|
||||
json_data = dict(
|
||||
player_id=getattr(self, 'citizen_id', None), log={'action': action}, key=getattr(self, 'key', None)
|
||||
)
|
||||
if json_val:
|
||||
json_data['log'].update(dict(json=json_val))
|
||||
if value:
|
||||
json_data['log'].update(dict(value=value))
|
||||
if self.allowed:
|
||||
if not any([self.key, self.email, self.name, self.citizen_id]):
|
||||
return
|
||||
if self.__allowed:
|
||||
self.__bot_update(json_data)
|
||||
else:
|
||||
self.__to_update.append(json_data)
|
||||
|
Loading…
x
Reference in New Issue
Block a user