yeref 0.29.26__py3-none-any.whl → 0.29.27__py3-none-any.whl

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
yeref/yeref.py CHANGED
@@ -7740,98 +7740,6 @@ async def check_webapp_hash(init_data, TOKEN_BOT, BOT_TOKEN_MAIN=None, extra=Non
7740
7740
  return result
7741
7741
 
7742
7742
 
7743
- async def get_vars_web_main(chat_id, username, full_name, lc, is_premium, utm_web, BASE_P, BOT_TOKEN_E18B):
7744
- is_paid = False
7745
- till_paid = ''
7746
- lz = 'en'
7747
- try:
7748
- dt = lz = utm = None
7749
- pays = []
7750
-
7751
- sql = "SELECT USER_TID, USER_LZ, USER_DT, USER_UTM, USER_PAY FROM \"USER\" WHERE USER_TID=$1"
7752
- data_user = await db_select_pg(sql, (chat_id,), BASE_P)
7753
- if len(data_user): USER_TID, lz, dt, utm, pays = data_user[0]
7754
-
7755
- if not dt:
7756
- dt = datetime.now(timezone.utc).strftime('%d-%m-%Y_%H-%M-%S')
7757
- if not utm:
7758
- utm = utm_web
7759
- if not lz:
7760
- if lc in ['zh', 'zh-chs', 'zh-cht', 'ja', 'ko', 'zh-CN', 'zh-TW', 'th', 'vi', 'tw', 'sg']:
7761
- lz = 'zh'
7762
- # arabic # ir, af
7763
- elif lc in ['ar-XA', 'ar', 'tr', 'ur', 'fa', 'tj', 'dz', 'eg', 'iq', 'sy', 'ae', 'sa', 'tn', 'ir', 'af']:
7764
- lz = 'ar'
7765
- # spanish # portugal: 'pt', 'br', 'ao', 'mz'
7766
- elif lc in ['es', 'ar', 'cl', 'co', 'cu', 've', 'bo', 'pe', 'ec', 'pt', 'br', 'ao', 'mz']:
7767
- lz = 'es'
7768
- # french
7769
- elif lc in ['fr', 'ch', 'be', 'ca']:
7770
- lz = 'fr'
7771
- # europe
7772
- elif lc in ['ru', 'kz', 'kg', 'uz', 'tm', 'md', 'am', 'uk-UA', 'uk', 'kk', 'tk', 'ky']:
7773
- lz = 'ru'
7774
- else:
7775
- lz = 'en'
7776
-
7777
- if utm_web not in ['@FereyPostBot', '']:
7778
- sql = """
7779
- INSERT INTO "USER" (USER_TID, USER_USERNAME, USER_FULLNAME, USER_LZ, USER_LC, USER_UTM, USER_ISPREMIUM, USER_DT)
7780
- VALUES ($1, $2, $3, $4, $5, $6, $7, $8)
7781
- ON CONFLICT (USER_TID)
7782
- DO UPDATE SET
7783
- USER_USERNAME = EXCLUDED.USER_USERNAME,
7784
- USER_FULLNAME = EXCLUDED.USER_FULLNAME,
7785
- USER_LZ = EXCLUDED.USER_LZ,
7786
- USER_LC = EXCLUDED.USER_LC,
7787
- USER_UTM = EXCLUDED.USER_UTM,
7788
- USER_ISPREMIUM = EXCLUDED.USER_ISPREMIUM,
7789
- USER_DT = EXCLUDED.USER_DT
7790
- """
7791
- await db_change_pg(sql, (chat_id, username, full_name, lz, lc, utm, is_premium, dt,), BASE_P)
7792
-
7793
- try:
7794
- print(f"{pays=}")
7795
- if not pays: pays = '[]'
7796
- pays = json.loads(pays)
7797
- except Exception as e:
7798
- logger.info(log_ % str(e))
7799
- pays = []
7800
-
7801
- print(f"{pays=}")
7802
- for pay in pays:
7803
- try:
7804
- if not (pay.get('TYPE', '') == 'SUB' and pay.get('DT_END', '')): continue
7805
- DT_END = datetime.strptime(pay.get('DT_END'), '%d-%m-%Y_%H-%M-%S').replace(tzinfo=timezone.utc)
7806
- print(f"{DT_END=}")
7807
- if datetime.now(timezone.utc) <= DT_END:
7808
- is_paid = True
7809
- till_paid = DT_END.strftime('%d.%m.%Y')
7810
- except Exception as e:
7811
- logger.info(log_ % str(e))
7812
- pass
7813
-
7814
- if not is_paid:
7815
- extra_bot = None
7816
- try:
7817
- lib_id = channel_library_ru if lz == 'ru' else channel_library_en
7818
- print(f"{channel_library_ru=}, {channel_library_en=}")
7819
- extra_bot = Bot(token=BOT_TOKEN_E18B)
7820
- member_ = await extra_bot.get_chat_member(chat_id=lib_id, user_id=chat_id)
7821
- if member_.status in ['member', 'administrator', 'creator']: is_paid = True
7822
- except Exception as e:
7823
- logger.info(log_ % str(e))
7824
- finally:
7825
- if extra_bot: await extra_bot.session.close()
7826
- except TelegramRetryAfter as e:
7827
- logger.info(log_ % f"TelegramRetryAfter {e.retry_after}")
7828
- await asyncio.sleep(e.retry_after + 1)
7829
- except Exception as e:
7830
- logger.info(log_ % str(e))
7831
- await asyncio.sleep(round(random.uniform(0, 1), 2))
7832
- return is_paid, till_paid, lz
7833
-
7834
-
7835
7743
  async def upd_user_data_main(data, web_app_init_data, BASE_P, BOT_TOKEN_E18B, req_url='', utm=''):
7836
7744
  chat_id = int(web_app_init_data.get('user', {}).get('id'))
7837
7745
  username = web_app_init_data.get('user', {}).get('username', None)
@@ -7845,7 +7753,7 @@ async def upd_user_data_main(data, web_app_init_data, BASE_P, BOT_TOKEN_E18B, re
7845
7753
  page = data.get('page', '')
7846
7754
  connectedAddress = data.get('connectedAddress', '')
7847
7755
  USER_TID = chat_id
7848
- USER_HID = USER_LZ = USER_DT = None
7756
+ USER_HID = USER_LZ = None
7849
7757
  USER_VARS = json.loads(USER_VARS_)
7850
7758
  USER_LSTS = json.loads(USER_LSTS_)
7851
7759
  USER_GAMES = {}
@@ -7885,8 +7793,8 @@ async def upd_user_data_main(data, web_app_init_data, BASE_P, BOT_TOKEN_E18B, re
7885
7793
  elif lc in ['ru', 'kz', 'kg', 'uz', 'tm', 'md', 'am', 'uk-UA', 'uk', 'kk', 'tk', 'ky']:
7886
7794
  lz = 'ru'
7887
7795
  USER_LZ = lz
7888
- if not USER_DT:
7889
- USER_VARS['USER_DT'] = USER_DT = datetime.now(timezone.utc).strftime("%d-%m-%Y_%H-%M-%S")
7796
+ if not USER_VARS.get('USER_DT', None):
7797
+ USER_VARS['USER_DT'] = USER_DT.strftime("%d-%m-%Y_%H-%M-%S")
7890
7798
  USER_HID = hashlib.blake2b(f"{'tid'}-{chat_id}".encode('utf-8'), digest_size=4).hexdigest()
7891
7799
  if utm: USER_VARS['USER_UTM'] = utm
7892
7800
 
@@ -7954,9 +7862,9 @@ async def upd_user_data_main(data, web_app_init_data, BASE_P, BOT_TOKEN_E18B, re
7954
7862
  sql = f"""
7955
7863
  INSERT INTO \"USER\" (
7956
7864
  USER_TID, USER_HID, USER_USERNAME, USER_FULLNAME, USER_ISPREMIUM,
7957
- USER_LZ, USER_DT, USER_GAMES, USER_VARS, USER_LSTS
7865
+ USER_LZ, USER_GAMES, USER_VARS, USER_LSTS
7958
7866
  )
7959
- VALUES ($1, $2, $3, $4, $5, $6, $7, $8, $9, $10)
7867
+ VALUES ($1, $2, $3, $4, $5, $6, $7, $8, $9)
7960
7868
  ON CONFLICT (USER_TID) DO UPDATE
7961
7869
  SET
7962
7870
  USER_HID = EXCLUDED.USER_HID,
@@ -7964,13 +7872,12 @@ async def upd_user_data_main(data, web_app_init_data, BASE_P, BOT_TOKEN_E18B, re
7964
7872
  USER_FULLNAME = EXCLUDED.USER_FULLNAME,
7965
7873
  USER_ISPREMIUM = EXCLUDED.USER_ISPREMIUM,
7966
7874
  USER_LZ = EXCLUDED.USER_LZ,
7967
- USER_DT = EXCLUDED.USER_DT,
7968
7875
 
7969
7876
  USER_GAMES = EXCLUDED.USER_GAMES,
7970
7877
  USER_VARS = EXCLUDED.USER_VARS,
7971
7878
  USER_LSTS = EXCLUDED.USER_LSTS
7972
7879
  """
7973
- await db_change_pg(sql, (USER_TID, USER_HID, username, full_name, is_premium, USER_LZ, USER_DT,
7880
+ await db_change_pg(sql, (USER_TID, USER_HID, username, full_name, is_premium, USER_LZ,
7974
7881
  json.dumps(USER_GAMES, ensure_ascii=False),
7975
7882
  json.dumps(USER_VARS, ensure_ascii=False),
7976
7883
  json.dumps(USER_LSTS, ensure_ascii=False),), BASE_P)
@@ -7994,7 +7901,7 @@ async def upd_user_data(ENT_TID, data, web_app_init_data, PROJECT_USERNAME, BASE
7994
7901
  page = data.get('page', '')
7995
7902
  connectedAddress = data.get('connectedAddress', '')
7996
7903
  USER_TID = chat_id
7997
- USER_HID = USER_LZ = USER_DT = None
7904
+ USER_HID = USER_LZ = None
7998
7905
  USER_VARS = json.loads(USER_VARS_)
7999
7906
  USER_LSTS = json.loads(USER_LSTS_)
8000
7907
  USER_GAMES = {}
@@ -8043,7 +7950,8 @@ async def upd_user_data(ENT_TID, data, web_app_init_data, PROJECT_USERNAME, BASE
8043
7950
  elif lc in ['ru', 'kz', 'kg', 'uz', 'tm', 'md', 'am', 'uk-UA', 'uk', 'kk', 'tk', 'ky']:
8044
7951
  lz = 'ru'
8045
7952
  USER_LZ = lz
8046
- if not USER_DT: USER_VARS['USER_DT'] = USER_DT = datetime.now(timezone.utc).strftime("%d-%m-%Y_%H-%M-%S")
7953
+ if not USER_VARS.get('USER_DT', None):
7954
+ USER_VARS['USER_DT'] = USER_DT.strftime("%d-%m-%Y_%H-%M-%S")
8047
7955
  if not USER_HID: USER_HID = hashlib.blake2b(f"{tid}-{chat_id}".encode('utf-8'), digest_size=4).hexdigest()
8048
7956
 
8049
7957
  now = datetime.now(timezone.utc)
@@ -8080,9 +7988,9 @@ async def upd_user_data(ENT_TID, data, web_app_init_data, PROJECT_USERNAME, BASE
8080
7988
  sql = f"""
8081
7989
  INSERT INTO {schema_name}_{tid}.USER (
8082
7990
  USER_TID, USER_HID, USER_USERNAME, USER_FULLNAME, USER_ISPREMIUM,
8083
- USER_LZ, USER_DT, USER_GAMES, USER_VARS, USER_LSTS
7991
+ USER_LZ, USER_GAMES, USER_VARS, USER_LSTS
8084
7992
  )
8085
- VALUES ($1, $2, $3, $4, $5, $6, $7, $8, $9, $10)
7993
+ VALUES ($1, $2, $3, $4, $5, $6, $7, $8, $9)
8086
7994
  ON CONFLICT (USER_TID) DO UPDATE
8087
7995
  SET
8088
7996
  USER_HID = EXCLUDED.USER_HID,
@@ -8090,13 +7998,12 @@ async def upd_user_data(ENT_TID, data, web_app_init_data, PROJECT_USERNAME, BASE
8090
7998
  USER_FULLNAME = EXCLUDED.USER_FULLNAME,
8091
7999
  USER_ISPREMIUM = EXCLUDED.USER_ISPREMIUM,
8092
8000
  USER_LZ = EXCLUDED.USER_LZ,
8093
- USER_DT = EXCLUDED.USER_DT,
8094
8001
 
8095
8002
  USER_GAMES = EXCLUDED.USER_GAMES,
8096
8003
  USER_VARS = EXCLUDED.USER_VARS,
8097
8004
  USER_LSTS = EXCLUDED.USER_LSTS
8098
8005
  """
8099
- await db_change_pg(sql, (USER_TID, USER_HID, username, full_name, is_premium, USER_LZ, USER_DT,
8006
+ await db_change_pg(sql, (USER_TID, USER_HID, username, full_name, is_premium, USER_LZ,
8100
8007
  json.dumps(USER_GAMES, ensure_ascii=False),
8101
8008
  json.dumps(USER_VARS, ensure_ascii=False),
8102
8009
  json.dumps(USER_LSTS, ensure_ascii=False),), BASE_P)
@@ -8468,7 +8375,6 @@ async def check_sub_pay(chat_id, lz, BOT_TOKEN_E18B, BASE_P):
8468
8375
  USER_ISPAID = 0
8469
8376
  USER_DTPAID = ''
8470
8377
  dt_now = datetime.now(timezone.utc)
8471
- USER_DT = dt_now.strftime('%d-%m-%Y_%H-%M-%S')
8472
8378
  extra_bot = None
8473
8379
  try:
8474
8380
  lib_id = channel_library_ru if lz == 'ru' else channel_library_en
@@ -8481,14 +8387,14 @@ async def check_sub_pay(chat_id, lz, BOT_TOKEN_E18B, BASE_P):
8481
8387
  finally:
8482
8388
  if extra_bot: await extra_bot.session.close()
8483
8389
 
8484
- sql = "SELECT USER_ISPAID, USER_DTPAID, USER_TYPAID, USER_DT, USER_LZ FROM USER WHERE USER_TID=$1"
8390
+ sql = "SELECT USER_ISPAID, USER_DTPAID, USER_TYPAID, USER_LZ FROM USER WHERE USER_TID=$1"
8485
8391
  data_usr = await db_select_pg(sql, (chat_id,), BASE_P)
8486
8392
 
8487
8393
  if not len(data_usr):
8488
- sql = "INSERT INTO USER (USER_TID, USER_DT) VALUES ($1, $2) ON CONFLICT DO NOTHING"
8489
- await db_change_pg(sql, (chat_id, USER_DT,), BASE_P)
8394
+ sql = "INSERT INTO USER (USER_TID) VALUES ($1, $2) ON CONFLICT DO NOTHING"
8395
+ await db_change_pg(sql, (chat_id,), BASE_P)
8490
8396
  else:
8491
- USER_ISPAID, USER_DTPAID, USER_TYPAID, USER_DT, lz = data_usr[0]
8397
+ USER_ISPAID, USER_DTPAID, USER_TYPAID, lz = data_usr[0]
8492
8398
 
8493
8399
  if is_paid:
8494
8400
  sql = "UPDATE USER SET USER_ISPAID=1, USER_DTPAID='', USER_TYPAID='all' WHERE USER_TID=$1"
@@ -8553,8 +8459,8 @@ async def pay_handler_for_all(bot, message, ideas_en, ideas_ru, PROJECT_USERNAME
8553
8459
  data_usr = await db_select_pg(sql, (chat_id,), BASE_P)
8554
8460
  if not len(data_usr):
8555
8461
  dt_ = datetime.now(timezone.utc).strftime('%d-%m-%Y_%H-%M-%S')
8556
- sql = "INSERT INTO \"USER\" (USER_TID, USER_DT) VALUES ($1, $2) ON CONFLICT DO NOTHING"
8557
- await db_change_pg(sql, (chat_id, dt_,), BASE_P)
8462
+ sql = "INSERT INTO \"USER\" (USER_TID) VALUES ($1) ON CONFLICT DO NOTHING"
8463
+ await db_change_pg(sql, (chat_id,), BASE_P)
8558
8464
  USER_LSTS = json.loads(USER_LSTS_)
8559
8465
  USER_VARS = json.loads(USER_VARS_)
8560
8466
  if payload == 'gift': USER_VARS['USER_UTM'] = 'gift'
@@ -8902,6 +8808,7 @@ async def calc_metrics(bot, PROJECT_USERNAME, dataroom_folder_id, EXTRA_D, BASE_
8902
8808
 
8903
8809
  data_users.append((
8904
8810
  random.randint(100000, 999999),
8811
+ entry_dt_obj,
8905
8812
  json.dumps({"USER_WALLET": wallet, "USER_UTM": utm, "USER_DT": entry_dt}),
8906
8813
  json.dumps({"USER_DAU": user_dau, "USER_MAU": user_mau, "USER_TXS": txs,
8907
8814
  "USER_PAYMENTS": payments, "USER_STATUSES": USER_STATUSES})
@@ -9033,7 +8940,6 @@ async def return_activity_metrics(bot, data_users, EXTRA_D, BASE_P, data_ents, s
9033
8940
  USER_LSTS = json.loads(USER_LSTS or "{}")
9034
8941
  USER_WALLET = USER_VARS.get('USER_WALLET', '')
9035
8942
  USER_UTM = USER_VARS.get('USER_UTM', '')
9036
- USER_DT = USER_VARS.get('USER_DT', '')
9037
8943
  USER_DAU = USER_LSTS.get("USER_DAU", [])
9038
8944
  USER_MAU = USER_LSTS.get("USER_MAU", [])
9039
8945
  USER_TXS = USER_LSTS.get("USER_TXS", [])
@@ -9077,11 +8983,9 @@ async def return_activity_metrics(bot, data_users, EXTRA_D, BASE_P, data_ents, s
9077
8983
  month_key = dt_tx.strftime("%Y-%m")
9078
8984
  metrics_by_month[month_key]["pay"] += 1
9079
8985
 
9080
- if USER_DT:
9081
- dt_obj = datetime.strptime(USER_DT, "%d-%m-%Y_%H-%M-%S")
9082
- month_key = dt_obj.strftime("%Y-%m")
9083
- key = "/startapp" if USER_UTM == "/startapp" else "/start"
9084
- metrics_by_month[month_key][key] += 1
8986
+ month_key = USER_DT.strftime("%Y-%m")
8987
+ key = "/startapp" if USER_UTM == "/startapp" else "/start"
8988
+ metrics_by_month[month_key][key] += 1
9085
8989
 
9086
8990
  process_user_rows(data_users)
9087
8991
 
@@ -9137,15 +9041,13 @@ async def return_unit_metrics(bot, data_users, EXTRA_D):
9137
9041
  for USER_TID, USER_VARS, USER_LSTS in data_users:
9138
9042
  USER_VARS = json.loads(USER_VARS or "{}")
9139
9043
  USER_LSTS = json.loads(USER_LSTS or "{}")
9140
- USER_DT = USER_VARS.get("USER_DT", "")
9141
9044
  USER_PAYMENTS = USER_LSTS.get("USER_PAYMENTS", [])
9142
9045
  USER_STATUSES = USER_LSTS.get("USER_STATUSES", [])
9143
9046
 
9144
- if USER_DT:
9145
- mo = datetime.strptime(USER_DT, "%d-%m-%Y_%H-%M-%S").strftime("%Y-%m")
9146
- if (USER_TID, mo) not in seen_new:
9147
- seen_new.add((USER_TID, mo))
9148
- metrics[mo]["new_users"] += 1
9047
+ mo = USER_DT.strftime("%Y-%m")
9048
+ if (USER_TID, mo) not in seen_new:
9049
+ seen_new.add((USER_TID, mo))
9050
+ metrics[mo]["new_users"] += 1
9149
9051
 
9150
9052
  for pay in USER_PAYMENTS:
9151
9053
  dt_p = datetime.strptime(pay.get("DT_START", ""), "%d-%m-%Y_%H-%M-%S")
@@ -9249,13 +9151,12 @@ async def return_cohort_metrics(bot, data_users, EXTRA_D):
9249
9151
  cohorts = defaultdict(set)
9250
9152
  activity_months = defaultdict(set)
9251
9153
 
9252
- for USER_TID, USER_VARS, USER_LSTS in data_users:
9154
+ for USER_TID, USER_DT, USER_VARS, USER_LSTS in data_users:
9253
9155
  USER_VARS = json.loads(USER_VARS or "{}")
9254
9156
  USER_LSTS = json.loads(USER_LSTS or "{}")
9255
- USER_DT = USER_VARS.get("USER_DT", "")
9256
9157
  USER_DAU = USER_LSTS.get("USER_DAU", [])
9257
9158
 
9258
- entry_mo = datetime.strptime(USER_DT, "%d-%m-%Y_%H-%M-%S").strftime("%Y-%m")
9159
+ entry_mo = USER_DT.strftime("%Y-%m")
9259
9160
  cohorts[entry_mo].add(USER_TID)
9260
9161
 
9261
9162
  for day_str in USER_DAU:
@@ -9338,13 +9239,11 @@ async def return_retention_metrics(bot, data_users, EXTRA_D):
9338
9239
  rev_by_cohort = defaultdict(lambda: defaultdict(float))
9339
9240
  cohort_users = defaultdict(set)
9340
9241
 
9341
- for USER_TID, USER_VARS, USER_LSTS in data_users:
9242
+ for USER_TID, USER_DT, USER_VARS, USER_LSTS in data_users:
9342
9243
  USER_VARS = json.loads(USER_VARS or "{}")
9343
9244
  USER_LSTS = json.loads(USER_LSTS or "{}")
9344
- dt_entry_raw = USER_VARS.get("USER_DT", "").split("_")[0]
9345
- if not dt_entry_raw:
9346
- continue
9347
- cohort_mo = datetime.strptime(dt_entry_raw, "%d-%m-%Y").strftime("%Y-%m")
9245
+
9246
+ cohort_mo = USER_DT.strftime("%Y-%m")
9348
9247
  cohort_users[cohort_mo].add(USER_TID)
9349
9248
 
9350
9249
  for pay in USER_LSTS.get("USER_PAYMENTS", []):
@@ -9431,15 +9330,11 @@ async def return_acquisition_retention_metrics(bot, data_users, EXTRA_D):
9431
9330
  user_signup = {}
9432
9331
  user_activity = defaultdict(set)
9433
9332
 
9434
- for USER_TID, USER_VARS, USER_LSTS in data_users:
9333
+ for USER_TID, USER_DT, USER_VARS, USER_LSTS in data_users:
9435
9334
  vars_ = json.loads(USER_VARS or "{}")
9436
9335
  lsts = json.loads(USER_LSTS or "{}")
9437
- dt0_str = vars_.get("USER_DT", "").split("_")[0]
9438
- if not dt0_str:
9439
- print(f"Skip USER_TID={USER_TID}, no signup date")
9440
- continue
9441
- dt0 = datetime.strptime(dt0_str, "%d-%m-%Y")
9442
- user_signup[USER_TID] = dt0
9336
+
9337
+ user_signup[USER_TID] = USER_DT
9443
9338
  for day in lsts.get("USER_DAU", []):
9444
9339
  try:
9445
9340
  d = datetime.strptime(day, "%Y-%m-%d")
@@ -9454,8 +9349,8 @@ async def return_acquisition_retention_metrics(bot, data_users, EXTRA_D):
9454
9349
 
9455
9350
  # group by cohort month
9456
9351
  cohorts = defaultdict(list)
9457
- for uid, dt0 in user_signup.items():
9458
- mo = dt0.strftime("%Y-%m")
9352
+ for uid, USER_DT in user_signup.items():
9353
+ mo = USER_DT.strftime("%Y-%m")
9459
9354
  cohorts[mo].append(uid)
9460
9355
  print("Cohorts by month:", {k: len(v) for k, v in cohorts.items()})
9461
9356
 
@@ -14482,62 +14377,6 @@ async def lz_code_pg(chat_id, lan, BASE_P):
14482
14377
  return result
14483
14378
 
14484
14379
 
14485
- async def check_sub_pay_pg(chat_id, lz, BOT_TOKEN_E18B, BASE_P):
14486
- is_paid = False
14487
- till_paid = ''
14488
- try:
14489
- USER_ISPAID = 0
14490
- USER_DTPAID = ''
14491
- dt_now = datetime.now(timezone.utc)
14492
- USER_DT = dt_now.strftime('%d-%m-%Y_%H-%M-%S')
14493
- extra_bot = None
14494
- try:
14495
- lib_id = channel_library_ru if lz == 'ru' else channel_library_en
14496
- extra_bot = Bot(token=BOT_TOKEN_E18B)
14497
- member_ = await extra_bot.get_chat_member(chat_id=lib_id, user_id=chat_id)
14498
- if member_.status in ['member', 'administrator', 'creator']: is_paid = True
14499
- print(f"check_sub_pay {is_paid=}")
14500
- except Exception as e:
14501
- logger.info(log_ % str(e))
14502
- finally:
14503
- if extra_bot: await extra_bot.session.close()
14504
-
14505
- sql = "SELECT USER_ISPAID, USER_DTPAID, USER_TYPAID, USER_DT, USER_LZ FROM \"USER\" WHERE USER_TID=$1"
14506
- data_usr = await db_select_pg(sql, (chat_id,), BASE_P)
14507
-
14508
- if not len(data_usr):
14509
- sql = "INSERT INTO \"USER\" (USER_TID, USER_DT) VALUES ($1, $2) ON CONFLICT DO NOTHING"
14510
- await db_change_pg(sql, (chat_id, USER_DT,), BASE_P)
14511
- else:
14512
- USER_ISPAID, USER_DTPAID, USER_TYPAID, USER_DT, lz = data_usr[0]
14513
-
14514
- if is_paid:
14515
- sql = "UPDATE \"USER\" SET USER_ISPAID=1, USER_DTPAID='', USER_TYPAID='all' WHERE USER_TID=$1"
14516
- await db_change_pg(sql, (chat_id,), BASE_P)
14517
- elif USER_ISPAID and USER_DTPAID:
14518
- till_paid = dt_now.strptime(USER_DTPAID, "%d-%m-%Y_%H-%M-%S").replace(tzinfo=timezone.utc)
14519
- print(f"{till_paid=}")
14520
-
14521
- if dt_now > till_paid:
14522
- sql = "UPDATE \"USER\" SET USER_ISPAID=0, USER_DTPAID='', USER_TYPAID='' WHERE USER_TID=$1"
14523
- await db_change_pg(sql, (chat_id,), BASE_P)
14524
- till_paid = ''
14525
- else:
14526
- is_paid = True
14527
- till_paid = till_paid.strftime('%d.%m.%Y')
14528
- else:
14529
- sql = "UPDATE \"USER\" SET USER_ISPAID=0, USER_DTPAID='', USER_TYPAID='' WHERE USER_TID=$1"
14530
- await db_change_pg(sql, (chat_id,), BASE_P)
14531
- print(f"check_sub_pay {is_paid=}, {till_paid=}")
14532
- except TelegramRetryAfter as e:
14533
- logger.info(log_ % f"TelegramRetryAfter {e.retry_after}")
14534
- await asyncio.sleep(e.retry_after + 1)
14535
- except Exception as e:
14536
- logger.info(log_ % str(e))
14537
- await asyncio.sleep(round(random.uniform(0, 1), 2))
14538
- return is_paid, till_paid
14539
-
14540
-
14541
14380
  async def no_new_text(txt):
14542
14381
  result = txt
14543
14382
  try:
@@ -1,6 +1,6 @@
1
1
  Metadata-Version: 2.4
2
2
  Name: yeref
3
- Version: 0.29.26
3
+ Version: 0.29.27
4
4
  Summary: desc-f
5
5
  Author: john smith
6
6
  Dynamic: author
@@ -0,0 +1,8 @@
1
+ yeref/__init__.py,sha256=Qpv3o6Xa78VdLcsSRmctGtpnYE9btpAkCekgGhgJyXM,49
2
+ yeref/l_.py,sha256=RbirKXasMmKTniXrvC08hF2DVfuHg-s75Z8pliEkEZk,616929
3
+ yeref/tonweb.js,sha256=Jf6aFOQ1OIY4q7fINYz-m5LsI3seMus124M5SYYZmtE,443659
4
+ yeref/yeref.py,sha256=WfvAeVdBYsx4oDcYI4crPcsXkBBu_alX60xEp1q0h14,1052921
5
+ yeref-0.29.27.dist-info/METADATA,sha256=Ls00CTMRxFrciFVlR_dhyZ-BmSNgrUlBc8zaQInbl14,119
6
+ yeref-0.29.27.dist-info/WHEEL,sha256=_zCd3N1l69ArxyTb8rzEoP9TpbYXkqRFSNOD5OuxnTs,91
7
+ yeref-0.29.27.dist-info/top_level.txt,sha256=yCQKchWHbfV-3OuQPYRdi2loypD-nmbDJbtt3OuKKkY,6
8
+ yeref-0.29.27.dist-info/RECORD,,
@@ -1,8 +0,0 @@
1
- yeref/__init__.py,sha256=Qpv3o6Xa78VdLcsSRmctGtpnYE9btpAkCekgGhgJyXM,49
2
- yeref/l_.py,sha256=RbirKXasMmKTniXrvC08hF2DVfuHg-s75Z8pliEkEZk,616929
3
- yeref/tonweb.js,sha256=Jf6aFOQ1OIY4q7fINYz-m5LsI3seMus124M5SYYZmtE,443659
4
- yeref/yeref.py,sha256=_ovEGm6pWExnS1J54Vg-QXaoXqkxnnhI7l9AA1azyHo,1060366
5
- yeref-0.29.26.dist-info/METADATA,sha256=stm1x8rEJEYsX5m6vvxXMNWPe8Grgrxfy-xxwODyxlw,119
6
- yeref-0.29.26.dist-info/WHEEL,sha256=_zCd3N1l69ArxyTb8rzEoP9TpbYXkqRFSNOD5OuxnTs,91
7
- yeref-0.29.26.dist-info/top_level.txt,sha256=yCQKchWHbfV-3OuQPYRdi2loypD-nmbDJbtt3OuKKkY,6
8
- yeref-0.29.26.dist-info/RECORD,,