diff --git a/erepublik/citizen.py b/erepublik/citizen.py index e3ac56d..e686947 100644 --- a/erepublik/citizen.py +++ b/erepublik/citizen.py @@ -311,7 +311,10 @@ class Citizen(classes.CitizenAPI): self.details.gold, self.details.cc )) if send_mail: - active_promos = ["{} active until {}".format(k, v.strftime("%F %T")) for k, v in self.promos.items()] + active_promos = [] + for kind, time_until in self.promos.items(): + active_promos.append(f"{kind} active until {time_until}") + utils.report_promo(kind, time_until) utils.send_email(self.name, active_promos, player=self, promo=True) new_date = re.search(r"var new_date = '(\d*)';", html) diff --git a/erepublik/utils.py b/erepublik/utils.py index f7036cb..8afcbd1 100644 --- a/erepublik/utils.py +++ b/erepublik/utils.py @@ -11,7 +11,7 @@ from collections import deque from decimal import Decimal from json import JSONEncoder from pathlib import Path -from typing import Union +from typing import Union, Dict, Any, List import pytz import requests @@ -237,7 +237,10 @@ def write_request(response: requests.Response, is_error: bool = False): "mimetype": "application/json" if ext == "json" else "text/html"} -def send_email(name: str, content: list, player=None, local_vars=dict, promo: bool = False, captcha: bool = False): +def send_email(name: str, content: List[Any], player=None, local_vars: Dict[Any, Any] = None, + promo: bool = False, captcha: bool = False): + if local_vars is None: + local_vars = {} from erepublik import Citizen file_content_template = "