From d3cda1d1cd64d76c22523a96f0ded60154e7f0ef Mon Sep 17 00:00:00 2001 From: gsd Date: Mon, 1 Apr 2024 23:39:42 +0300 Subject: [PATCH] commision fix --- paybot.facti13.py | 22 +++++++++++++++++----- 1 file changed, 17 insertions(+), 5 deletions(-) diff --git a/paybot.facti13.py b/paybot.facti13.py index 24b69c6..7e9867f 100644 --- a/paybot.facti13.py +++ b/paybot.facti13.py @@ -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__":