yeref 0.24.24__tar.gz → 0.24.26__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.
- {yeref-0.24.24 → yeref-0.24.26}/PKG-INFO +1 -1
- {yeref-0.24.24 → yeref-0.24.26}/setup.py +1 -1
- {yeref-0.24.24 → yeref-0.24.26}/yeref/yeref.py +251 -134
- {yeref-0.24.24 → yeref-0.24.26}/yeref.egg-info/PKG-INFO +1 -1
- {yeref-0.24.24 → yeref-0.24.26}/pyproject.toml +0 -0
- {yeref-0.24.24 → yeref-0.24.26}/setup.cfg +0 -0
- {yeref-0.24.24 → yeref-0.24.26}/yeref/__init__.py +0 -0
- {yeref-0.24.24 → yeref-0.24.26}/yeref/l_.py +0 -0
- {yeref-0.24.24 → yeref-0.24.26}/yeref/tonweb.js +0 -0
- {yeref-0.24.24 → yeref-0.24.26}/yeref.egg-info/SOURCES.txt +0 -0
- {yeref-0.24.24 → yeref-0.24.26}/yeref.egg-info/dependency_links.txt +0 -0
- {yeref-0.24.24 → yeref-0.24.26}/yeref.egg-info/top_level.txt +0 -0
@@ -211,7 +211,7 @@ BOT_CADMIN_ = '☐☑'
|
|
211
211
|
BOT_VARS_ = '{"BOT_PROMO": "#911", "BOT_CHANNEL": 0, "BOT_CHANNELTID": 0, "BOT_GROUP": 0, "BOT_GROUPTID": 0, "BOT_CHATGPT": "", "BOT_GEO": 0, "BOT_TZ": "+00:00", "BOT_DT": "", "BOT_LZ": "en", "BOT_LC": "en", "BOT_ISSTARTED": 0, "BOT_ISMENTIONED": 0}'
|
212
212
|
BOT_LSTS_ = '{"BOT_ADMINS": [], "BOT_COMMANDS": ["/start"]}'
|
213
213
|
USER_VARS_ = '{"USER_TEXT": "", "USER_REACTION": "", "USER_PUSH": "", "USER_EMAIL": "", "USER_PROMO": "", "USER_CONTACT": "", "USER_GEO": "", "USER_UTM": "", "USER_ID": 0, "USER_DT": "", "USER_TZ": "+00:00", "USER_LC": "en", "USER_LZ": "en", "USER_ISADMIN": 0, "USER_ISBLOG": 0, "USER_ISPREMIUM": 0, "USER_BALL": 0, "USER_RAND": 0, "USER_QUIZ": 0, "USER_DICE": 0, "MSGID_PAID": 0, "DATE_TIME": 0}'
|
214
|
-
USER_LSTS_ = '{"USER_UTMREF": [], "USER_PAYMENTS": []}'
|
214
|
+
USER_LSTS_ = '{"USER_UTMREF": [], "USER_PAYMENTS": [], "USER_TXS": [], "USER_DAU": [], "USER_MAU": []}'
|
215
215
|
|
216
216
|
UB_CONFIG_ = '☑☑☑☐☐☑☑☐☐☐☐☐☐'
|
217
217
|
UB_CMONITOR_ = '☐'
|
@@ -15511,6 +15511,256 @@ async def get_vars_web_main(chat_id, username, full_name, lc, is_premium, utm_we
|
|
15511
15511
|
return is_paid, till_paid, lz
|
15512
15512
|
|
15513
15513
|
|
15514
|
+
async def upd_user_data_main(data, web_app_init_data, BASE_P, BOT_TOKEN_E18B, req_url=''):
|
15515
|
+
chat_id = int(web_app_init_data.get('user', {}).get('id'))
|
15516
|
+
username = web_app_init_data.get('user', {}).get('username', None)
|
15517
|
+
first_name = web_app_init_data.get('user', {}).get('first_name', '')
|
15518
|
+
last_name = web_app_init_data.get('user', {}).get('last_name', '')
|
15519
|
+
full_name = f"{first_name} {last_name}".strip()
|
15520
|
+
lc = web_app_init_data.get('user', {}).get('language_code', 'en')
|
15521
|
+
is_premium = web_app_init_data.get('user', {}).get('is_premium', None)
|
15522
|
+
usr_sig = web_app_init_data.get('signature', '')
|
15523
|
+
|
15524
|
+
page = data.get('page', '')
|
15525
|
+
connectedAddress = data.get('connectedAddress', '')
|
15526
|
+
USER_TID = chat_id
|
15527
|
+
USER_VARS = json.loads(USER_VARS_)
|
15528
|
+
USER_LSTS = json.loads(USER_LSTS_)
|
15529
|
+
USER_GAMES = {}
|
15530
|
+
balls = 1
|
15531
|
+
is_paid = False
|
15532
|
+
till_paid = ''
|
15533
|
+
|
15534
|
+
print(f"upd_user_data_main: {USER_LSTS=}")
|
15535
|
+
try:
|
15536
|
+
sql = f"SELECT USER_TID, USER_GAMES, USER_VARS, USER_LSTS FROM \"USER\" WHERE USER_TID=$1"
|
15537
|
+
data_user = await db_select_pg(sql, (chat_id,), BASE_P)
|
15538
|
+
|
15539
|
+
if len(data_user):
|
15540
|
+
USER_TID, USER_GAMES, USER_VARS, USER_LSTS = data_user[0]
|
15541
|
+
USER_GAMES = json.loads(USER_GAMES)
|
15542
|
+
USER_VARS = json.loads(USER_VARS)
|
15543
|
+
USER_LSTS = json.loads(USER_LSTS)
|
15544
|
+
if page in ['msg', 'pst']: USER_GAMES = await ch_games(USER_GAMES, 'web', True, balls)
|
15545
|
+
|
15546
|
+
# region lz
|
15547
|
+
if lc:
|
15548
|
+
USER_VARS['USER_LC'] = lc
|
15549
|
+
lz = 'en'
|
15550
|
+
if lc in ['zh', 'zh-chs', 'zh-cht', 'ja', 'ko', 'zh-CN', 'zh-TW', 'th', 'vi', 'tw', 'sg']:
|
15551
|
+
lz = 'zh'
|
15552
|
+
# arabic # ir, af
|
15553
|
+
elif lc in ['ar-XA', 'ar', 'tr', 'ur', 'fa', 'tj', 'dz', 'eg', 'iq', 'sy', 'ae', 'sa', 'tn', 'ir', 'af']:
|
15554
|
+
lz = 'ar'
|
15555
|
+
# spanish # portugal: 'pt', 'br', 'ao', 'mz'
|
15556
|
+
elif lc in ['es', 'ar', 'cl', 'co', 'cu', 've', 'bo', 'pe', 'ec', 'pt', 'br', 'ao', 'mz']:
|
15557
|
+
lz = 'es'
|
15558
|
+
# french
|
15559
|
+
elif lc in ['fr', 'ch', 'be', 'ca']:
|
15560
|
+
lz = 'fr'
|
15561
|
+
# europe
|
15562
|
+
elif lc in ['ru', 'kz', 'kg', 'uz', 'tm', 'md', 'am', 'uk-UA', 'uk', 'kk', 'tk', 'ky']:
|
15563
|
+
lz = 'ru'
|
15564
|
+
USER_VARS['USER_LZ'] = lz
|
15565
|
+
# endregion
|
15566
|
+
print(f"{USER_VARS=}, {lc=}")
|
15567
|
+
|
15568
|
+
# region tx
|
15569
|
+
if connectedAddress:
|
15570
|
+
print(f"{connectedAddress=}, {USER_VARS=}")
|
15571
|
+
USER_VARS['USER_WALLET'] = connectedAddress
|
15572
|
+
print(f"after {req_url=}, {USER_VARS=}")
|
15573
|
+
print(f"after {data.get('amount', None)=}, {data=}")
|
15574
|
+
|
15575
|
+
if req_url and data.get('amount', None):
|
15576
|
+
amount = data.get('amount', None)
|
15577
|
+
address = data.get('address', '')
|
15578
|
+
DT_START = datetime.now(timezone.utc).strftime('%d-%m-%Y_%H-%M-%S')
|
15579
|
+
USER_TXS = USER_LSTS.get("USER_TXS", [])
|
15580
|
+
|
15581
|
+
USER_TXS.append({
|
15582
|
+
'TYPE': req_url,
|
15583
|
+
'AMOUNT': amount,
|
15584
|
+
'ADDRESS': address,
|
15585
|
+
'DT_START': DT_START,
|
15586
|
+
})
|
15587
|
+
USER_LSTS["USER_TXS"] = USER_TXS
|
15588
|
+
print(f"{USER_TXS=}, {USER_LSTS=}")
|
15589
|
+
# endregion
|
15590
|
+
|
15591
|
+
# region pay
|
15592
|
+
pays = USER_LSTS.get('USER_PAYMENTS', [])
|
15593
|
+
print(f"{pays=}")
|
15594
|
+
for pay in pays:
|
15595
|
+
try:
|
15596
|
+
if not (pay.get('TYPE', '') == 'SUB' and pay.get('DT_END', '')): continue
|
15597
|
+
DT_END = datetime.strptime(pay.get('DT_END'), '%d-%m-%Y_%H-%M-%S').replace(tzinfo=timezone.utc)
|
15598
|
+
print(f"{DT_END=}")
|
15599
|
+
if datetime.now(timezone.utc) <= DT_END:
|
15600
|
+
is_paid = True
|
15601
|
+
till_paid = DT_END.strftime('%d.%m.%Y')
|
15602
|
+
except Exception as e:
|
15603
|
+
logger.info(log_ % str(e))
|
15604
|
+
pass
|
15605
|
+
|
15606
|
+
if not is_paid:
|
15607
|
+
extra_bot = None
|
15608
|
+
try:
|
15609
|
+
lib_id = channel_library_ru if lz == 'ru' else channel_library_en
|
15610
|
+
print(f"{channel_library_ru=}, {channel_library_en=}")
|
15611
|
+
extra_bot = Bot(token=BOT_TOKEN_E18B)
|
15612
|
+
member_ = await extra_bot.get_chat_member(chat_id=lib_id, user_id=chat_id)
|
15613
|
+
if member_.status in ['member', 'administrator', 'creator']: is_paid = True
|
15614
|
+
print(f"get_vars_web_main -> get_chat_member {is_paid=}")
|
15615
|
+
except Exception as e:
|
15616
|
+
logger.info(log_ % str(e))
|
15617
|
+
finally:
|
15618
|
+
if extra_bot: await extra_bot.session.close()
|
15619
|
+
# endregion
|
15620
|
+
|
15621
|
+
now = datetime.now(timezone.utc)
|
15622
|
+
USER_LSTS["USER_DAU"] = list(set(USER_LSTS.get("USER_DAU", []) + [now.strftime('%Y-%m-%d')]))
|
15623
|
+
USER_LSTS["USER_MAU"] = list(set(USER_LSTS.get("USER_MAU", []) + [now.strftime('%Y-%m')]))
|
15624
|
+
USER_VARS['USER_SIG'] = usr_sig
|
15625
|
+
USER_VARS['USER_ISPREMIUM'] = is_premium
|
15626
|
+
|
15627
|
+
sql = f"""
|
15628
|
+
INSERT INTO \"USER\" (
|
15629
|
+
USER_TID, USER_USERNAME, USER_FULLNAME, USER_GAMES, USER_VARS, USER_LSTS
|
15630
|
+
)
|
15631
|
+
VALUES ($1, $2, $3, $4, $5, $6)
|
15632
|
+
ON CONFLICT (USER_TID) DO UPDATE
|
15633
|
+
SET
|
15634
|
+
USER_USERNAME = EXCLUDED.USER_USERNAME,
|
15635
|
+
USER_FULLNAME = EXCLUDED.USER_FULLNAME,
|
15636
|
+
USER_GAMES = EXCLUDED.USER_GAMES,
|
15637
|
+
USER_VARS = EXCLUDED.USER_VARS,
|
15638
|
+
USER_LSTS = EXCLUDED.USER_LSTS
|
15639
|
+
"""
|
15640
|
+
await db_change_pg(sql, (USER_TID, username, full_name,
|
15641
|
+
json.dumps(USER_GAMES, ensure_ascii=False),
|
15642
|
+
json.dumps(USER_VARS, ensure_ascii=False),
|
15643
|
+
json.dumps(USER_LSTS, ensure_ascii=False),), BASE_P)
|
15644
|
+
except Exception as e:
|
15645
|
+
logger.info(log_ % str(e))
|
15646
|
+
await asyncio.sleep(round(random.uniform(0, 1), 2))
|
15647
|
+
finally:
|
15648
|
+
return USER_TID, username, full_name, USER_GAMES, USER_VARS, USER_LSTS, is_paid, till_paid
|
15649
|
+
|
15650
|
+
|
15651
|
+
async def upd_user_data(ENT_TID, data, web_app_init_data, PROJECT_USERNAME, BASE_P, req_url=''):
|
15652
|
+
chat_id = int(web_app_init_data.get('user', {}).get('id'))
|
15653
|
+
username = web_app_init_data.get('user', {}).get('username', None)
|
15654
|
+
first_name = web_app_init_data.get('user', {}).get('first_name', '')
|
15655
|
+
last_name = web_app_init_data.get('user', {}).get('last_name', '')
|
15656
|
+
full_name = f"{first_name} {last_name}".strip()
|
15657
|
+
lc = web_app_init_data.get('user', {}).get('language_code', 'en')
|
15658
|
+
is_premium = web_app_init_data.get('user', {}).get('is_premium', None)
|
15659
|
+
usr_sig = web_app_init_data.get('signature', '')
|
15660
|
+
|
15661
|
+
tid = str(ENT_TID).replace('-', '')
|
15662
|
+
page = data.get('page', '')
|
15663
|
+
connectedAddress = data.get('connectedAddress', '')
|
15664
|
+
USER_TID = chat_id
|
15665
|
+
USER_VARS = json.loads(USER_VARS_)
|
15666
|
+
USER_LSTS = json.loads(USER_LSTS_)
|
15667
|
+
USER_GAMES = {}
|
15668
|
+
balls = 1
|
15669
|
+
|
15670
|
+
print(f"upd_user_data: {USER_LSTS=}")
|
15671
|
+
try:
|
15672
|
+
schema_name = 'USER'
|
15673
|
+
if PROJECT_USERNAME == 'FereyBotBot':
|
15674
|
+
schema_name = 'BOT'
|
15675
|
+
balls = -1
|
15676
|
+
elif PROJECT_USERNAME == 'FereyChannelBot':
|
15677
|
+
schema_name = 'CHANNEL'
|
15678
|
+
elif PROJECT_USERNAME == 'FereyGroupBot':
|
15679
|
+
schema_name = 'GROUPP'
|
15680
|
+
|
15681
|
+
sql = f"SELECT USER_TID, USER_GAMES, USER_VARS, USER_LSTS FROM {schema_name}_{tid}.USER WHERE USER_TID=$1"
|
15682
|
+
data_user = await db_select_pg(sql, (chat_id,), BASE_P)
|
15683
|
+
print(f"{data_user=}")
|
15684
|
+
if len(data_user):
|
15685
|
+
USER_TID, USER_GAMES, USER_VARS, USER_LSTS = data_user[0]
|
15686
|
+
USER_GAMES = json.loads(USER_GAMES)
|
15687
|
+
USER_VARS = json.loads(USER_VARS)
|
15688
|
+
USER_LSTS = json.loads(USER_LSTS)
|
15689
|
+
if page in ['msg', 'pst']: USER_GAMES = await ch_games(USER_GAMES, 'web', True, balls)
|
15690
|
+
|
15691
|
+
# region lz
|
15692
|
+
if lc:
|
15693
|
+
USER_VARS['USER_LC'] = lc
|
15694
|
+
lz = 'en'
|
15695
|
+
if lc in ['zh', 'zh-chs', 'zh-cht', 'ja', 'ko', 'zh-CN', 'zh-TW', 'th', 'vi', 'tw', 'sg']:
|
15696
|
+
lz = 'zh'
|
15697
|
+
# arabic # ir, af
|
15698
|
+
elif lc in ['ar-XA', 'ar', 'tr', 'ur', 'fa', 'tj', 'dz', 'eg', 'iq', 'sy', 'ae', 'sa', 'tn', 'ir', 'af']:
|
15699
|
+
lz = 'ar'
|
15700
|
+
# spanish # portugal: 'pt', 'br', 'ao', 'mz'
|
15701
|
+
elif lc in ['es', 'ar', 'cl', 'co', 'cu', 've', 'bo', 'pe', 'ec', 'pt', 'br', 'ao', 'mz']:
|
15702
|
+
lz = 'es'
|
15703
|
+
# french
|
15704
|
+
elif lc in ['fr', 'ch', 'be', 'ca']:
|
15705
|
+
lz = 'fr'
|
15706
|
+
# europe
|
15707
|
+
elif lc in ['ru', 'kz', 'kg', 'uz', 'tm', 'md', 'am', 'uk-UA', 'uk', 'kk', 'tk', 'ky']:
|
15708
|
+
lz = 'ru'
|
15709
|
+
USER_VARS['USER_LZ'] = lz
|
15710
|
+
# endregion
|
15711
|
+
print(f"{USER_VARS=}, {lc=}")
|
15712
|
+
|
15713
|
+
# region tx
|
15714
|
+
if connectedAddress:
|
15715
|
+
print(f"{connectedAddress=}, {USER_VARS=}")
|
15716
|
+
USER_VARS['USER_WALLET'] = connectedAddress
|
15717
|
+
print(f"after {req_url=}, {USER_VARS=}")
|
15718
|
+
print(f"after {data.get('amount', None)=}, {data=}")
|
15719
|
+
|
15720
|
+
if req_url and data.get('amount', None):
|
15721
|
+
amount = data.get('amount', None)
|
15722
|
+
address = data.get('address', '')
|
15723
|
+
DT_START = datetime.now(timezone.utc).strftime('%d-%m-%Y_%H-%M-%S')
|
15724
|
+
USER_TXS = USER_LSTS.get("USER_TXS", [])
|
15725
|
+
|
15726
|
+
USER_TXS.append({
|
15727
|
+
'TYPE': req_url,
|
15728
|
+
'AMOUNT': amount,
|
15729
|
+
'ADDRESS': address,
|
15730
|
+
'DT_START': DT_START,
|
15731
|
+
})
|
15732
|
+
USER_LSTS["USER_TXS"] = USER_TXS
|
15733
|
+
print(f"{USER_TXS=}, {USER_LSTS=}")
|
15734
|
+
# endregion
|
15735
|
+
|
15736
|
+
now = datetime.now(timezone.utc)
|
15737
|
+
USER_LSTS["USER_DAU"] = list(set(USER_LSTS.get("USER_DAU", []) + [now.strftime('%Y-%m-%d')]))
|
15738
|
+
USER_LSTS["USER_MAU"] = list(set(USER_LSTS.get("USER_MAU", []) + [now.strftime('%Y-%m')]))
|
15739
|
+
USER_VARS['USER_SIG'] = usr_sig
|
15740
|
+
USER_VARS['USER_ISPREMIUM'] = is_premium
|
15741
|
+
|
15742
|
+
sql = f"""
|
15743
|
+
INSERT INTO {schema_name}_{tid}.USER (
|
15744
|
+
USER_TID, USER_USERNAME, USER_FULLNAME, USER_GAMES, USER_VARS, USER_LSTS
|
15745
|
+
)
|
15746
|
+
VALUES ($1, $2, $3, $4, $5, $6)
|
15747
|
+
ON CONFLICT (USER_TID) DO UPDATE
|
15748
|
+
SET
|
15749
|
+
USER_USERNAME = EXCLUDED.USER_USERNAME,
|
15750
|
+
USER_FULLNAME = EXCLUDED.USER_FULLNAME,
|
15751
|
+
USER_GAMES = EXCLUDED.USER_GAMES,
|
15752
|
+
USER_VARS = EXCLUDED.USER_VARS,
|
15753
|
+
USER_LSTS = EXCLUDED.USER_LSTS
|
15754
|
+
"""
|
15755
|
+
await db_change_pg(sql, (USER_TID, username, full_name,
|
15756
|
+
json.dumps(USER_GAMES, ensure_ascii=False),
|
15757
|
+
json.dumps(USER_VARS, ensure_ascii=False),
|
15758
|
+
json.dumps(USER_LSTS, ensure_ascii=False),), BASE_P)
|
15759
|
+
except Exception as e:
|
15760
|
+
logger.info(log_ % str(e))
|
15761
|
+
await asyncio.sleep(round(random.uniform(0, 1), 2))
|
15762
|
+
finally:
|
15763
|
+
return USER_TID, username, full_name, USER_GAMES, USER_VARS, USER_LSTS
|
15514
15764
|
# endregion
|
15515
15765
|
|
15516
15766
|
|
@@ -15606,139 +15856,6 @@ async def ch_games(USER_GAMES, game, condition, balls=-1):
|
|
15606
15856
|
return USER_GAMES
|
15607
15857
|
|
15608
15858
|
|
15609
|
-
# async def ch_games(USER_GAMES, game, condition, balls=1):
|
15610
|
-
# try:
|
15611
|
-
# dt = datetime.now(timezone.utc)
|
15612
|
-
# dt_ = dt.strftime('%d-%m-%Y_%H-%M-%S')
|
15613
|
-
#
|
15614
|
-
# if condition:
|
15615
|
-
# dt_game = USER_GAMES[game].get('date')
|
15616
|
-
#
|
15617
|
-
# if not dt_game:
|
15618
|
-
# USER_GAMES[game]['date'] = dt_
|
15619
|
-
# USER_GAMES[game]['balls'] = balls
|
15620
|
-
# else:
|
15621
|
-
# dt_game = datetime.strptime(dt_game, "%d-%m-%Y_%H-%M-%S").replace(tzinfo=timezone.utc)
|
15622
|
-
# if (dt - dt_game).days >= 1:
|
15623
|
-
# USER_GAMES[game]['date'] = dt_
|
15624
|
-
# USER_GAMES[game]['balls'] = balls
|
15625
|
-
# else:
|
15626
|
-
# USER_GAMES[game]['balls'] = 0
|
15627
|
-
# except Exception as e:
|
15628
|
-
# logger.info(log_ % str(e))
|
15629
|
-
# await asyncio.sleep(round(random.uniform(0, 1), 2))
|
15630
|
-
# finally:
|
15631
|
-
# return USER_GAMES
|
15632
|
-
|
15633
|
-
|
15634
|
-
async def get_user_vars(PROJECT_USERNAME, BASE_P, ENT_TID, chat_id, lc, username, full_name, is_premium=False, usr_sig='',
|
15635
|
-
page=''):
|
15636
|
-
USER_TID = chat_id
|
15637
|
-
USER_VARS = json.loads(USER_VARS_)
|
15638
|
-
USER_LSTS = json.loads(USER_LSTS_)
|
15639
|
-
USER_GAMES = {}
|
15640
|
-
print(f"start get usernv a, {USER_LSTS=}")
|
15641
|
-
try:
|
15642
|
-
schema_name = 'USER'
|
15643
|
-
balls = 1
|
15644
|
-
if PROJECT_USERNAME == 'FereyBotBot':
|
15645
|
-
schema_name = 'BOT'
|
15646
|
-
balls = -1
|
15647
|
-
elif PROJECT_USERNAME == 'FereyChannelBot':
|
15648
|
-
schema_name = 'CHANNEL'
|
15649
|
-
elif PROJECT_USERNAME == 'FereyGroupBot':
|
15650
|
-
schema_name = 'GROUPP'
|
15651
|
-
|
15652
|
-
sql = f"SELECT USER_TID, USER_GAMES, USER_VARS, USER_LSTS FROM {schema_name}_{str(ENT_TID).replace('-', '')}.USER WHERE USER_TID=$1"
|
15653
|
-
data_user = await db_select_pg(sql, (chat_id,), BASE_P)
|
15654
|
-
print(f"{data_user=}")
|
15655
|
-
if len(data_user):
|
15656
|
-
USER_TID, USER_GAMES, USER_VARS, USER_LSTS = data_user[0]
|
15657
|
-
USER_GAMES = json.loads(USER_GAMES)
|
15658
|
-
USER_VARS = json.loads(USER_VARS)
|
15659
|
-
USER_LSTS = json.loads(USER_LSTS)
|
15660
|
-
if page in ['msg', 'pst']: USER_GAMES = await ch_games(USER_GAMES, 'web', True, balls)
|
15661
|
-
|
15662
|
-
# region lz
|
15663
|
-
if lc:
|
15664
|
-
USER_VARS['USER_LC'] = lc
|
15665
|
-
lz = 'en'
|
15666
|
-
if lc in ['zh', 'zh-chs', 'zh-cht', 'ja', 'ko', 'zh-CN', 'zh-TW', 'th', 'vi', 'tw', 'sg']:
|
15667
|
-
lz = 'zh'
|
15668
|
-
# arabic # ir, af
|
15669
|
-
elif lc in ['ar-XA', 'ar', 'tr', 'ur', 'fa', 'tj', 'dz', 'eg', 'iq', 'sy', 'ae', 'sa', 'tn', 'ir',
|
15670
|
-
'af']:
|
15671
|
-
lz = 'ar'
|
15672
|
-
# spanish # portugal: 'pt', 'br', 'ao', 'mz'
|
15673
|
-
elif lc in ['es', 'ar', 'cl', 'co', 'cu', 've', 'bo', 'pe', 'ec', 'pt', 'br', 'ao', 'mz']:
|
15674
|
-
lz = 'es'
|
15675
|
-
# french
|
15676
|
-
elif lc in ['fr', 'ch', 'be', 'ca']:
|
15677
|
-
lz = 'fr'
|
15678
|
-
# europe
|
15679
|
-
elif lc in ['ru', 'kz', 'kg', 'uz', 'tm', 'md', 'am', 'uk-UA', 'uk', 'kk', 'tk', 'ky']:
|
15680
|
-
lz = 'ru'
|
15681
|
-
USER_VARS['USER_LZ'] = lz
|
15682
|
-
# endregion
|
15683
|
-
print(f"{USER_VARS=}, {lc=}")
|
15684
|
-
USER_VARS['USER_SIG'] = usr_sig
|
15685
|
-
USER_VARS['USER_ISPREMIUM'] = is_premium
|
15686
|
-
|
15687
|
-
sql = f"""
|
15688
|
-
INSERT INTO {schema_name}_{str(ENT_TID).replace('-', '')}.USER (
|
15689
|
-
USER_TID, USER_USERNAME, USER_FULLNAME, USER_GAMES, USER_VARS, USER_LSTS
|
15690
|
-
)
|
15691
|
-
VALUES ($1, $2, $3, $4, $5, $6)
|
15692
|
-
ON CONFLICT (USER_TID) DO UPDATE
|
15693
|
-
SET
|
15694
|
-
USER_USERNAME = EXCLUDED.USER_USERNAME,
|
15695
|
-
USER_FULLNAME = EXCLUDED.USER_FULLNAME,
|
15696
|
-
USER_GAMES = EXCLUDED.USER_GAMES,
|
15697
|
-
USER_VARS = EXCLUDED.USER_VARS,
|
15698
|
-
USER_LSTS = EXCLUDED.USER_LSTS
|
15699
|
-
"""
|
15700
|
-
await db_change_pg(sql, (USER_TID, username, full_name,
|
15701
|
-
json.dumps(USER_GAMES, ensure_ascii=False),
|
15702
|
-
json.dumps(USER_VARS, ensure_ascii=False),
|
15703
|
-
json.dumps(USER_LSTS, ensure_ascii=False),), BASE_P)
|
15704
|
-
except Exception as e:
|
15705
|
-
logger.info(log_ % str(e))
|
15706
|
-
await asyncio.sleep(round(random.uniform(0, 1), 2))
|
15707
|
-
finally:
|
15708
|
-
return USER_TID, username, full_name, USER_GAMES, USER_VARS, USER_LSTS
|
15709
|
-
|
15710
|
-
|
15711
|
-
async def get_user_vars2(chat_id, ENT_TID, BASE_D, PROJECT_USERNAME):
|
15712
|
-
USER_GAMES = {}
|
15713
|
-
USER_VARS = {}
|
15714
|
-
USER_ISPAID = 0
|
15715
|
-
try:
|
15716
|
-
schema_name = 'USER'
|
15717
|
-
if PROJECT_USERNAME == 'FereyBotBot':
|
15718
|
-
schema_name = 'BOT'
|
15719
|
-
elif PROJECT_USERNAME == 'FereyChannelBot':
|
15720
|
-
schema_name = 'CHANNEL'
|
15721
|
-
elif PROJECT_USERNAME == 'FereyGroupBot':
|
15722
|
-
schema_name = 'GROUPP'
|
15723
|
-
|
15724
|
-
sql = f"SELECT USER_GAMES, USER_VARS, USER_ISPAID FROM {schema_name}_{str(ENT_TID).replace('-', '')}.USER WHERE USER_TID=$1"
|
15725
|
-
data_usr = await db_select_pg(sql, (chat_id,), BASE_D)
|
15726
|
-
if not len(data_usr) or not data_usr[0][0]:
|
15727
|
-
if not len(data_usr):
|
15728
|
-
dt_now = datetime.now(timezone.utc).strftime('%d-%m-%Y_%H-%M-%S')
|
15729
|
-
sql = f"INSERT INTO {schema_name}_{str(ENT_TID).replace('-', '')}.USER (USER_TID, USER_DT) VALUES ($1, $2) ON CONFLICT DO NOTHING"
|
15730
|
-
await db_change_pg(sql, (chat_id, dt_now,), BASE_D)
|
15731
|
-
else:
|
15732
|
-
USER_GAMES, USER_VARS, USER_ISPAID = data_usr[0]
|
15733
|
-
USER_GAMES = json.loads(USER_GAMES) if USER_GAMES else {}
|
15734
|
-
USER_VARS = json.loads(USER_VARS) if USER_VARS else {}
|
15735
|
-
except Exception as e:
|
15736
|
-
logger.info(log_ % str(e))
|
15737
|
-
await asyncio.sleep(round(random.uniform(0, 1), 2))
|
15738
|
-
finally:
|
15739
|
-
return USER_GAMES, USER_VARS, USER_ISPAID
|
15740
|
-
|
15741
|
-
|
15742
15859
|
async def post_save(bot, data_user, data_web, MEDIA_D, BASE_P, KEYS_JSON, PROJECT_USERNAME, PROJECT_TYPE, is_paid=False):
|
15743
15860
|
result = {'result': True, 'bot': True, 'post': data_web['post']}
|
15744
15861
|
try:
|
File without changes
|
File without changes
|
File without changes
|
File without changes
|
File without changes
|
File without changes
|
File without changes
|
File without changes
|