Less intrusive reporting
This commit is contained in:
parent
b760a2f66c
commit
ac4fc9baab
@ -5,7 +5,7 @@
|
|||||||
__author__ = """Eriks Karls"""
|
__author__ = """Eriks Karls"""
|
||||||
__email__ = 'eriks@72.lv'
|
__email__ = 'eriks@72.lv'
|
||||||
__version__ = '0.20.0'
|
__version__ = '0.20.0'
|
||||||
__commit_id__ = "5c47b70"
|
__commit_id__ = "b760a2f"
|
||||||
|
|
||||||
from erepublik import classes, utils
|
from erepublik import classes, utils
|
||||||
from erepublik.citizen import Citizen
|
from erepublik.citizen import Citizen
|
||||||
|
@ -394,11 +394,11 @@ class Reporter:
|
|||||||
email: str = ""
|
email: str = ""
|
||||||
citizen_id: int = 0
|
citizen_id: int = 0
|
||||||
key: str = ""
|
key: str = ""
|
||||||
__allowed: bool = False
|
allowed: bool = False
|
||||||
|
|
||||||
@property
|
@property
|
||||||
def __dict__(self):
|
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)
|
queue=self.__to_update)
|
||||||
|
|
||||||
def __init__(self):
|
def __init__(self):
|
||||||
@ -415,7 +415,7 @@ class Reporter:
|
|||||||
self.key: str = ""
|
self.key: str = ""
|
||||||
self.__update_key()
|
self.__update_key()
|
||||||
self.register_account()
|
self.register_account()
|
||||||
self.__allowed = True
|
self.allowed = True
|
||||||
|
|
||||||
def __update_key(self):
|
def __update_key(self):
|
||||||
self.key = hashlib.md5(bytes(f"{self.name}:{self.email}", encoding="UTF-8")).hexdigest()
|
self.key = hashlib.md5(bytes(f"{self.name}:{self.email}", encoding="UTF-8")).hexdigest()
|
||||||
@ -438,7 +438,7 @@ class Reporter:
|
|||||||
player_id=self.citizen_id))
|
player_id=self.citizen_id))
|
||||||
finally:
|
finally:
|
||||||
self.__registered = True
|
self.__registered = True
|
||||||
self.__allowed = True
|
self.allowed = True
|
||||||
self.report_action("STARTED", value=utils.now().strftime("%F %T"))
|
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,
|
def send_state_update(self, xp: int, cc: float, gold: float, inv_total: int, inv: int,
|
||||||
@ -449,7 +449,7 @@ class Reporter:
|
|||||||
pp=pp, hp_limit=hp_limit, hp_interval=hp_interval, hp_available=hp_available,
|
pp=pp, hp_limit=hp_limit, hp_interval=hp_interval, hp_available=hp_available,
|
||||||
))
|
))
|
||||||
|
|
||||||
if self.__allowed:
|
if self.allowed:
|
||||||
self.__bot_update(data)
|
self.__bot_update(data)
|
||||||
|
|
||||||
def report_action(self, action: str, json_val: Dict[Any, Any] = None, value: str = None):
|
def report_action(self, action: str, json_val: Dict[Any, Any] = None, value: str = None):
|
||||||
@ -462,7 +462,7 @@ class Reporter:
|
|||||||
json_data['log'].update(dict(value=value))
|
json_data['log'].update(dict(value=value))
|
||||||
if not any([self.key, self.email, self.name, self.citizen_id]):
|
if not any([self.key, self.email, self.name, self.citizen_id]):
|
||||||
return
|
return
|
||||||
if self.__allowed:
|
if self.allowed:
|
||||||
self.__bot_update(json_data)
|
self.__bot_update(json_data)
|
||||||
else:
|
else:
|
||||||
self.__to_update.append(json_data)
|
self.__to_update.append(json_data)
|
||||||
|
Loading…
x
Reference in New Issue
Block a user