diff --git a/erepublik/citizen.py b/erepublik/citizen.py index 3daa4f5..fd0eaf4 100644 --- a/erepublik/citizen.py +++ b/erepublik/citizen.py @@ -144,7 +144,6 @@ class Citizen(CitizenAPI): return html = resp.text - self.check_for_new_medals(html) re_token = re.search(r'var csrfToken = \'(\w{32})\'', html) re_login_token = re.search(r'', html) if re_token: @@ -219,8 +218,6 @@ class Citizen(CitizenAPI): if self._errors_in_response(response): self.get_csrf_token() self.get(url, **kwargs) - else: - self.check_for_new_medals(response.text) self.r = response return response @@ -258,40 +255,38 @@ class Citizen(CitizenAPI): elif json: json.update({"_token": self.token}) response = self.post(url, data=data, json=json, **kwargs) - else: - self.check_for_new_medals(response.text) self.r = response return response - def check_for_new_medals(self, html: str): - new_medals = re.findall(r'(
Congratulations, you have reached experience level (\d+)
", html) - if levelup: - level = levelup.group(1) - msg = f"Level up! Current level {level}" - self.write_log(msg) - self.telegram.report_medal(f"Level *{level}*") - self.reporter.report_action("LEVEL_UP", value=level) + # levelup = re.search(r"Congratulations, you have reached experience level (\d+)
", html) + # if levelup: + # level = levelup.group(1) + # msg = f"Level up! Current level {level}" + # self.write_log(msg) + # self.telegram.report_medal(f"Level *{level}*") + # self.reporter.report_action("LEVEL_UP", value=level) def update_all(self, force_update=False): # Do full update max every 5 min @@ -324,12 +319,14 @@ class Citizen(CitizenAPI): self.update_money() self.update_weekly_challenge() self.send_state_update() + self.check_for_new_medals() def update_citizen_info(self, html: str = None): """ Gets main page and updates most information about player """ if html is None: + self.check_for_new_medals() self._get_main() return ugly_js = re.search(r'"promotions":\s*(\[{?.*?}?])', html).group(1) diff --git a/erepublik/classes.py b/erepublik/classes.py index 06c91b7..2f6c8a1 100644 --- a/erepublik/classes.py +++ b/erepublik/classes.py @@ -524,9 +524,12 @@ Class for unifying eRepublik known endpoints and their required/optional paramet def _get_main_citizen_profile_json(self, player_id: int) -> Response: return self.get("{}/main/citizen-profile-json/{}".format(self.url, player_id)) - def _get_main_citizen_daily_assistant(self) -> Response: + def _get_main_citizen_notifications(self) -> Response: return self.get("{}/main/citizenDailyAssistant".format(self.url)) + def _get_main_citizen_daily_assistant(self) -> Response: + return self.get("{}/main/citizenNotifications".format(self.url)) + def _get_main_city_data_residents(self, city: int, page: int = 1, params: Mapping[str, Any] = None) -> Response: if params is None: params = {} @@ -673,6 +676,10 @@ Class for unifying eRepublik known endpoints and their required/optional paramet data = dict(_token=self.token, articleId=article_id, amount=amount) return self.post("{}/main/donate-article".format(self.url), data=data) + def _post_main_global_alerts_close(self, alert_id: int) -> Response: + data = dict(_token=self.token, alert_id=alert_id) + return self.post("{}/main/global-alerts/close".format(self.url), data=data) + def _post_delete_message(self, msg_id: list) -> Response: data = {"_token": self.token, "delete_message[]": msg_id} return self.post("{}/main/messages-delete".format(self.url), data)