xync-client 0.0.114__py3-none-any.whl → 0.0.155__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.
Files changed (39) hide show
  1. xync_client/Abc/AdLoader.py +299 -0
  2. xync_client/Abc/Agent.py +94 -10
  3. xync_client/Abc/Ex.py +27 -22
  4. xync_client/Abc/HasAbotUid.py +10 -0
  5. xync_client/Abc/InAgent.py +0 -11
  6. xync_client/Abc/PmAgent.py +42 -35
  7. xync_client/Abc/xtype.py +24 -2
  8. xync_client/Binance/ex.py +2 -2
  9. xync_client/BingX/ex.py +2 -2
  10. xync_client/BitGet/ex.py +2 -2
  11. xync_client/Bybit/InAgent.py +229 -114
  12. xync_client/Bybit/agent.py +584 -572
  13. xync_client/Bybit/etype/ad.py +11 -56
  14. xync_client/Bybit/etype/cred.py +29 -9
  15. xync_client/Bybit/etype/order.py +55 -62
  16. xync_client/Bybit/ex.py +17 -4
  17. xync_client/Gate/ex.py +2 -2
  18. xync_client/Gmail/__init__.py +119 -98
  19. xync_client/Htx/agent.py +162 -31
  20. xync_client/Htx/etype/ad.py +18 -11
  21. xync_client/Htx/ex.py +9 -11
  22. xync_client/KuCoin/ex.py +2 -2
  23. xync_client/Mexc/agent.py +85 -0
  24. xync_client/Mexc/api.py +636 -0
  25. xync_client/Mexc/etype/order.py +639 -0
  26. xync_client/Mexc/ex.py +12 -10
  27. xync_client/Okx/ex.py +2 -2
  28. xync_client/Pms/Payeer/__init__.py +147 -43
  29. xync_client/Pms/Payeer/login.py +29 -2
  30. xync_client/Pms/Volet/__init__.py +148 -94
  31. xync_client/Pms/Volet/api.py +17 -13
  32. xync_client/TgWallet/ex.py +2 -2
  33. xync_client/details.py +44 -0
  34. xync_client/loader.py +2 -1
  35. xync_client/pm_unifier.py +1 -1
  36. {xync_client-0.0.114.dist-info → xync_client-0.0.155.dist-info}/METADATA +6 -1
  37. {xync_client-0.0.114.dist-info → xync_client-0.0.155.dist-info}/RECORD +39 -33
  38. {xync_client-0.0.114.dist-info → xync_client-0.0.155.dist-info}/WHEEL +0 -0
  39. {xync_client-0.0.114.dist-info → xync_client-0.0.155.dist-info}/top_level.txt +0 -0
@@ -4,76 +4,77 @@ from datetime import datetime, timedelta
4
4
  from decimal import Decimal
5
5
  from enum import StrEnum
6
6
 
7
- from playwright.async_api import Page, Playwright
7
+ from PGram import Bot
8
+ from playwright.async_api import Page, Browser
8
9
  from pyro_client.client.file import FileClient
9
- from xync_client.loader import TOKEN
10
+ from pyro_client.client.user import UserClient
11
+ from tortoise.timezone import now
12
+
10
13
  from xync_schema.enums import UserStatus
11
- 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
12
17
 
13
18
 
14
19
  class LoginFailedException(Exception): ...
15
20
 
16
21
 
17
- class PmAgentClient(metaclass=ABCMeta):
22
+ class PmAgentClient(HasAbotUid, metaclass=ABCMeta):
18
23
  class Pages(StrEnum):
19
24
  base = "https://host"
20
25
  LOGIN = base + "login"
21
26
  SEND = base + "send"
22
27
  OTP_LOGIN = base + "login/otp"
23
28
 
29
+ browser: Browser
24
30
  norm: str
25
- uid: int
26
31
  agent: PmAgent
27
- bot: FileClient
32
+ ubot: FileClient | UserClient = None
28
33
  page: Page
29
34
  pages: type(StrEnum) = Pages
30
- last_page: int = 0
31
- last_active: datetime = datetime.now()
35
+ last_active: datetime = now()
36
+ with_userbot: bool = False
32
37
  _is_started: bool = False
33
38
 
34
- async def start(self, pw: Playwright, headed: bool = False) -> "PmAgentClient":
35
- dct = dict(user__status__gte=UserStatus.PAY, pm__norm=self.norm)
36
- if self.uid:
37
- dct.update({"user__username_id": self.uid})
38
-
39
- self.bot = FileClient(TOKEN)
40
- await self.bot.start()
41
-
42
- self.agent = await PmAgent.get_or_none(**dct).prefetch_related("user__username__session")
43
- if not self.agent:
44
- await self.bot.send(f"No active users with agent for {self.norm}!", self.uid)
45
- raise Exception(f"No active users for {self.norm}!")
46
-
47
- self.browser = await pw.chromium.launch(channel="chrome", headless=not headed)
39
+ async def start(self) -> "PmAgentClient":
40
+ if self.with_userbot:
41
+ self.ubot = UserClient(self.uid)
42
+ await self.ubot.start()
43
+ # noinspection PyTypeChecker
48
44
  context = await self.browser.new_context(storage_state=self.agent.state)
49
45
  self.page = await context.new_page()
50
- await self.page.goto(self.pages.SEND) # Оптимистично переходим сразу на страницу отправки
46
+ await self.page.goto(self.pages.SEND, wait_until="commit") # Оптимистично переходим сразу на страницу отправки
51
47
  if self.page.url.startswith(self.pages.LOGIN): # Если перебросило на страницу логина
52
48
  await self._login() # Логинимся
53
49
  if not self.page.url.startswith(self.pages.SEND): # Если в итоге не удалось попасть на отправку
54
- await self.bot.send(self.norm + " not logged in!", self.uid, photo=await self.page.screenshot())
50
+ await self.receive(self.norm + " not logged in!", photo=await self.page.screenshot())
55
51
  raise LoginFailedException(f"User {self.agent.user_id} has not logged in")
56
52
  loop = get_running_loop()
57
- self.last_active = datetime.now()
53
+ self.last_active = now()
58
54
  loop.create_task(self._idle()) # Бесконечно пасёмся в фоне на странице отправки, что бы куки не протухли
59
55
  self._is_started = True
60
56
  return self
61
57
 
58
+ def get_topup(self, tid: str) -> dict: ...
59
+
62
60
  async def _idle(self): # todo: не мешать другим процессам, обновлять на другой вкладке?
63
61
  while (await User.get(username_id=self.uid)).status >= UserStatus.ACTIVE:
64
- await self.page.wait_for_timeout(15 * 1000)
65
- if self.last_active < datetime.now() - timedelta(seconds=20):
66
- await self.page.reload()
67
- self.last_active = datetime.now()
68
- await self.bot.send(self.norm + " stoped", self.uid)
62
+ await self.page.wait_for_timeout(30 * 1000)
63
+ if self.last_active < now() - timedelta(minutes=1):
64
+ await self.page.reload(wait_until="commit")
65
+ self.last_active = now()
66
+ await self.receive(self.norm + " stoped")
69
67
  await self.stop()
70
68
 
71
69
  async def stop(self):
72
70
  # save state
71
+ # noinspection PyTypeChecker
73
72
  self.agent.state = await self.page.context.storage_state()
74
73
  await self.agent.save()
75
74
  # closing
76
- await self.bot.stop()
75
+ await self.abot.stop()
76
+ if self.ubot:
77
+ await self.ubot.stop()
77
78
  await self.page.context.close()
78
79
  await self.page.context.browser.close()
79
80
  self._is_started = False
@@ -82,13 +83,19 @@ class PmAgentClient(metaclass=ABCMeta):
82
83
  async def _login(self): ...
83
84
 
84
85
  @abstractmethod
85
- async def send(self, dest, amount: int, cur: str) -> tuple[int, bytes, float]: ...
86
+ async def send(self, t: Transfer) -> tuple[int, bytes] | float: ...
86
87
 
87
88
  @abstractmethod # проверка поступления определенной суммы за последние пол часа (минимум), return точную сумму
88
- async def check_in(self, amount: int | Decimal | float, cur: str, tid: str | int = None) -> float | None: ...
89
+ async def check_in(
90
+ self, amount: int | Decimal | float, cur: str, dt: datetime, tid: str | int = None
91
+ ) -> float | None: ...
89
92
 
90
93
  @abstractmethod # видео входа в аккаунт, и переход в историю поступлений за последние сутки (минимум)
91
94
  async def proof(self) -> bytes: ...
92
95
 
93
- def __init__(self, uid: int = None):
94
- self.uid = uid
96
+ def __init__(self, agent: PmAgent, browser: Browser, abot: Bot):
97
+ self.agent = agent
98
+ self.browser = browser
99
+ self.abot = abot
100
+ self.uid = agent.user.username_id
101
+ self.norm = agent.pm.norm
xync_client/Abc/xtype.py CHANGED
@@ -3,7 +3,7 @@ from typing import Literal
3
3
  from pydantic import BaseModel, model_validator
4
4
  from x_model.types import BaseUpd
5
5
  from xync_schema.enums import PmType
6
- from xync_schema.models import Country, Pm, Ex
6
+ from xync_schema.models import Country, Pm, Ex, CredEx
7
7
  from xync_schema.xtype import PmExBank
8
8
 
9
9
  from xync_client.pm_unifier import PmUni
@@ -53,7 +53,9 @@ class BaseOrderReq(BaseModel):
53
53
  asset_amount: float | None = None
54
54
  fiat_amount: float | None = None
55
55
 
56
- # todo: mv from to base to special ex class
56
+ pmex_exid: str = None # int
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
@@ -106,3 +108,23 @@ class BaseCad(BaseAdUpdate):
106
108
  side: Literal[0, 1] # 0 - покупка, 1 - продажа
107
109
  tokenId: str
108
110
  userId: str
111
+
112
+
113
+ class GetAds(BaseModel):
114
+ coin_id: int | str
115
+ cur_id: int | str
116
+ is_sell: bool
117
+ pm_ids: list[int | str] | None = None
118
+ amount: int | None = None
119
+
120
+
121
+ class AdUpd(BaseAdUpdate, GetAds):
122
+ price: float
123
+ pm_ids: list[int | str]
124
+ amount: float
125
+ premium: float | None = None
126
+ credexs: list[CredEx] | None = None
127
+ quantity: float | None = None
128
+
129
+ class Config:
130
+ arbitrary_types_allowed = True
xync_client/Binance/ex.py CHANGED
@@ -6,7 +6,7 @@ from x_model import init_db
6
6
  from xync_client.Abc.Ex import BaseExClient
7
7
  from xync_client.Binance.etype import pm, ad
8
8
  from xync_client.Abc.xtype import PmEx, MapOfIdsList
9
- from xync_client.loader import TOKEN, TORM
9
+ from xync_client.loader import NET_TOKEN, TORM
10
10
 
11
11
  from xync_schema.models import Ex
12
12
  from xync_schema import xtype
@@ -139,7 +139,7 @@ class ExClient(BaseExClient):
139
139
  async def main():
140
140
  _ = await init_db(TORM)
141
141
  ex = await Ex.get(name="Binance")
142
- async with FileClient(TOKEN) as b:
142
+ async with FileClient(NET_TOKEN) as b:
143
143
  cl = ExClient(ex, b)
144
144
  await cl.set_pms()
145
145
  await cl.set_coins()
xync_client/BingX/ex.py CHANGED
@@ -8,7 +8,7 @@ from xync_schema import xtype
8
8
 
9
9
  from xync_client.Abc.Ex import BaseExClient
10
10
  from xync_client.BingX.base import BaseBingXClient
11
- from xync_client.loader import TOKEN, TORM
11
+ from xync_client.loader import NET_TOKEN, TORM
12
12
  from xync_client.Abc.xtype import MapOfIdsList
13
13
  from xync_client.BingX.etype import ad, pm
14
14
  from xync_client.Abc.xtype import PmEx
@@ -93,7 +93,7 @@ class ExClient(BaseExClient, BaseBingXClient):
93
93
  async def main():
94
94
  _ = await init_db(TORM, True)
95
95
  bg = await Ex.get(name="BingX").prefetch_related("pm_reps")
96
- async with FileClient(TOKEN) as b:
96
+ async with FileClient(NET_TOKEN) as b:
97
97
  b: FileClient
98
98
  cl = ExClient(bg, b)
99
99
  _ads = await cl.ads(
xync_client/BitGet/ex.py CHANGED
@@ -6,7 +6,7 @@ from xync_schema.models import Ex
6
6
  from xync_schema import xtype
7
7
 
8
8
  from xync_client.Abc.Ex import BaseExClient
9
- from xync_client.loader import TORM, TOKEN
9
+ from xync_client.loader import TORM, NET_TOKEN
10
10
  from xync_client.Abc.xtype import PmEx, MapOfIdsList
11
11
  from xync_client.BitGet.etype import ad
12
12
 
@@ -94,7 +94,7 @@ class ExClient(BaseExClient):
94
94
  async def main():
95
95
  _ = await init_db(TORM, True)
96
96
  bg = await Ex.get(name="BitGet")
97
- cl = ExClient(bg, FileClient(TOKEN))
97
+ cl = ExClient(bg, FileClient(NET_TOKEN))
98
98
  _ads = await cl.ads("USDT", "RUB", False, [])
99
99
  await cl.curs()
100
100
  await cl.coins()