yeref 0.29.25__tar.gz → 0.29.27__tar.gz

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.
@@ -1,6 +1,6 @@
1
1
  Metadata-Version: 2.4
2
2
  Name: yeref
3
- Version: 0.29.25
3
+ Version: 0.29.27
4
4
  Summary: desc-f
5
5
  Author: john smith
6
6
  Dynamic: author
@@ -2,7 +2,7 @@ from setuptools import setup
2
2
 
3
3
  setup(
4
4
  name='yeref',
5
- version='0.29.25',
5
+ version='0.29.27',
6
6
  description='desc-f',
7
7
  author='john smith',
8
8
  packages=['yeref'],
@@ -7824,7 +7824,7 @@ l_tonest_dialog_limit_50 = {
7824
7824
  "ar": "👩🏽‍💻 <b>يمكنك</b> سكّ ما يصل إلى 50 ردًا في حوار NFT",
7825
7825
  }
7826
7826
  l_tonest_dialog_need_correct_msgs = {
7827
- "ru": "👩🏽‍💻 <b>Необходимо</b> переслать корректные сообщения (аудио формат невозможно переслать)",
7827
+ "ru": "👩🏽‍💻 <b>Необходимо</b> переслать корректные сообщения (сообщения от бота или аудио формат невозможно переслать)",
7828
7828
  "en": "👩🏽‍💻 <b>You need</b> to forward valid messages (audio format cannot be forwarded)",
7829
7829
  "es": "👩🏽‍💻 <b>Necesitas</b> reenviar mensajes válidos (el formato de audio no se puede reenviar)",
7830
7830
  "fr": "👩🏽‍💻 <b>Vous devez</b> transférer des messages valides (le format audio ne peut pas être transféré)",
@@ -122,6 +122,7 @@ from yeref.l_ import l_inline_demo, l_inline_bot, l_inline_post, l_inline_media,
122
122
  l_payment_success, l_payment_hashtag, l_inline_codex, l_permissions_add_members, l_admin_closed_group_reject, \
123
123
  l_insert_group_link, l_start_group_check, l_check_group_members, l_admin_rights_required
124
124
 
125
+
125
126
  # region group links
126
127
  payment_link = 'http://bagazhznaniy.ru/wp-content/uploads/2014/03/zhivaya-priroda.jpg'
127
128
  # channel_library_ru_link = 'https://t.me/+f-0AbTALTOg4ODBk'
@@ -253,7 +254,7 @@ GROUPP_CDIALOG_ = '☑☑☑'
253
254
 
254
255
  GROUPP_CSYSTEM_ = '☑'
255
256
  GROUPP_CCHANNEL_ = '☑☑'
256
- GROUPP_CLINKS_ = '☑☑☑☑'
257
+ GROUPP_CLINKS_ = '☑☑☑☑☑'
257
258
  GROUPP_CSYMBOLS_ = '☑☑☑'
258
259
  GROUPP_CWORDS_ = '☐☐'
259
260
 
@@ -2142,8 +2143,8 @@ allowed_startapp_params = ['fnd', 'sbt', 'don', 'sub', 'pay', 'pst', 'msg', 'ft'
2142
2143
  tids_not_for_trans = [5134596871, 5152320320, 5200969162, 5240041587, 5277505344, 5298580533, 5300792695, 5304873693,
2143
2144
  5318482236, 5372068352, 5380838469, 5456863561, 5588781655, 5621199443, 5805890320, 5846446387,
2144
2145
  5850795580, 5868482417, 5951232918, 5962132892, 5969907012]
2145
- GROUP_ANON_TID = 1087968824 # GroupAnonymousBot
2146
- CHANNEL_BOT_ = 136817688
2146
+ GROUP_ANON_TID = 1087968824 # @GroupAnonymousBot
2147
+ CHANNEL_BOT_ = 136817688 # @Channel_bot
2147
2148
  ferey_channel_europe = -1001471122743
2148
2149
  ferey_channel_en = -1001833151619
2149
2150
  ferey_channel_es = -1001988190840
@@ -7739,98 +7740,6 @@ async def check_webapp_hash(init_data, TOKEN_BOT, BOT_TOKEN_MAIN=None, extra=Non
7739
7740
  return result
7740
7741
 
7741
7742
 
7742
- async def get_vars_web_main(chat_id, username, full_name, lc, is_premium, utm_web, BASE_P, BOT_TOKEN_E18B):
7743
- is_paid = False
7744
- till_paid = ''
7745
- lz = 'en'
7746
- try:
7747
- dt = lz = utm = None
7748
- pays = []
7749
-
7750
- sql = "SELECT USER_TID, USER_LZ, USER_DT, USER_UTM, USER_PAY FROM \"USER\" WHERE USER_TID=$1"
7751
- data_user = await db_select_pg(sql, (chat_id,), BASE_P)
7752
- if len(data_user): USER_TID, lz, dt, utm, pays = data_user[0]
7753
-
7754
- if not dt:
7755
- dt = datetime.now(timezone.utc).strftime('%d-%m-%Y_%H-%M-%S')
7756
- if not utm:
7757
- utm = utm_web
7758
- if not lz:
7759
- if lc in ['zh', 'zh-chs', 'zh-cht', 'ja', 'ko', 'zh-CN', 'zh-TW', 'th', 'vi', 'tw', 'sg']:
7760
- lz = 'zh'
7761
- # arabic # ir, af
7762
- elif lc in ['ar-XA', 'ar', 'tr', 'ur', 'fa', 'tj', 'dz', 'eg', 'iq', 'sy', 'ae', 'sa', 'tn', 'ir', 'af']:
7763
- lz = 'ar'
7764
- # spanish # portugal: 'pt', 'br', 'ao', 'mz'
7765
- elif lc in ['es', 'ar', 'cl', 'co', 'cu', 've', 'bo', 'pe', 'ec', 'pt', 'br', 'ao', 'mz']:
7766
- lz = 'es'
7767
- # french
7768
- elif lc in ['fr', 'ch', 'be', 'ca']:
7769
- lz = 'fr'
7770
- # europe
7771
- elif lc in ['ru', 'kz', 'kg', 'uz', 'tm', 'md', 'am', 'uk-UA', 'uk', 'kk', 'tk', 'ky']:
7772
- lz = 'ru'
7773
- else:
7774
- lz = 'en'
7775
-
7776
- if utm_web not in ['@FereyPostBot', '']:
7777
- sql = """
7778
- INSERT INTO "USER" (USER_TID, USER_USERNAME, USER_FULLNAME, USER_LZ, USER_LC, USER_UTM, USER_ISPREMIUM, USER_DT)
7779
- VALUES ($1, $2, $3, $4, $5, $6, $7, $8)
7780
- ON CONFLICT (USER_TID)
7781
- DO UPDATE SET
7782
- USER_USERNAME = EXCLUDED.USER_USERNAME,
7783
- USER_FULLNAME = EXCLUDED.USER_FULLNAME,
7784
- USER_LZ = EXCLUDED.USER_LZ,
7785
- USER_LC = EXCLUDED.USER_LC,
7786
- USER_UTM = EXCLUDED.USER_UTM,
7787
- USER_ISPREMIUM = EXCLUDED.USER_ISPREMIUM,
7788
- USER_DT = EXCLUDED.USER_DT
7789
- """
7790
- await db_change_pg(sql, (chat_id, username, full_name, lz, lc, utm, is_premium, dt,), BASE_P)
7791
-
7792
- try:
7793
- print(f"{pays=}")
7794
- if not pays: pays = '[]'
7795
- pays = json.loads(pays)
7796
- except Exception as e:
7797
- logger.info(log_ % str(e))
7798
- pays = []
7799
-
7800
- print(f"{pays=}")
7801
- for pay in pays:
7802
- try:
7803
- if not (pay.get('TYPE', '') == 'SUB' and pay.get('DT_END', '')): continue
7804
- DT_END = datetime.strptime(pay.get('DT_END'), '%d-%m-%Y_%H-%M-%S').replace(tzinfo=timezone.utc)
7805
- print(f"{DT_END=}")
7806
- if datetime.now(timezone.utc) <= DT_END:
7807
- is_paid = True
7808
- till_paid = DT_END.strftime('%d.%m.%Y')
7809
- except Exception as e:
7810
- logger.info(log_ % str(e))
7811
- pass
7812
-
7813
- if not is_paid:
7814
- extra_bot = None
7815
- try:
7816
- lib_id = channel_library_ru if lz == 'ru' else channel_library_en
7817
- print(f"{channel_library_ru=}, {channel_library_en=}")
7818
- extra_bot = Bot(token=BOT_TOKEN_E18B)
7819
- member_ = await extra_bot.get_chat_member(chat_id=lib_id, user_id=chat_id)
7820
- if member_.status in ['member', 'administrator', 'creator']: is_paid = True
7821
- except Exception as e:
7822
- logger.info(log_ % str(e))
7823
- finally:
7824
- if extra_bot: await extra_bot.session.close()
7825
- except TelegramRetryAfter as e:
7826
- logger.info(log_ % f"TelegramRetryAfter {e.retry_after}")
7827
- await asyncio.sleep(e.retry_after + 1)
7828
- except Exception as e:
7829
- logger.info(log_ % str(e))
7830
- await asyncio.sleep(round(random.uniform(0, 1), 2))
7831
- return is_paid, till_paid, lz
7832
-
7833
-
7834
7743
  async def upd_user_data_main(data, web_app_init_data, BASE_P, BOT_TOKEN_E18B, req_url='', utm=''):
7835
7744
  chat_id = int(web_app_init_data.get('user', {}).get('id'))
7836
7745
  username = web_app_init_data.get('user', {}).get('username', None)
@@ -7844,7 +7753,7 @@ async def upd_user_data_main(data, web_app_init_data, BASE_P, BOT_TOKEN_E18B, re
7844
7753
  page = data.get('page', '')
7845
7754
  connectedAddress = data.get('connectedAddress', '')
7846
7755
  USER_TID = chat_id
7847
- USER_HID = USER_LZ = USER_DT = None
7756
+ USER_HID = USER_LZ = None
7848
7757
  USER_VARS = json.loads(USER_VARS_)
7849
7758
  USER_LSTS = json.loads(USER_LSTS_)
7850
7759
  USER_GAMES = {}
@@ -7884,8 +7793,8 @@ async def upd_user_data_main(data, web_app_init_data, BASE_P, BOT_TOKEN_E18B, re
7884
7793
  elif lc in ['ru', 'kz', 'kg', 'uz', 'tm', 'md', 'am', 'uk-UA', 'uk', 'kk', 'tk', 'ky']:
7885
7794
  lz = 'ru'
7886
7795
  USER_LZ = lz
7887
- if not USER_DT:
7888
- 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")
7889
7798
  USER_HID = hashlib.blake2b(f"{'tid'}-{chat_id}".encode('utf-8'), digest_size=4).hexdigest()
7890
7799
  if utm: USER_VARS['USER_UTM'] = utm
7891
7800
 
@@ -7953,9 +7862,9 @@ async def upd_user_data_main(data, web_app_init_data, BASE_P, BOT_TOKEN_E18B, re
7953
7862
  sql = f"""
7954
7863
  INSERT INTO \"USER\" (
7955
7864
  USER_TID, USER_HID, USER_USERNAME, USER_FULLNAME, USER_ISPREMIUM,
7956
- USER_LZ, USER_DT, USER_GAMES, USER_VARS, USER_LSTS
7865
+ USER_LZ, USER_GAMES, USER_VARS, USER_LSTS
7957
7866
  )
7958
- VALUES ($1, $2, $3, $4, $5, $6, $7, $8, $9, $10)
7867
+ VALUES ($1, $2, $3, $4, $5, $6, $7, $8, $9)
7959
7868
  ON CONFLICT (USER_TID) DO UPDATE
7960
7869
  SET
7961
7870
  USER_HID = EXCLUDED.USER_HID,
@@ -7963,13 +7872,12 @@ async def upd_user_data_main(data, web_app_init_data, BASE_P, BOT_TOKEN_E18B, re
7963
7872
  USER_FULLNAME = EXCLUDED.USER_FULLNAME,
7964
7873
  USER_ISPREMIUM = EXCLUDED.USER_ISPREMIUM,
7965
7874
  USER_LZ = EXCLUDED.USER_LZ,
7966
- USER_DT = EXCLUDED.USER_DT,
7967
7875
 
7968
7876
  USER_GAMES = EXCLUDED.USER_GAMES,
7969
7877
  USER_VARS = EXCLUDED.USER_VARS,
7970
7878
  USER_LSTS = EXCLUDED.USER_LSTS
7971
7879
  """
7972
- 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,
7973
7881
  json.dumps(USER_GAMES, ensure_ascii=False),
7974
7882
  json.dumps(USER_VARS, ensure_ascii=False),
7975
7883
  json.dumps(USER_LSTS, ensure_ascii=False),), BASE_P)
@@ -7993,7 +7901,7 @@ async def upd_user_data(ENT_TID, data, web_app_init_data, PROJECT_USERNAME, BASE
7993
7901
  page = data.get('page', '')
7994
7902
  connectedAddress = data.get('connectedAddress', '')
7995
7903
  USER_TID = chat_id
7996
- USER_HID = USER_LZ = USER_DT = None
7904
+ USER_HID = USER_LZ = None
7997
7905
  USER_VARS = json.loads(USER_VARS_)
7998
7906
  USER_LSTS = json.loads(USER_LSTS_)
7999
7907
  USER_GAMES = {}
@@ -8042,7 +7950,8 @@ async def upd_user_data(ENT_TID, data, web_app_init_data, PROJECT_USERNAME, BASE
8042
7950
  elif lc in ['ru', 'kz', 'kg', 'uz', 'tm', 'md', 'am', 'uk-UA', 'uk', 'kk', 'tk', 'ky']:
8043
7951
  lz = 'ru'
8044
7952
  USER_LZ = lz
8045
- 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")
8046
7955
  if not USER_HID: USER_HID = hashlib.blake2b(f"{tid}-{chat_id}".encode('utf-8'), digest_size=4).hexdigest()
8047
7956
 
8048
7957
  now = datetime.now(timezone.utc)
@@ -8079,9 +7988,9 @@ async def upd_user_data(ENT_TID, data, web_app_init_data, PROJECT_USERNAME, BASE
8079
7988
  sql = f"""
8080
7989
  INSERT INTO {schema_name}_{tid}.USER (
8081
7990
  USER_TID, USER_HID, USER_USERNAME, USER_FULLNAME, USER_ISPREMIUM,
8082
- USER_LZ, USER_DT, USER_GAMES, USER_VARS, USER_LSTS
7991
+ USER_LZ, USER_GAMES, USER_VARS, USER_LSTS
8083
7992
  )
8084
- VALUES ($1, $2, $3, $4, $5, $6, $7, $8, $9, $10)
7993
+ VALUES ($1, $2, $3, $4, $5, $6, $7, $8, $9)
8085
7994
  ON CONFLICT (USER_TID) DO UPDATE
8086
7995
  SET
8087
7996
  USER_HID = EXCLUDED.USER_HID,
@@ -8089,13 +7998,12 @@ async def upd_user_data(ENT_TID, data, web_app_init_data, PROJECT_USERNAME, BASE
8089
7998
  USER_FULLNAME = EXCLUDED.USER_FULLNAME,
8090
7999
  USER_ISPREMIUM = EXCLUDED.USER_ISPREMIUM,
8091
8000
  USER_LZ = EXCLUDED.USER_LZ,
8092
- USER_DT = EXCLUDED.USER_DT,
8093
8001
 
8094
8002
  USER_GAMES = EXCLUDED.USER_GAMES,
8095
8003
  USER_VARS = EXCLUDED.USER_VARS,
8096
8004
  USER_LSTS = EXCLUDED.USER_LSTS
8097
8005
  """
8098
- 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,
8099
8007
  json.dumps(USER_GAMES, ensure_ascii=False),
8100
8008
  json.dumps(USER_VARS, ensure_ascii=False),
8101
8009
  json.dumps(USER_LSTS, ensure_ascii=False),), BASE_P)
@@ -8467,7 +8375,6 @@ async def check_sub_pay(chat_id, lz, BOT_TOKEN_E18B, BASE_P):
8467
8375
  USER_ISPAID = 0
8468
8376
  USER_DTPAID = ''
8469
8377
  dt_now = datetime.now(timezone.utc)
8470
- USER_DT = dt_now.strftime('%d-%m-%Y_%H-%M-%S')
8471
8378
  extra_bot = None
8472
8379
  try:
8473
8380
  lib_id = channel_library_ru if lz == 'ru' else channel_library_en
@@ -8480,14 +8387,14 @@ async def check_sub_pay(chat_id, lz, BOT_TOKEN_E18B, BASE_P):
8480
8387
  finally:
8481
8388
  if extra_bot: await extra_bot.session.close()
8482
8389
 
8483
- 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"
8484
8391
  data_usr = await db_select_pg(sql, (chat_id,), BASE_P)
8485
8392
 
8486
8393
  if not len(data_usr):
8487
- sql = "INSERT INTO USER (USER_TID, USER_DT) VALUES ($1, $2) ON CONFLICT DO NOTHING"
8488
- 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)
8489
8396
  else:
8490
- USER_ISPAID, USER_DTPAID, USER_TYPAID, USER_DT, lz = data_usr[0]
8397
+ USER_ISPAID, USER_DTPAID, USER_TYPAID, lz = data_usr[0]
8491
8398
 
8492
8399
  if is_paid:
8493
8400
  sql = "UPDATE USER SET USER_ISPAID=1, USER_DTPAID='', USER_TYPAID='all' WHERE USER_TID=$1"
@@ -8552,8 +8459,8 @@ async def pay_handler_for_all(bot, message, ideas_en, ideas_ru, PROJECT_USERNAME
8552
8459
  data_usr = await db_select_pg(sql, (chat_id,), BASE_P)
8553
8460
  if not len(data_usr):
8554
8461
  dt_ = datetime.now(timezone.utc).strftime('%d-%m-%Y_%H-%M-%S')
8555
- sql = "INSERT INTO \"USER\" (USER_TID, USER_DT) VALUES ($1, $2) ON CONFLICT DO NOTHING"
8556
- 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)
8557
8464
  USER_LSTS = json.loads(USER_LSTS_)
8558
8465
  USER_VARS = json.loads(USER_VARS_)
8559
8466
  if payload == 'gift': USER_VARS['USER_UTM'] = 'gift'
@@ -8901,6 +8808,7 @@ async def calc_metrics(bot, PROJECT_USERNAME, dataroom_folder_id, EXTRA_D, BASE_
8901
8808
 
8902
8809
  data_users.append((
8903
8810
  random.randint(100000, 999999),
8811
+ entry_dt_obj,
8904
8812
  json.dumps({"USER_WALLET": wallet, "USER_UTM": utm, "USER_DT": entry_dt}),
8905
8813
  json.dumps({"USER_DAU": user_dau, "USER_MAU": user_mau, "USER_TXS": txs,
8906
8814
  "USER_PAYMENTS": payments, "USER_STATUSES": USER_STATUSES})
@@ -9032,7 +8940,6 @@ async def return_activity_metrics(bot, data_users, EXTRA_D, BASE_P, data_ents, s
9032
8940
  USER_LSTS = json.loads(USER_LSTS or "{}")
9033
8941
  USER_WALLET = USER_VARS.get('USER_WALLET', '')
9034
8942
  USER_UTM = USER_VARS.get('USER_UTM', '')
9035
- USER_DT = USER_VARS.get('USER_DT', '')
9036
8943
  USER_DAU = USER_LSTS.get("USER_DAU", [])
9037
8944
  USER_MAU = USER_LSTS.get("USER_MAU", [])
9038
8945
  USER_TXS = USER_LSTS.get("USER_TXS", [])
@@ -9076,11 +8983,9 @@ async def return_activity_metrics(bot, data_users, EXTRA_D, BASE_P, data_ents, s
9076
8983
  month_key = dt_tx.strftime("%Y-%m")
9077
8984
  metrics_by_month[month_key]["pay"] += 1
9078
8985
 
9079
- if USER_DT:
9080
- dt_obj = datetime.strptime(USER_DT, "%d-%m-%Y_%H-%M-%S")
9081
- month_key = dt_obj.strftime("%Y-%m")
9082
- key = "/startapp" if USER_UTM == "/startapp" else "/start"
9083
- 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
9084
8989
 
9085
8990
  process_user_rows(data_users)
9086
8991
 
@@ -9136,15 +9041,13 @@ async def return_unit_metrics(bot, data_users, EXTRA_D):
9136
9041
  for USER_TID, USER_VARS, USER_LSTS in data_users:
9137
9042
  USER_VARS = json.loads(USER_VARS or "{}")
9138
9043
  USER_LSTS = json.loads(USER_LSTS or "{}")
9139
- USER_DT = USER_VARS.get("USER_DT", "")
9140
9044
  USER_PAYMENTS = USER_LSTS.get("USER_PAYMENTS", [])
9141
9045
  USER_STATUSES = USER_LSTS.get("USER_STATUSES", [])
9142
9046
 
9143
- if USER_DT:
9144
- mo = datetime.strptime(USER_DT, "%d-%m-%Y_%H-%M-%S").strftime("%Y-%m")
9145
- if (USER_TID, mo) not in seen_new:
9146
- seen_new.add((USER_TID, mo))
9147
- 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
9148
9051
 
9149
9052
  for pay in USER_PAYMENTS:
9150
9053
  dt_p = datetime.strptime(pay.get("DT_START", ""), "%d-%m-%Y_%H-%M-%S")
@@ -9248,13 +9151,12 @@ async def return_cohort_metrics(bot, data_users, EXTRA_D):
9248
9151
  cohorts = defaultdict(set)
9249
9152
  activity_months = defaultdict(set)
9250
9153
 
9251
- for USER_TID, USER_VARS, USER_LSTS in data_users:
9154
+ for USER_TID, USER_DT, USER_VARS, USER_LSTS in data_users:
9252
9155
  USER_VARS = json.loads(USER_VARS or "{}")
9253
9156
  USER_LSTS = json.loads(USER_LSTS or "{}")
9254
- USER_DT = USER_VARS.get("USER_DT", "")
9255
9157
  USER_DAU = USER_LSTS.get("USER_DAU", [])
9256
9158
 
9257
- entry_mo = datetime.strptime(USER_DT, "%d-%m-%Y_%H-%M-%S").strftime("%Y-%m")
9159
+ entry_mo = USER_DT.strftime("%Y-%m")
9258
9160
  cohorts[entry_mo].add(USER_TID)
9259
9161
 
9260
9162
  for day_str in USER_DAU:
@@ -9337,13 +9239,11 @@ async def return_retention_metrics(bot, data_users, EXTRA_D):
9337
9239
  rev_by_cohort = defaultdict(lambda: defaultdict(float))
9338
9240
  cohort_users = defaultdict(set)
9339
9241
 
9340
- for USER_TID, USER_VARS, USER_LSTS in data_users:
9242
+ for USER_TID, USER_DT, USER_VARS, USER_LSTS in data_users:
9341
9243
  USER_VARS = json.loads(USER_VARS or "{}")
9342
9244
  USER_LSTS = json.loads(USER_LSTS or "{}")
9343
- dt_entry_raw = USER_VARS.get("USER_DT", "").split("_")[0]
9344
- if not dt_entry_raw:
9345
- continue
9346
- cohort_mo = datetime.strptime(dt_entry_raw, "%d-%m-%Y").strftime("%Y-%m")
9245
+
9246
+ cohort_mo = USER_DT.strftime("%Y-%m")
9347
9247
  cohort_users[cohort_mo].add(USER_TID)
9348
9248
 
9349
9249
  for pay in USER_LSTS.get("USER_PAYMENTS", []):
@@ -9430,15 +9330,11 @@ async def return_acquisition_retention_metrics(bot, data_users, EXTRA_D):
9430
9330
  user_signup = {}
9431
9331
  user_activity = defaultdict(set)
9432
9332
 
9433
- for USER_TID, USER_VARS, USER_LSTS in data_users:
9333
+ for USER_TID, USER_DT, USER_VARS, USER_LSTS in data_users:
9434
9334
  vars_ = json.loads(USER_VARS or "{}")
9435
9335
  lsts = json.loads(USER_LSTS or "{}")
9436
- dt0_str = vars_.get("USER_DT", "").split("_")[0]
9437
- if not dt0_str:
9438
- print(f"Skip USER_TID={USER_TID}, no signup date")
9439
- continue
9440
- dt0 = datetime.strptime(dt0_str, "%d-%m-%Y")
9441
- user_signup[USER_TID] = dt0
9336
+
9337
+ user_signup[USER_TID] = USER_DT
9442
9338
  for day in lsts.get("USER_DAU", []):
9443
9339
  try:
9444
9340
  d = datetime.strptime(day, "%Y-%m-%d")
@@ -9453,8 +9349,8 @@ async def return_acquisition_retention_metrics(bot, data_users, EXTRA_D):
9453
9349
 
9454
9350
  # group by cohort month
9455
9351
  cohorts = defaultdict(list)
9456
- for uid, dt0 in user_signup.items():
9457
- mo = dt0.strftime("%Y-%m")
9352
+ for uid, USER_DT in user_signup.items():
9353
+ mo = USER_DT.strftime("%Y-%m")
9458
9354
  cohorts[mo].append(uid)
9459
9355
  print("Cohorts by month:", {k: len(v) for k, v in cohorts.items()})
9460
9356
 
@@ -14481,62 +14377,6 @@ async def lz_code_pg(chat_id, lan, BASE_P):
14481
14377
  return result
14482
14378
 
14483
14379
 
14484
- async def check_sub_pay_pg(chat_id, lz, BOT_TOKEN_E18B, BASE_P):
14485
- is_paid = False
14486
- till_paid = ''
14487
- try:
14488
- USER_ISPAID = 0
14489
- USER_DTPAID = ''
14490
- dt_now = datetime.now(timezone.utc)
14491
- USER_DT = dt_now.strftime('%d-%m-%Y_%H-%M-%S')
14492
- extra_bot = None
14493
- try:
14494
- lib_id = channel_library_ru if lz == 'ru' else channel_library_en
14495
- extra_bot = Bot(token=BOT_TOKEN_E18B)
14496
- member_ = await extra_bot.get_chat_member(chat_id=lib_id, user_id=chat_id)
14497
- if member_.status in ['member', 'administrator', 'creator']: is_paid = True
14498
- print(f"check_sub_pay {is_paid=}")
14499
- except Exception as e:
14500
- logger.info(log_ % str(e))
14501
- finally:
14502
- if extra_bot: await extra_bot.session.close()
14503
-
14504
- sql = "SELECT USER_ISPAID, USER_DTPAID, USER_TYPAID, USER_DT, USER_LZ FROM \"USER\" WHERE USER_TID=$1"
14505
- data_usr = await db_select_pg(sql, (chat_id,), BASE_P)
14506
-
14507
- if not len(data_usr):
14508
- sql = "INSERT INTO \"USER\" (USER_TID, USER_DT) VALUES ($1, $2) ON CONFLICT DO NOTHING"
14509
- await db_change_pg(sql, (chat_id, USER_DT,), BASE_P)
14510
- else:
14511
- USER_ISPAID, USER_DTPAID, USER_TYPAID, USER_DT, lz = data_usr[0]
14512
-
14513
- if is_paid:
14514
- sql = "UPDATE \"USER\" SET USER_ISPAID=1, USER_DTPAID='', USER_TYPAID='all' WHERE USER_TID=$1"
14515
- await db_change_pg(sql, (chat_id,), BASE_P)
14516
- elif USER_ISPAID and USER_DTPAID:
14517
- till_paid = dt_now.strptime(USER_DTPAID, "%d-%m-%Y_%H-%M-%S").replace(tzinfo=timezone.utc)
14518
- print(f"{till_paid=}")
14519
-
14520
- if dt_now > till_paid:
14521
- sql = "UPDATE \"USER\" SET USER_ISPAID=0, USER_DTPAID='', USER_TYPAID='' WHERE USER_TID=$1"
14522
- await db_change_pg(sql, (chat_id,), BASE_P)
14523
- till_paid = ''
14524
- else:
14525
- is_paid = True
14526
- till_paid = till_paid.strftime('%d.%m.%Y')
14527
- else:
14528
- sql = "UPDATE \"USER\" SET USER_ISPAID=0, USER_DTPAID='', USER_TYPAID='' WHERE USER_TID=$1"
14529
- await db_change_pg(sql, (chat_id,), BASE_P)
14530
- print(f"check_sub_pay {is_paid=}, {till_paid=}")
14531
- except TelegramRetryAfter as e:
14532
- logger.info(log_ % f"TelegramRetryAfter {e.retry_after}")
14533
- await asyncio.sleep(e.retry_after + 1)
14534
- except Exception as e:
14535
- logger.info(log_ % str(e))
14536
- await asyncio.sleep(round(random.uniform(0, 1), 2))
14537
- return is_paid, till_paid
14538
-
14539
-
14540
14380
  async def no_new_text(txt):
14541
14381
  result = txt
14542
14382
  try:
@@ -1,6 +1,6 @@
1
1
  Metadata-Version: 2.4
2
2
  Name: yeref
3
- Version: 0.29.25
3
+ Version: 0.29.27
4
4
  Summary: desc-f
5
5
  Author: john smith
6
6
  Dynamic: author
File without changes
File without changes
File without changes
File without changes