|
|
@ -9,6 +9,7 @@ import ws |
|
|
|
class CustomAlerts(Alert): |
|
|
|
backend: BackendClient |
|
|
|
prices = {} |
|
|
|
original_prices = {} |
|
|
|
|
|
|
|
convert_map = { |
|
|
|
"month":30*24*60*60, |
|
|
@ -37,7 +38,11 @@ class CustomAlerts(Alert): |
|
|
|
|
|
|
|
money = event.amount |
|
|
|
uid = event.id |
|
|
|
seconds = self.price_checker(money) |
|
|
|
if event.additional_data.get('is_commission_covered', 0): |
|
|
|
seconds = self.price_checker(money, False) |
|
|
|
else: |
|
|
|
seconds = self.price_checker(money, True) |
|
|
|
|
|
|
|
if seconds == 0: |
|
|
|
warning(f"[{uid}] so smol donate {money} RUB") |
|
|
|
|
|
|
@ -63,19 +68,26 @@ class CustomAlerts(Alert): |
|
|
|
|
|
|
|
def update_prices(self, prices): |
|
|
|
self.prices = {} |
|
|
|
self.original_prices = {} |
|
|
|
for price in prices: |
|
|
|
if price["money_price"] == 0: |
|
|
|
continue |
|
|
|
self.prices.update({float(price["money_price"]) + float(price["money_price"] * price["da_percent"] / 100):self.convert_map[price['period']]}) |
|
|
|
self.original_prices.update({float(price["money_price"]):self.convert_map[price['period']]}) |
|
|
|
if not self.prices: |
|
|
|
error("cannot get prices from server") |
|
|
|
sys.exit(228) |
|
|
|
|
|
|
|
def price_checker(self, amount): |
|
|
|
def price_checker(self, amount, original = False): |
|
|
|
seconds2give = 0 |
|
|
|
for rub, sec in self.prices.items(): |
|
|
|
if amount >= rub and seconds2give <= sec: |
|
|
|
seconds2give = sec |
|
|
|
if original: |
|
|
|
for rub, sec in self.original_prices.items(): |
|
|
|
if amount >= rub and seconds2give <= sec: |
|
|
|
seconds2give = sec |
|
|
|
else: |
|
|
|
for rub, sec in self.prices.items(): |
|
|
|
if amount >= rub and seconds2give <= sec: |
|
|
|
seconds2give = sec |
|
|
|
return seconds2give |
|
|
|
|
|
|
|
if __name__ == "__main__": |
|
|
|