From d2e60968ecf82287dafef47224b5394dd40794ad Mon Sep 17 00:00:00 2001 From: salko-ua Date: Wed, 5 Jun 2024 14:14:14 +0300 Subject: [PATCH] debug add subs --- control_db/premium_user.py | 12 ++++++++---- 1 file changed, 8 insertions(+), 4 deletions(-) diff --git a/control_db/premium_user.py b/control_db/premium_user.py index 3a661f7..a2067a3 100644 --- a/control_db/premium_user.py +++ b/control_db/premium_user.py @@ -3,7 +3,7 @@ from aiosqlite import Row from dateutil.relativedelta import relativedelta - +from control_db import Database from control_db.create_db import BaseDBPart @@ -88,6 +88,7 @@ async def delete_premium_user(self, telegram_id): await self.base.commit() async def add_premium_user(self, telegram_id): + db = await Database.setup() telegram_id_exists = await ( await self.cur.execute( """SELECT COUNT(`telegram_id`) FROM `premium_user` WHERE telegram_id = ?""", @@ -121,9 +122,12 @@ async def add_premium_user(self, telegram_id): ) return await self.base.commit() - continue_data = ( - datetime.strptime(expiration_date[0][0], "%d.%m.%Y") + relativedelta(months=1) - ).strftime("%d.%m.%Y") + if await db.is_premium_user(telegram_id): + continue_data = ( + datetime.strptime(expiration_date[0][0], "%d.%m.%Y") + relativedelta(months=1) + ).strftime("%d.%m.%Y") + else: + continue_data = (datetime.now() + relativedelta(months=1)).strftime("%d.%m.%Y") await self.cur.execute( """UPDATE premium_user SET is_premium = ?, expiration_date = ?, bought_premium = ?, date_purchase = ?