xync-client 0.0.136__py3-none-any.whl → 0.0.138__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.
Potentially problematic release.
This version of xync-client might be problematic. Click here for more details.
- xync_client/Bybit/InAgent.py +4 -4
- xync_client/Bybit/agent.py +89 -7
- xync_client/Pms/Payeer/__init__.py +1 -1
- xync_client/details.py +21 -4
- {xync_client-0.0.136.dist-info → xync_client-0.0.138.dist-info}/METADATA +1 -1
- {xync_client-0.0.136.dist-info → xync_client-0.0.138.dist-info}/RECORD +8 -8
- {xync_client-0.0.136.dist-info → xync_client-0.0.138.dist-info}/WHEEL +0 -0
- {xync_client-0.0.136.dist-info → xync_client-0.0.138.dist-info}/top_level.txt +0 -0
xync_client/Bybit/InAgent.py
CHANGED
|
@@ -98,7 +98,7 @@ class InAgentClient(BaseInAgentClient):
|
|
|
98
98
|
await self.money_upd(order_db)
|
|
99
99
|
if upd.side: # я покупатель - ждем мою оплату
|
|
100
100
|
dest = order.paymentTermList[0].accountNo
|
|
101
|
-
if not re.match(r"^([Pp])\d{
|
|
101
|
+
if not re.match(r"^([PpРр])\d{7,10}\b", dest):
|
|
102
102
|
continue
|
|
103
103
|
await order_db.fetch_related("ad__pair_side__pair", "cred__pmcur__cur")
|
|
104
104
|
await self.send_payment(order_db, dest)
|
|
@@ -234,7 +234,7 @@ class InAgentClient(BaseInAgentClient):
|
|
|
234
234
|
).prefetch_related("ad__pair_side__pair", "cred__pmcur__cur"):
|
|
235
235
|
im_taker = order_db.taker_id == self.agent_client.actor.id
|
|
236
236
|
im_buyer = order_db.ad.pair_side.is_sell == im_taker
|
|
237
|
-
if order_db.ad.auto_msg != upd.message and upd.roleType
|
|
237
|
+
if order_db.ad.auto_msg != upd.message and upd.roleType == "user":
|
|
238
238
|
msg, _ = await models.Msg.update_or_create(
|
|
239
239
|
{
|
|
240
240
|
"to_maker": upd.userId == self.agent_client.actor.exid and im_taker,
|
|
@@ -245,8 +245,8 @@ class InAgentClient(BaseInAgentClient):
|
|
|
245
245
|
)
|
|
246
246
|
if not upd.message:
|
|
247
247
|
...
|
|
248
|
-
if im_buyer and re.match(r"^
|
|
249
|
-
await self.send_payment(order_db,
|
|
248
|
+
if im_buyer and (g := re.match(r"^[PpРр]\d{7,10}\b", upd.message)):
|
|
249
|
+
await self.send_payment(order_db, g.group())
|
|
250
250
|
case "READ":
|
|
251
251
|
upd = Read.model_validate(data["data"])
|
|
252
252
|
# if upd.status not in (StatusWs.created, StatusWs.canceled, 10, StatusWs.completed):
|
xync_client/Bybit/agent.py
CHANGED
|
@@ -7,12 +7,14 @@ from datetime import datetime, timedelta, timezone
|
|
|
7
7
|
from difflib import SequenceMatcher
|
|
8
8
|
from enum import IntEnum
|
|
9
9
|
from http.client import HTTPException
|
|
10
|
+
from math import floor
|
|
10
11
|
from typing import Literal
|
|
11
12
|
|
|
12
13
|
import pyotp
|
|
13
14
|
from asyncpg import ConnectionDoesNotExistError
|
|
14
15
|
from bybit_p2p import P2P
|
|
15
16
|
from bybit_p2p._exceptions import FailedRequestError
|
|
17
|
+
from payeer_api import PayeerAPI
|
|
16
18
|
from pyro_client.client.file import FileClient
|
|
17
19
|
from tortoise import BaseDBAsyncClient
|
|
18
20
|
from tortoise.exceptions import IntegrityError
|
|
@@ -88,6 +90,8 @@ class AgentClient(BaseAgentClient): # Bybit client
|
|
|
88
90
|
def __init__(self, actor: Actor, bot: FileClient, **kwargs):
|
|
89
91
|
super().__init__(actor, bot, **kwargs)
|
|
90
92
|
self.api = P2P(testnet=False, api_key=actor.agent.auth["key"], api_secret=actor.agent.auth["sec"])
|
|
93
|
+
self.hist: dict = None
|
|
94
|
+
self.completed_orders: list[int] = None
|
|
91
95
|
|
|
92
96
|
""" Private METHs"""
|
|
93
97
|
|
|
@@ -448,9 +452,28 @@ class AgentClient(BaseAgentClient): # Bybit client
|
|
|
448
452
|
if not ad_db:
|
|
449
453
|
...
|
|
450
454
|
ecredex: CredEpyd = order.confirmedPayTerm
|
|
455
|
+
|
|
451
456
|
if ecredex.paymentType == 0 and im_maker and order.side:
|
|
452
457
|
ecredex = order.paymentTermList[0]
|
|
453
458
|
if ecredex.paymentType:
|
|
459
|
+
if ecredex.paymentType == 51:
|
|
460
|
+
ecredex.accountNo = ecredex.accountNo.replace("p", "P").replace("р", "P").replace("Р", "P")
|
|
461
|
+
if not re.match(r"^([Pp])\d{7,10}$", ecredex.accountNo):
|
|
462
|
+
msgs = self.api.get_chat_messages(orderId=order.id, size=100)["result"]["result"]
|
|
463
|
+
msgs = [m["message"] for m in msgs if m["roleType"] == "user" and m["userId"] == order.targetUserId]
|
|
464
|
+
msgs = [g.group() for m in msgs if (g := re.match(r"([PpРр])\d{7,10}\b", m))]
|
|
465
|
+
crd = await models.Cred.get_or_none(
|
|
466
|
+
detail=ecredex.accountNo, credexs__exid=ecredex.id, credexs__ex=self.ex_client.ex
|
|
467
|
+
)
|
|
468
|
+
if not msgs and re.match(r"^\d{7,10}$", ecredex.accountNo):
|
|
469
|
+
ecredex.accountNo = "P" + ecredex.accountNo
|
|
470
|
+
elif msgs:
|
|
471
|
+
ecredex.accountNo = msgs[-1]
|
|
472
|
+
else:
|
|
473
|
+
...
|
|
474
|
+
if crd:
|
|
475
|
+
crd.detail = ecredex.accountNo
|
|
476
|
+
await crd.save(update_fields=["detail"])
|
|
454
477
|
if not (credex := await models.CredEx.get_or_none(exid=ecredex.id, ex=self.ex_client.ex)):
|
|
455
478
|
# cur_id = await Cur.get(ticker=ad.currencyId).values_list('id', flat=True)
|
|
456
479
|
# await self.cred_epyd2db(ecredex, ad_db.maker.person_id, cur_id)
|
|
@@ -504,16 +527,55 @@ class AgentClient(BaseAgentClient): # Bybit client
|
|
|
504
527
|
"amount": float(order.amount) * 10**cur_scale,
|
|
505
528
|
"quantity": float(order.quantity) * 10**coin_scale,
|
|
506
529
|
"status": OrderStatus[Status(order.status).name],
|
|
507
|
-
"created_at":
|
|
508
|
-
"payed_at": order.transferDate != "0" and
|
|
509
|
-
"confirmed_at": Status(order.status) == Status.completed and
|
|
510
|
-
"appealed_at": order.status == 30 and
|
|
530
|
+
"created_at": ms2utc(order.createDate),
|
|
531
|
+
"payed_at": order.transferDate != "0" and ms2utc(order.transferDate) or None,
|
|
532
|
+
"confirmed_at": Status(order.status) == Status.completed and ms2utc(order.transferDate) or None,
|
|
533
|
+
"appealed_at": order.status == 30 and ms2utc(order.transferDate) or None,
|
|
511
534
|
"cred_id": ecredex.paymentType and credex.cred_id or None,
|
|
512
535
|
"taker": taker,
|
|
513
536
|
"ad": ad_db,
|
|
514
537
|
},
|
|
515
538
|
exid=order.id,
|
|
516
539
|
)
|
|
540
|
+
if order.status == Status.completed and ecredex.paymentType == 51:
|
|
541
|
+
await odb.fetch_related("cred", "transfer")
|
|
542
|
+
if odb.cred.detail != ecredex.accountNo:
|
|
543
|
+
...
|
|
544
|
+
frm = (odb.created_at + timedelta(minutes=180 - 1)).isoformat(sep=" ").split("+")[0]
|
|
545
|
+
to = ((odb.payed_at or odb.created_at) + timedelta(minutes=180 + 30)).isoformat(sep=" ").split("+")[0]
|
|
546
|
+
tsa = [
|
|
547
|
+
t
|
|
548
|
+
for tid, t in self.hist.items()
|
|
549
|
+
if (ecredex.accountNo == t["to"] and t["from"] != "@merchant" and frm < t["date"] < to)
|
|
550
|
+
]
|
|
551
|
+
buyer_person = (
|
|
552
|
+
self.actor.person
|
|
553
|
+
if not order.side
|
|
554
|
+
else await self.person_upsert(order.buyerRealName, int(order.targetUserId))
|
|
555
|
+
)
|
|
556
|
+
ts = [t for t in tsa if floor(fa := float(order.amount)) <= float(t["creditedAmount"]) <= round(fa)]
|
|
557
|
+
if len(ts) != 1:
|
|
558
|
+
if len(tsa) > 1:
|
|
559
|
+
summ = sum(float(t["creditedAmount"]) for t in tsa)
|
|
560
|
+
if floor(fa) <= summ <= round(fa):
|
|
561
|
+
for tr in tsa:
|
|
562
|
+
am = int(float(tr["creditedAmount"]) * 100)
|
|
563
|
+
await models.Transfer.create(
|
|
564
|
+
pmid=tr["id"], order=odb, amount=am, sender_acc=tr["from"], created_at=tr["date"]
|
|
565
|
+
)
|
|
566
|
+
else:
|
|
567
|
+
bcred, _ = await models.Cred.get_or_create(
|
|
568
|
+
{"detail": ts[0]["from"]}, person=buyer_person, pmcur_id=odb.cred.pmcur_id
|
|
569
|
+
)
|
|
570
|
+
am = int(float(ts[0]["creditedAmount"]) * 100)
|
|
571
|
+
try:
|
|
572
|
+
await models.Transfer.create(
|
|
573
|
+
pmid=ts[0]["id"], order=odb, amount=am, sender_acc=ts[0]["from"], created_at=ts[0]["date"]
|
|
574
|
+
)
|
|
575
|
+
except IntegrityError as e:
|
|
576
|
+
logging.error(e)
|
|
577
|
+
...
|
|
578
|
+
|
|
517
579
|
await odb.fetch_related("ad")
|
|
518
580
|
return odb
|
|
519
581
|
|
|
@@ -531,8 +593,8 @@ class AgentClient(BaseAgentClient): # Bybit client
|
|
|
531
593
|
page=page,
|
|
532
594
|
# status=status, # 50 - завершено
|
|
533
595
|
# tokenId=token_id,
|
|
534
|
-
beginTime=begin_time,
|
|
535
|
-
endTime=end_time,
|
|
596
|
+
# beginTime=begin_time,
|
|
597
|
+
# endTime=end_time,
|
|
536
598
|
# side=side, # 1 - продажа, 0 - покупка
|
|
537
599
|
size=30,
|
|
538
600
|
)
|
|
@@ -542,6 +604,8 @@ class AgentClient(BaseAgentClient): # Bybit client
|
|
|
542
604
|
await self.get_api_orders(page, begin_time, end_time) # , status, side, token_id)
|
|
543
605
|
ords = {int(o["id"]): OrderItem.model_validate(o) for o in lst["result"]["items"]}
|
|
544
606
|
for oid, o in ords.items():
|
|
607
|
+
if o.status != Status.completed.value or oid in self.completed_orders:
|
|
608
|
+
continue
|
|
545
609
|
fo = self.api.get_order_details(orderId=o.id)
|
|
546
610
|
order = OrderFull.model_validate(fo["result"])
|
|
547
611
|
order_db = await self.create_order(order)
|
|
@@ -565,6 +629,10 @@ class AgentClient(BaseAgentClient): # Bybit client
|
|
|
565
629
|
if len(ords) == 30:
|
|
566
630
|
await self.get_api_orders(page + 1, begin_time, end_time, status, side, token_id)
|
|
567
631
|
|
|
632
|
+
# async def order_stat(self, papi: PayeerAPI):
|
|
633
|
+
# for t in papi.history():
|
|
634
|
+
# os = self.api.get_orders(page=1, size=30)
|
|
635
|
+
|
|
568
636
|
async def mad_upd(self, mad: Ad, attrs: dict, cxids: list[str]):
|
|
569
637
|
if not [setattr(mad, k, v) for k, v in attrs.items() if getattr(mad, k) != v]:
|
|
570
638
|
print(end="v" if mad.side else "^", flush=True)
|
|
@@ -1117,6 +1185,10 @@ class AgentClient(BaseAgentClient): # Bybit client
|
|
|
1117
1185
|
self.tree = tree
|
|
1118
1186
|
|
|
1119
1187
|
|
|
1188
|
+
def ms2utc(msk_ts_str: str):
|
|
1189
|
+
return datetime.fromtimestamp(int(msk_ts_str) / 1000, timezone(timedelta(hours=3), name="MSK"))
|
|
1190
|
+
|
|
1191
|
+
|
|
1120
1192
|
def get_sim(s1, s2) -> int:
|
|
1121
1193
|
sim = int((SequenceMatcher(None, s1, s2).ratio() - 0.6) * 10_000)
|
|
1122
1194
|
return sim if sim > 0 else 0
|
|
@@ -1236,7 +1308,17 @@ async def main():
|
|
|
1236
1308
|
if ct := set(cl.tree.keys()) & a:
|
|
1237
1309
|
logging.exception(f"cycle cids: {ct}")
|
|
1238
1310
|
|
|
1239
|
-
|
|
1311
|
+
pauth = (await models.PmAgent[1]).auth
|
|
1312
|
+
papi = PayeerAPI(pauth["email"], pauth["api_id"], pauth["api_sec"])
|
|
1313
|
+
hist: dict = papi.history(count=1000)
|
|
1314
|
+
hist |= papi.history(count=1000, append=list(hist.keys())[-1])
|
|
1315
|
+
hist |= papi.history(count=1000, append=list(hist.keys())[-1])
|
|
1316
|
+
cl.hist = hist
|
|
1317
|
+
|
|
1318
|
+
cl.completed_orders = await models.Order.filter(status=OrderStatus.completed, transfer__isnull=False).values_list(
|
|
1319
|
+
"exid", flat=True
|
|
1320
|
+
)
|
|
1321
|
+
await cl.get_api_orders() # 43, 1741294800000, 1749157199999)
|
|
1240
1322
|
|
|
1241
1323
|
races = await models.Race.filter(started=True).prefetch_related(
|
|
1242
1324
|
"road__ad__pair_side__pair__cur",
|
|
@@ -81,7 +81,7 @@ class Client(PmAgentClient):
|
|
|
81
81
|
def form_redirect(topup: TopUp) -> tuple[str, dict | None]:
|
|
82
82
|
m_shop = str(topup.topupable.auth["id"])
|
|
83
83
|
m_orderid = str(topup.id)
|
|
84
|
-
m_amount =
|
|
84
|
+
m_amount = "{0:.2f}".format(topup.amount * 0.01)
|
|
85
85
|
m_curr = topup.cur.ticker
|
|
86
86
|
m_desc = b64encode(b"XyncPay top up").decode()
|
|
87
87
|
m_key = topup.topupable.auth["sec"]
|
xync_client/details.py
CHANGED
|
@@ -5,10 +5,26 @@ from xync_schema import models
|
|
|
5
5
|
import re
|
|
6
6
|
from typing import List, Dict
|
|
7
7
|
|
|
8
|
-
|
|
8
|
+
details = ["дай(те)?", "номер", "рек(и|визиты)", "карту", "банк(и|а)?", "куда", "(на )?как(ой|ую)", "актуал"]
|
|
9
9
|
|
|
10
|
+
begging = ["вз (лайк|отзыв)", "взаим(о|ный)?", "отзыву?", "like", "лайкни"]
|
|
10
11
|
|
|
11
|
-
|
|
12
|
+
greetings = [
|
|
13
|
+
"привет(ствую|ик)?",
|
|
14
|
+
"здаровa?",
|
|
15
|
+
"здоров(а|енько)",
|
|
16
|
+
"здравствуй(те)?",
|
|
17
|
+
"Добрый ?(день|вечер)?",
|
|
18
|
+
"h(i|ello)",
|
|
19
|
+
"сал(ют|лам)",
|
|
20
|
+
"ку",
|
|
21
|
+
"йо",
|
|
22
|
+
"хай",
|
|
23
|
+
"добро пожаловать",
|
|
24
|
+
]
|
|
25
|
+
|
|
26
|
+
|
|
27
|
+
async def search_messages(phrases_to_find) -> List[Dict[str, str]]:
|
|
12
28
|
_ = await init_db(TORM, True)
|
|
13
29
|
msgs = await models.Msg.all().values("txt")
|
|
14
30
|
patterns = [re.compile(rf"\b{phrase}\b", re.IGNORECASE) for phrase in phrases_to_find]
|
|
@@ -19,9 +35,10 @@ async def request_for_details(phrases_to_find) -> List[Dict[str, str]]:
|
|
|
19
35
|
for pattern in patterns:
|
|
20
36
|
if pattern.search(msg["txt"]):
|
|
21
37
|
results.append({pattern.pattern: msg["txt"]})
|
|
22
|
-
|
|
38
|
+
for i in results:
|
|
39
|
+
print(i)
|
|
23
40
|
return results
|
|
24
41
|
|
|
25
42
|
|
|
26
43
|
if __name__ == "__main__":
|
|
27
|
-
asyncio.run(
|
|
44
|
+
asyncio.run(search_messages(greetings))
|
|
@@ -1,5 +1,5 @@
|
|
|
1
1
|
xync_client/__init__.py,sha256=47DEQpj8HBSa-_TImW-5JCeuQeRkm5NMpJWZG3hSuFU,0
|
|
2
|
-
xync_client/details.py,sha256=
|
|
2
|
+
xync_client/details.py,sha256=21itVPCgAtaYRR1H9J9oYudj95gafcFjExUN6QL17OI,1330
|
|
3
3
|
xync_client/loader.py,sha256=qAOQqE4id42aOG3jwc0UMBB8roHd6X3_O08qRG7Bfxw,563
|
|
4
4
|
xync_client/pm_unifier.py,sha256=T2Xh-tvcu114P2YBI6RK_XDiaIhyq6ABMrXDuXPlx7A,6541
|
|
5
5
|
xync_client/Abc/Agent.py,sha256=OJaJ1RIMDYAS4xeefeXxVIVI0EKnMczQtrO35MLzqr4,5390
|
|
@@ -34,8 +34,8 @@ xync_client/BitGet/agent.py,sha256=YVs3bDY0OcEJGU7m2A8chzO6PFhWDnQQrA-E6MVkBBg,3
|
|
|
34
34
|
xync_client/BitGet/ex.py,sha256=nAexKRkguIhq4fYP1tkIaou6oBFjjV2xwlajlJ-9DAE,3757
|
|
35
35
|
xync_client/BitGet/etype/ad.py,sha256=fysSW47wGYjSOPUqY864z857AJz4gjN-nOkI1Jxd27U,1838
|
|
36
36
|
xync_client/BitPapa/ex.py,sha256=U-RRB_RSOtErfRgxOZYWegZ_td_uZO37YKo3Jxchf_w,912
|
|
37
|
-
xync_client/Bybit/InAgent.py,sha256=
|
|
38
|
-
xync_client/Bybit/agent.py,sha256=
|
|
37
|
+
xync_client/Bybit/InAgent.py,sha256=EzxMwbSVPv5CKGWzILSwKMEvuIzIl4wtdaPNbkhrln0,25294
|
|
38
|
+
xync_client/Bybit/agent.py,sha256=wpFGareRojeG0nW1mBrtxU9HJlQjStsexdTRMm_3s_w,61753
|
|
39
39
|
xync_client/Bybit/ex.py,sha256=DgPOmnjphcSCSsO4ZQjnIlWICNzdtKhNIpVsU93s99k,4707
|
|
40
40
|
xync_client/Bybit/order.py,sha256=H4UIb8hxFGnw1hZuSbr0yZ4qeaCOIZOMc6jEst0ycBs,1713
|
|
41
41
|
xync_client/Bybit/web_earn.py,sha256=qjqS10xlFc8r40IhDdPZ0LxA2dFEGbvBGXdsrUUJCMo,3019
|
|
@@ -72,7 +72,7 @@ xync_client/Pms/Alfa/state.json,sha256=MKE6vl-JsJO9PNCVqoQgBgYZTgYkHCas7USwl8QFt
|
|
|
72
72
|
xync_client/Pms/MTS/__init__.py,sha256=P_E7W46IZEk8RsEgl7H1xV3JplMT5l9vYQYTYyNbyQ8,2101
|
|
73
73
|
xync_client/Pms/Ozon/__init__.py,sha256=EvQZDSPv0fOT2hNCTP44nXHOIEQvP5bQf_7HVLiZc2I,4123
|
|
74
74
|
xync_client/Pms/Payeer/.gitignore,sha256=sWORdRp8ROppV2CsMEDJ3M_SokrNWCf8b1hlaNs64hg,12
|
|
75
|
-
xync_client/Pms/Payeer/__init__.py,sha256=
|
|
75
|
+
xync_client/Pms/Payeer/__init__.py,sha256=3Uzb4A_q34vPUOlSk1HoNVQWtPqq1ncRH7MK4BGQei0,8886
|
|
76
76
|
xync_client/Pms/Payeer/api.py,sha256=bb8qrlPYyWafel1VR-2nate6xBeRZAVciFJblHygfAs,549
|
|
77
77
|
xync_client/Pms/Payeer/login.py,sha256=W5FAA0reW5x2hSh8sBIWmR38VcYhwvrn1R64IAtWHVw,2921
|
|
78
78
|
xync_client/Pms/Sber/__init__.py,sha256=dxQfd9ZPhFTc_C4xrwaxrV6p0SijDCLNzBeUv3oQG38,4926
|
|
@@ -95,7 +95,7 @@ xync_client/TgWallet/order.py,sha256=BOmBx5WWfJv0-_-A8DcR-Xd8utqO_VTmSqSegm0cteQ
|
|
|
95
95
|
xync_client/TgWallet/pyd.py,sha256=Ys3E8b3RLuyQ26frWT0F0BorkNxVpxnd18tY4Gp9dik,5636
|
|
96
96
|
xync_client/TgWallet/pyro.py,sha256=2K7QWdo48k4MbbgQt90gdz_HiPck69Njm4xaMjIVgoo,1440
|
|
97
97
|
xync_client/TgWallet/web.py,sha256=kDcv9SKKQPe91mw1qJBpbuyKYCAmZdfdHJylHumLBVU,1608
|
|
98
|
-
xync_client-0.0.
|
|
99
|
-
xync_client-0.0.
|
|
100
|
-
xync_client-0.0.
|
|
101
|
-
xync_client-0.0.
|
|
98
|
+
xync_client-0.0.138.dist-info/METADATA,sha256=hj6obh0V9c8OVO4E87R_KRryDQez2HU1IWgdU1hEIfg,1037
|
|
99
|
+
xync_client-0.0.138.dist-info/WHEEL,sha256=_zCd3N1l69ArxyTb8rzEoP9TpbYXkqRFSNOD5OuxnTs,91
|
|
100
|
+
xync_client-0.0.138.dist-info/top_level.txt,sha256=bmYEVIIrD3v7yFwH-X15pEfRvzhuAdfsAZ2igvNI4O8,12
|
|
101
|
+
xync_client-0.0.138.dist-info/RECORD,,
|
|
File without changes
|
|
File without changes
|