randydev commited on
Commit
140484b
·
verified ·
1 Parent(s): 1187bdc

Update akn/utils/expired_bot.py

Browse files
Files changed (1) hide show
  1. akn/utils/expired_bot.py +5 -6
akn/utils/expired_bot.py CHANGED
@@ -26,22 +26,21 @@ async def watch_do_time(user_id, client, assistant):
26
  while True:
27
  now = dt.now(timezone("Asia/Jakarta"))
28
  time = now.strftime("%d-%m-%Y")
29
- clock = now.strftime("%H:%M:%S")
30
 
31
  exp = await db.get_expired_date(user_id)
32
  if exp is None:
33
  await asyncio.sleep(30)
34
  continue
35
-
36
  expired_on = exp.get("expire_date")
37
- if expired_on is None:
38
  await asyncio.sleep(30)
39
  continue
40
 
41
  expired_on = expired_on.strftime("%d-%m-%Y")
42
- LOGS.info(expired_on)
43
 
44
- if time == expired_on:
45
  await client.log_out()
46
  await assistant.send_message(
47
  exp.get("user_id", user_id),
@@ -54,4 +53,4 @@ async def watch_do_time(user_id, client, assistant):
54
  LOGS.info(f"bot {exp.get('username', 'UnknownBot')} has expired")
55
  break
56
  else:
57
- await asyncio.sleep(30)
 
26
  while True:
27
  now = dt.now(timezone("Asia/Jakarta"))
28
  time = now.strftime("%d-%m-%Y")
 
29
 
30
  exp = await db.get_expired_date(user_id)
31
  if exp is None:
32
  await asyncio.sleep(30)
33
  continue
34
+
35
  expired_on = exp.get("expire_date")
36
+ if expired_on is None:
37
  await asyncio.sleep(30)
38
  continue
39
 
40
  expired_on = expired_on.strftime("%d-%m-%Y")
41
+ LOGS.info(f"Expiration date for user {user_id}: {expired_on}")
42
 
43
+ if now >= expired_on:
44
  await client.log_out()
45
  await assistant.send_message(
46
  exp.get("user_id", user_id),
 
53
  LOGS.info(f"bot {exp.get('username', 'UnknownBot')} has expired")
54
  break
55
  else:
56
+ await asyncio.sleep(30)