Skip to content

Commit

Permalink
debug add subs
Browse files Browse the repository at this point in the history
  • Loading branch information
salko-ua committed Jun 5, 2024
1 parent c8de37b commit d2e6096
Showing 1 changed file with 8 additions and 4 deletions.
12 changes: 8 additions & 4 deletions control_db/premium_user.py
Original file line number Diff line number Diff line change
Expand Up @@ -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


Expand Down Expand Up @@ -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 = ?""",
Expand Down Expand Up @@ -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 = ?
Expand Down

0 comments on commit d2e6096

Please sign in to comment.