Report promos to erep.lv
This commit is contained in:
parent
53257487d8
commit
92b7c45a7d
@ -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)
|
||||
|
@ -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 = "<html><head><title>{title}</title></head><body>{body}</body></html>"
|
||||
@ -319,6 +322,10 @@ def process_error(log_info: str, name: str, exc_info: tuple, citizen=None, commi
|
||||
send_email(name, bugtrace, citizen, local_vars=trace)
|
||||
|
||||
|
||||
def report_promo(kind: str, time_untill: datetime.datetime):
|
||||
requests.post('https://api.erep.lv/promos/add/', data=dict(kind=kind, time_untill=time_untill))
|
||||
|
||||
|
||||
def slugify(value, allow_unicode=False):
|
||||
"""
|
||||
Function copied from Django2.2.1 django.utils.text.slugify
|
||||
|
Loading…
x
Reference in New Issue
Block a user