xync-client 0.0.144__py3-none-any.whl → 0.0.147__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/Abc/Agent.py +21 -5
- xync_client/Abc/HasAbotUid.py +10 -0
- xync_client/Abc/InAgent.py +5 -3
- xync_client/Abc/PmAgent.py +34 -23
- xync_client/Abc/xtype.py +3 -1
- xync_client/Bybit/InAgent.py +55 -33
- xync_client/Bybit/agent.py +110 -53
- xync_client/Bybit/etype/order.py +34 -16
- xync_client/Gmail/__init__.py +119 -98
- xync_client/Pms/Payeer/__init__.py +37 -28
- xync_client/Pms/Payeer/login.py +6 -2
- xync_client/Pms/Volet/__init__.py +80 -61
- xync_client/Pms/Volet/api.py +5 -4
- xync_client/loader.py +1 -0
- {xync_client-0.0.144.dist-info → xync_client-0.0.147.dist-info}/METADATA +1 -1
- {xync_client-0.0.144.dist-info → xync_client-0.0.147.dist-info}/RECORD +18 -17
- {xync_client-0.0.144.dist-info → xync_client-0.0.147.dist-info}/WHEEL +0 -0
- {xync_client-0.0.144.dist-info → xync_client-0.0.147.dist-info}/top_level.txt +0 -0
xync_client/Abc/Agent.py
CHANGED
|
@@ -3,19 +3,35 @@ from abc import abstractmethod
|
|
|
3
3
|
from pydantic import BaseModel
|
|
4
4
|
from pyro_client.client.file import FileClient
|
|
5
5
|
from x_client.aiohttp import Client as HttpClient
|
|
6
|
+
from xync_bot import XyncBot
|
|
6
7
|
from xync_schema import models
|
|
7
|
-
from xync_schema.models import OrderStatus, Coin, Cur, Ad, AdStatus, Actor
|
|
8
|
+
from xync_schema.models import OrderStatus, Coin, Cur, Ad, AdStatus, Actor, Agent
|
|
8
9
|
from xync_schema.xtype import BaseAd
|
|
9
10
|
|
|
10
11
|
from xync_client.Abc.Ex import BaseExClient
|
|
11
12
|
from xync_client.Abc.xtype import CredExOut, BaseOrderReq, BaseAdUpdate
|
|
13
|
+
from xync_client.Gmail import GmClient
|
|
12
14
|
|
|
13
15
|
|
|
14
16
|
class BaseAgentClient(HttpClient):
|
|
15
|
-
|
|
16
|
-
|
|
17
|
-
|
|
18
|
-
|
|
17
|
+
bbot: XyncBot
|
|
18
|
+
fbot: FileClient
|
|
19
|
+
|
|
20
|
+
def __init__(
|
|
21
|
+
self,
|
|
22
|
+
agent: Agent,
|
|
23
|
+
fbot: FileClient,
|
|
24
|
+
bbot: XyncBot,
|
|
25
|
+
headers: dict[str, str] = None,
|
|
26
|
+
cookies: dict[str, str] = None,
|
|
27
|
+
):
|
|
28
|
+
self.bbot = bbot
|
|
29
|
+
self.fbot = fbot
|
|
30
|
+
self.agent: Agent = agent
|
|
31
|
+
self.actor: Actor = agent.actor
|
|
32
|
+
self.gmail = GmClient(agent.actor.person.user)
|
|
33
|
+
super().__init__(self.actor.ex.host_p2p, headers, cookies)
|
|
34
|
+
self.ex_client: BaseExClient = self.actor.ex.client(fbot)
|
|
19
35
|
|
|
20
36
|
# 0: Получшение ордеров в статусе status, по монете coin, в валюте coin, в направлении is_sell: bool
|
|
21
37
|
@abstractmethod
|
|
@@ -0,0 +1,10 @@
|
|
|
1
|
+
from PGram import Bot
|
|
2
|
+
from aiogram.types import Message
|
|
3
|
+
|
|
4
|
+
|
|
5
|
+
class HasAbotUid:
|
|
6
|
+
abot: Bot
|
|
7
|
+
uid: int
|
|
8
|
+
|
|
9
|
+
async def receive(self, text: str, photo: bytes = None, video: bytes = None) -> Message:
|
|
10
|
+
return await self.abot.send(self.uid, txt=text, photo=photo, video=video)
|
xync_client/Abc/InAgent.py
CHANGED
|
@@ -1,8 +1,10 @@
|
|
|
1
1
|
from abc import abstractmethod
|
|
2
2
|
|
|
3
3
|
from pyro_client.client.file import FileClient
|
|
4
|
+
from xync_bot import XyncBot
|
|
5
|
+
|
|
4
6
|
from xync_client.Abc.PmAgent import PmAgentClient
|
|
5
|
-
from xync_schema.models import
|
|
7
|
+
from xync_schema.models import Agent
|
|
6
8
|
|
|
7
9
|
from xync_client.Abc.Agent import BaseAgentClient
|
|
8
10
|
|
|
@@ -10,8 +12,8 @@ from xync_client.Abc.Agent import BaseAgentClient
|
|
|
10
12
|
class BaseInAgentClient:
|
|
11
13
|
pmacs: dict[int, PmAgentClient] = {}
|
|
12
14
|
|
|
13
|
-
def __init__(self,
|
|
14
|
-
self.agent_client: BaseAgentClient =
|
|
15
|
+
def __init__(self, agent: Agent, fbot: FileClient, bbot: XyncBot):
|
|
16
|
+
self.agent_client: BaseAgentClient = agent.client(fbot, bbot)
|
|
15
17
|
|
|
16
18
|
@abstractmethod
|
|
17
19
|
async def start_listen(self) -> bool: ...
|
xync_client/Abc/PmAgent.py
CHANGED
|
@@ -4,52 +4,57 @@ from datetime import datetime, timedelta
|
|
|
4
4
|
from decimal import Decimal
|
|
5
5
|
from enum import StrEnum
|
|
6
6
|
|
|
7
|
-
from
|
|
7
|
+
from PGram import Bot
|
|
8
|
+
from playwright.async_api import Page, Playwright, Browser
|
|
8
9
|
from pyro_client.client.file import FileClient
|
|
9
10
|
from pyro_client.client.user import UserClient
|
|
11
|
+
from tortoise.timezone import now
|
|
10
12
|
|
|
11
|
-
from xync_client.loader import NET_TOKEN
|
|
12
13
|
from xync_schema.enums import UserStatus
|
|
13
|
-
from xync_schema.models import PmAgent, User
|
|
14
|
+
from xync_schema.models import PmAgent, User, Transfer
|
|
15
|
+
|
|
16
|
+
from xync_client.Abc.HasAbotUid import HasAbotUid
|
|
14
17
|
|
|
15
18
|
|
|
16
19
|
class LoginFailedException(Exception): ...
|
|
17
20
|
|
|
18
21
|
|
|
19
|
-
class PmAgentClient(metaclass=ABCMeta):
|
|
22
|
+
class PmAgentClient(HasAbotUid, metaclass=ABCMeta):
|
|
20
23
|
class Pages(StrEnum):
|
|
21
24
|
base = "https://host"
|
|
22
25
|
LOGIN = base + "login"
|
|
23
26
|
SEND = base + "send"
|
|
24
27
|
OTP_LOGIN = base + "login/otp"
|
|
25
28
|
|
|
29
|
+
browser: Browser
|
|
26
30
|
norm: str
|
|
27
31
|
agent: PmAgent
|
|
28
|
-
|
|
32
|
+
ubot: FileClient | UserClient = None
|
|
29
33
|
page: Page
|
|
30
34
|
pages: type(StrEnum) = Pages
|
|
31
|
-
|
|
32
|
-
|
|
35
|
+
last_active: datetime = now()
|
|
36
|
+
with_userbot: bool = False
|
|
33
37
|
_is_started: bool = False
|
|
34
38
|
|
|
35
|
-
async def start(self, pw: Playwright, headed: bool = False
|
|
36
|
-
|
|
37
|
-
|
|
38
|
-
|
|
39
|
+
async def start(self, pw: Playwright, headed: bool = False) -> "PmAgentClient":
|
|
40
|
+
if self.with_userbot:
|
|
41
|
+
self.ubot = UserClient(self.uid)
|
|
42
|
+
await self.ubot.start()
|
|
39
43
|
|
|
40
44
|
self.browser = await pw.chromium.launch(
|
|
41
|
-
channel="
|
|
45
|
+
channel="chrome-beta" if headed else "chromium-headless-shell", headless=not headed
|
|
42
46
|
)
|
|
47
|
+
# noinspection PyTypeChecker
|
|
43
48
|
context = await self.browser.new_context(storage_state=self.agent.state)
|
|
44
49
|
self.page = await context.new_page()
|
|
45
|
-
await self.page.goto(self.pages.SEND) # Оптимистично переходим сразу на страницу отправки
|
|
50
|
+
await self.page.goto(self.pages.SEND, wait_until="commit") # Оптимистично переходим сразу на страницу отправки
|
|
46
51
|
if self.page.url.startswith(self.pages.LOGIN): # Если перебросило на страницу логина
|
|
47
52
|
await self._login() # Логинимся
|
|
48
53
|
if not self.page.url.startswith(self.pages.SEND): # Если в итоге не удалось попасть на отправку
|
|
49
|
-
await self.
|
|
54
|
+
await self.receive(self.norm + " not logged in!", photo=await self.page.screenshot())
|
|
50
55
|
raise LoginFailedException(f"User {self.agent.user_id} has not logged in")
|
|
51
56
|
loop = get_running_loop()
|
|
52
|
-
self.last_active =
|
|
57
|
+
self.last_active = now()
|
|
53
58
|
loop.create_task(self._idle()) # Бесконечно пасёмся в фоне на странице отправки, что бы куки не протухли
|
|
54
59
|
self._is_started = True
|
|
55
60
|
return self
|
|
@@ -59,18 +64,21 @@ class PmAgentClient(metaclass=ABCMeta):
|
|
|
59
64
|
async def _idle(self): # todo: не мешать другим процессам, обновлять на другой вкладке?
|
|
60
65
|
while (await User.get(username_id=self.uid)).status >= UserStatus.ACTIVE:
|
|
61
66
|
await self.page.wait_for_timeout(30 * 1000)
|
|
62
|
-
if self.last_active <
|
|
63
|
-
await self.page.reload()
|
|
64
|
-
self.last_active =
|
|
65
|
-
await self.
|
|
67
|
+
if self.last_active < now() - timedelta(minutes=1):
|
|
68
|
+
await self.page.reload(wait_until="commit")
|
|
69
|
+
self.last_active = now()
|
|
70
|
+
await self.receive(self.norm + " stoped")
|
|
66
71
|
await self.stop()
|
|
67
72
|
|
|
68
73
|
async def stop(self):
|
|
69
74
|
# save state
|
|
75
|
+
# noinspection PyTypeChecker
|
|
70
76
|
self.agent.state = await self.page.context.storage_state()
|
|
71
77
|
await self.agent.save()
|
|
72
78
|
# closing
|
|
73
|
-
await self.
|
|
79
|
+
await self.abot.stop()
|
|
80
|
+
if self.ubot:
|
|
81
|
+
await self.ubot.stop()
|
|
74
82
|
await self.page.context.close()
|
|
75
83
|
await self.page.context.browser.close()
|
|
76
84
|
self._is_started = False
|
|
@@ -79,15 +87,18 @@ class PmAgentClient(metaclass=ABCMeta):
|
|
|
79
87
|
async def _login(self): ...
|
|
80
88
|
|
|
81
89
|
@abstractmethod
|
|
82
|
-
async def send(self,
|
|
90
|
+
async def send(self, t: Transfer) -> tuple[int, bytes] | float: ...
|
|
83
91
|
|
|
84
92
|
@abstractmethod # проверка поступления определенной суммы за последние пол часа (минимум), return точную сумму
|
|
85
|
-
async def check_in(
|
|
93
|
+
async def check_in(
|
|
94
|
+
self, amount: int | Decimal | float, cur: str, dt: datetime, tid: str | int = None
|
|
95
|
+
) -> float | None: ...
|
|
86
96
|
|
|
87
97
|
@abstractmethod # видео входа в аккаунт, и переход в историю поступлений за последние сутки (минимум)
|
|
88
98
|
async def proof(self) -> bytes: ...
|
|
89
99
|
|
|
90
|
-
def __init__(self, agent: PmAgent):
|
|
100
|
+
def __init__(self, agent: PmAgent, abot: Bot):
|
|
91
101
|
self.agent = agent
|
|
102
|
+
self.abot = abot
|
|
92
103
|
self.uid = agent.user.username_id
|
|
93
104
|
self.norm = agent.pm.norm
|
xync_client/Abc/xtype.py
CHANGED
|
@@ -53,7 +53,9 @@ class BaseOrderReq(BaseModel):
|
|
|
53
53
|
asset_amount: float | None = None
|
|
54
54
|
fiat_amount: float | None = None
|
|
55
55
|
|
|
56
|
-
|
|
56
|
+
pm_id: int = (None,)
|
|
57
|
+
|
|
58
|
+
# todo: mv from base to special ex class
|
|
57
59
|
amount_is_fiat: bool = True
|
|
58
60
|
is_sell: bool = None
|
|
59
61
|
cur_exid: int | str = None
|
xync_client/Bybit/InAgent.py
CHANGED
|
@@ -1,6 +1,7 @@
|
|
|
1
1
|
import json
|
|
2
2
|
import logging
|
|
3
3
|
import re
|
|
4
|
+
import traceback
|
|
4
5
|
from datetime import datetime, timezone, timedelta
|
|
5
6
|
from uuid import uuid4
|
|
6
7
|
|
|
@@ -14,6 +15,7 @@ from pyro_client.client.file import FileClient
|
|
|
14
15
|
from tortoise.exceptions import IntegrityError
|
|
15
16
|
from tortoise.timezone import now
|
|
16
17
|
from tortoise.transactions import in_transaction
|
|
18
|
+
from xync_bot import XyncBot
|
|
17
19
|
|
|
18
20
|
from xync_client.Abc.PmAgent import PmAgentClient
|
|
19
21
|
from xync_schema import models
|
|
@@ -28,7 +30,7 @@ from xync_client.Bybit.etype.order import (
|
|
|
28
30
|
OrderFull,
|
|
29
31
|
StatusApi,
|
|
30
32
|
)
|
|
31
|
-
from xync_client.loader import NET_TOKEN
|
|
33
|
+
from xync_client.loader import NET_TOKEN, PAY_TOKEN
|
|
32
34
|
from xync_client.Abc.InAgent import BaseInAgentClient
|
|
33
35
|
from xync_client.Bybit.agent import AgentClient
|
|
34
36
|
|
|
@@ -39,7 +41,7 @@ class InAgentClient(BaseInAgentClient):
|
|
|
39
41
|
async def start_listen(self):
|
|
40
42
|
t = await self.agent_client.ott()
|
|
41
43
|
ts = int(float(t["time_now"]) * 1000)
|
|
42
|
-
await self.ws_prv(self.agent_client.
|
|
44
|
+
await self.ws_prv(self.agent_client.agent.auth["deviceId"], t["result"], ts)
|
|
43
45
|
|
|
44
46
|
# 3N: [T] - Уведомление об одобрении запроса на сделку
|
|
45
47
|
async def request_accepted_notify(self) -> int: ... # id
|
|
@@ -75,7 +77,7 @@ class InAgentClient(BaseInAgentClient):
|
|
|
75
77
|
while resp := await websocket.recv():
|
|
76
78
|
if data := json.loads(resp):
|
|
77
79
|
upd, order_db = None, None
|
|
78
|
-
logging.info(f" {
|
|
80
|
+
logging.info(f" {now().strftime('%H:%M:%S')} upd: {data.get('topic')}:{data.get('type')}")
|
|
79
81
|
match data.get("topic"):
|
|
80
82
|
case "OTC_ORDER_STATUS":
|
|
81
83
|
match data["type"]:
|
|
@@ -96,20 +98,21 @@ class InAgentClient(BaseInAgentClient):
|
|
|
96
98
|
# сразу уменьшаем доступный остаток монеты/валюты
|
|
97
99
|
await self.money_upd(order_db)
|
|
98
100
|
if upd.side: # я покупатель - ждем мою оплату
|
|
99
|
-
|
|
100
|
-
if not re.match(r"^([PpРр])\d{7,10}\b",
|
|
101
|
+
_dest = order.paymentTermList[0].accountNo
|
|
102
|
+
if not re.match(r"^([PpРр])\d{7,10}\b", _dest):
|
|
101
103
|
continue
|
|
102
104
|
await order_db.fetch_related("ad__pair_side__pair", "cred__pmcur__cur")
|
|
103
|
-
await self.send_payment(order_db
|
|
105
|
+
await self.send_payment(order_db)
|
|
104
106
|
case StatusApi.wait_for_buyer:
|
|
105
107
|
if upd.side == 0: # ждем когда покупатель оплатит
|
|
106
108
|
if not (pmacdx := await self.get_pma_by_cdex(order)):
|
|
107
109
|
continue
|
|
108
110
|
pma, cdx = pmacdx
|
|
109
|
-
am, tid = pma.check_in(
|
|
111
|
+
am, tid = await pma.check_in(
|
|
110
112
|
Decimal(order.amount),
|
|
111
113
|
cdx.cred.pmcur.cur.ticker,
|
|
112
|
-
|
|
114
|
+
# todo: почему в московском час.поясе?
|
|
115
|
+
datetime.fromtimestamp(float(order.transferDate) / 1000),
|
|
113
116
|
)
|
|
114
117
|
if not tid:
|
|
115
118
|
logging.info(
|
|
@@ -140,9 +143,13 @@ class InAgentClient(BaseInAgentClient):
|
|
|
140
143
|
if (
|
|
141
144
|
o["amount"] == order.amount
|
|
142
145
|
and o["id"] != upd.id
|
|
143
|
-
and
|
|
146
|
+
and int(order.createDate)
|
|
147
|
+
< int(o["createDate"]) + 15 * 60 * 1000
|
|
148
|
+
# get full_order from o, and cred or pm from full_order:
|
|
149
|
+
and self.agent_client.api.get_order_details(orderId=o["id"])[
|
|
150
|
+
"result"
|
|
151
|
+
]["paymentTermList"][0]["accountNo"]
|
|
144
152
|
== order.paymentTermList[0].accountNo
|
|
145
|
-
and int(order.createDate) < int(o["createDate"]) + 3600 * 000
|
|
146
153
|
)
|
|
147
154
|
]
|
|
148
155
|
curex = await models.CurEx.get(
|
|
@@ -153,7 +160,7 @@ class InAgentClient(BaseInAgentClient):
|
|
|
153
160
|
cred_id=order_db.cred_id,
|
|
154
161
|
amount=int(float(order.amount) * 10**curex.scale),
|
|
155
162
|
status__not_in=[OrderStatus.completed, OrderStatus.canceled],
|
|
156
|
-
created_at__gt=now() - timedelta(
|
|
163
|
+
created_at__gt=now() - timedelta(minutes=15),
|
|
157
164
|
)
|
|
158
165
|
if pos or pos_db:
|
|
159
166
|
await self.agent_client.ex_client.bot.send(
|
|
@@ -167,10 +174,10 @@ class InAgentClient(BaseInAgentClient):
|
|
|
167
174
|
# !!! ОТПРАВЛЯЕМ ДЕНЬГИ !!!
|
|
168
175
|
self.agent_client.api.release_assets(orderId=upd.id)
|
|
169
176
|
logging.info(
|
|
170
|
-
f"Order {order.id} created, paid before #{tid}:{am} at {order.createDate}, and RELEASED at {
|
|
177
|
+
f"Order {order.id} created, paid before #{tid}:{am} at {order.createDate}, and RELEASED at {now()}"
|
|
171
178
|
)
|
|
172
179
|
elif upd.side == 1: # я покупатель - ждем мою оплату
|
|
173
|
-
continue # logging.warning(f"Order {order.id} PAID at {
|
|
180
|
+
continue # logging.warning(f"Order {order.id} PAID at {now()}: {int_am}")
|
|
174
181
|
else:
|
|
175
182
|
...
|
|
176
183
|
# todo: check is always canceling
|
|
@@ -245,7 +252,10 @@ class InAgentClient(BaseInAgentClient):
|
|
|
245
252
|
if not upd.message:
|
|
246
253
|
...
|
|
247
254
|
if im_buyer and (g := re.match(r"^[PpРр]\d{7,10}\b", upd.message)):
|
|
248
|
-
|
|
255
|
+
if not order_db.cred.detail.startswith(dest := g.group()):
|
|
256
|
+
order_db.cred.detail = dest
|
|
257
|
+
await order_db.save()
|
|
258
|
+
await self.send_payment(order_db)
|
|
249
259
|
case "READ":
|
|
250
260
|
upd = Read.model_validate(data["data"])
|
|
251
261
|
# if upd.status not in (StatusWs.created, StatusWs.canceled, 10, StatusWs.completed):
|
|
@@ -318,7 +328,7 @@ class InAgentClient(BaseInAgentClient):
|
|
|
318
328
|
await fiat.save(update_fields=["amount"])
|
|
319
329
|
logging.info(f"Order #{order_db.id} {order_db.status.name}. Fiat: {fiat.amount}, Asset: {ass.free}")
|
|
320
330
|
|
|
321
|
-
async def send_payment(self, order_db: models.Order
|
|
331
|
+
async def send_payment(self, order_db: models.Order):
|
|
322
332
|
if order_db.status != OrderStatus.created:
|
|
323
333
|
return
|
|
324
334
|
fmt_am = round(order_db.amount * 10**-2, 2)
|
|
@@ -335,19 +345,23 @@ class InAgentClient(BaseInAgentClient):
|
|
|
335
345
|
# проверяем не отправляли ли мы уже перевод по этому ордеру
|
|
336
346
|
if t := await models.Transfer.get_or_none(order=order_db, amount=order_db.amount):
|
|
337
347
|
await pma.bot.send(
|
|
338
|
-
f"Order# {order_db.exid}: Double send {fmt_am}{cur} to {
|
|
348
|
+
f"Order# {order_db.exid}: Double send {fmt_am}{cur} to {order_db.cred.detail} #{t.pmid}!",
|
|
339
349
|
self.agent_client.actor.person.user.username_id,
|
|
340
350
|
)
|
|
341
|
-
raise Exception(
|
|
351
|
+
raise Exception(
|
|
352
|
+
f"Order# {order_db.exid}: Double send {fmt_am}{cur} to {order_db.cred.detail} #{t.pmid}!"
|
|
353
|
+
)
|
|
342
354
|
|
|
343
355
|
# ставим в бд статус "оплачен"
|
|
344
356
|
order_db.status = OrderStatus.paid
|
|
345
357
|
order_db.payed_at = datetime.now(timezone.utc)
|
|
346
358
|
await order_db.save()
|
|
347
|
-
# отправляем деньги
|
|
348
|
-
tid, img, rest_amount = await pma.send(dest=dest, amount=fmt_am, cur=cur)
|
|
349
359
|
# создаем перевод в бд
|
|
350
|
-
t
|
|
360
|
+
t = models.Transfer(order=order_db, amount=order_db.amount, updated_at=now())
|
|
361
|
+
# отправляем деньги
|
|
362
|
+
tid, img = await pma.send(t)
|
|
363
|
+
t.pmid = tid
|
|
364
|
+
await t.save()
|
|
351
365
|
await self.send_receipt(str(order_db.exid), tid) # отправляем продавцу чек
|
|
352
366
|
logging.info(f"Order {order_db.exid} PAID at {datetime.now()}: {fmt_am}!")
|
|
353
367
|
|
|
@@ -396,33 +410,41 @@ async def main():
|
|
|
396
410
|
from x_model import init_db
|
|
397
411
|
from xync_client.loader import TORM
|
|
398
412
|
|
|
399
|
-
|
|
413
|
+
cn = await init_db(TORM, True)
|
|
400
414
|
logging.basicConfig(level=logging.INFO)
|
|
401
415
|
|
|
402
|
-
|
|
403
|
-
await models.
|
|
404
|
-
|
|
405
|
-
|
|
406
|
-
|
|
407
|
-
|
|
416
|
+
agent = (
|
|
417
|
+
await models.Agent.filter(
|
|
418
|
+
actor__ex_id=4,
|
|
419
|
+
active=True,
|
|
420
|
+
auth__isnull=False,
|
|
421
|
+
actor__person__user__status=UserStatus.ACTIVE,
|
|
422
|
+
actor__person__user__pm_agents__isnull=False,
|
|
408
423
|
)
|
|
409
|
-
.prefetch_related("
|
|
424
|
+
.prefetch_related("actor__ex", "actor__person__user__gmail")
|
|
410
425
|
.first()
|
|
411
426
|
)
|
|
427
|
+
pm_agents = await models.PmAgent.filter(
|
|
428
|
+
active=True,
|
|
429
|
+
auth__isnull=False,
|
|
430
|
+
user__status=UserStatus.ACTIVE,
|
|
431
|
+
).prefetch_related("pm", "user__gmail")
|
|
432
|
+
|
|
433
|
+
bbot = XyncBot(PAY_TOKEN, cn)
|
|
412
434
|
|
|
413
435
|
async with FileClient(NET_TOKEN) as b:
|
|
414
436
|
b: FileClient
|
|
415
|
-
cl: InAgentClient =
|
|
437
|
+
cl: InAgentClient = agent.in_client(b, bbot)
|
|
416
438
|
# await cl.agent_client.export_my_ads()
|
|
417
439
|
# payeer_cl = Client(actor.person.user.username_id)
|
|
418
|
-
for pma in
|
|
419
|
-
pcl = pma.client()
|
|
440
|
+
for pma in pm_agents:
|
|
441
|
+
pcl: PmAgentClient = pma.client(bbot)
|
|
420
442
|
cl.pmacs[pma.pm_id] = await pcl.start(await async_playwright().start(), False)
|
|
421
443
|
try:
|
|
422
444
|
_ = await cl.start_listen()
|
|
423
445
|
except Exception as e:
|
|
424
|
-
await b.send("😱Bybit InAgent CRASHED!!!😱", actor.person.user.username_id)
|
|
425
|
-
await b.send(
|
|
446
|
+
await b.send("😱Bybit InAgent CRASHED!!!😱", agent.actor.person.user.username_id)
|
|
447
|
+
await b.send(f"```\n{''.join(traceback.format_exception(e))}\n```", agent.actor.person.user.username_id)
|
|
426
448
|
await cl.agent_client.close()
|
|
427
449
|
|
|
428
450
|
|