xync-client 0.0.25.dev100__tar.gz → 0.0.25.dev101__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.
- {xync_client-0.0.25.dev100/xync_client.egg-info → xync_client-0.0.25.dev101}/PKG-INFO +3 -2
- {xync_client-0.0.25.dev100 → xync_client-0.0.25.dev101}/pyproject.toml +2 -2
- {xync_client-0.0.25.dev100 → xync_client-0.0.25.dev101}/xync_client/Abc/Ex.py +13 -0
- xync_client-0.0.25.dev101/xync_client/TgWallet/pyro.py +156 -0
- {xync_client-0.0.25.dev100 → xync_client-0.0.25.dev101/xync_client.egg-info}/PKG-INFO +3 -2
- {xync_client-0.0.25.dev100 → xync_client-0.0.25.dev101}/xync_client.egg-info/requires.txt +2 -1
- xync_client-0.0.25.dev100/xync_client/TgWallet/pyro.py +0 -52
- {xync_client-0.0.25.dev100 → xync_client-0.0.25.dev101}/.env.sample +0 -0
- {xync_client-0.0.25.dev100 → xync_client-0.0.25.dev101}/.gitignore +0 -0
- {xync_client-0.0.25.dev100 → xync_client-0.0.25.dev101}/.pre-commit-config.yaml +0 -0
- {xync_client-0.0.25.dev100 → xync_client-0.0.25.dev101}/README.md +0 -0
- {xync_client-0.0.25.dev100 → xync_client-0.0.25.dev101}/makefile +0 -0
- {xync_client-0.0.25.dev100 → xync_client-0.0.25.dev101}/setup.cfg +0 -0
- {xync_client-0.0.25.dev100 → xync_client-0.0.25.dev101}/tests/TestAgent.py +0 -0
- {xync_client-0.0.25.dev100 → xync_client-0.0.25.dev101}/tests/TestAsset.py +0 -0
- {xync_client-0.0.25.dev100 → xync_client-0.0.25.dev101}/tests/TestEx.py +0 -0
- {xync_client-0.0.25.dev100 → xync_client-0.0.25.dev101}/tests/TestOrder.py +0 -0
- {xync_client-0.0.25.dev100 → xync_client-0.0.25.dev101}/tests/_todo_refact/Binance/test_binance.py +0 -0
- {xync_client-0.0.25.dev100 → xync_client-0.0.25.dev101}/tests/_todo_refact/Bybit/test_bybit.py +0 -0
- {xync_client-0.0.25.dev100 → xync_client-0.0.25.dev101}/tests/_todo_refact/Bybit/test_bybit_p2p.py +0 -0
- {xync_client-0.0.25.dev100 → xync_client-0.0.25.dev101}/tests/_todo_refact/Gate/test_gate.py +0 -0
- {xync_client-0.0.25.dev100 → xync_client-0.0.25.dev101}/tests/_todo_refact/Htx/test_htx_p2p.py +0 -0
- {xync_client-0.0.25.dev100 → xync_client-0.0.25.dev101}/tests/_todo_refact/Wallet/test_agent.py +0 -0
- {xync_client-0.0.25.dev100 → xync_client-0.0.25.dev101}/tests/_todo_refact/Wallet/test_ex.py +0 -0
- {xync_client-0.0.25.dev100 → xync_client-0.0.25.dev101}/tests/_todo_refact/__init__.py +0 -0
- {xync_client-0.0.25.dev100 → xync_client-0.0.25.dev101}/tests/_todo_refact/_test_ex.py +0 -0
- {xync_client-0.0.25.dev100 → xync_client-0.0.25.dev101}/tests/res.js +0 -0
- {xync_client-0.0.25.dev100 → xync_client-0.0.25.dev101}/xync_client/Abc/Agent.py +0 -0
- {xync_client-0.0.25.dev100 → xync_client-0.0.25.dev101}/xync_client/Abc/Asset.py +0 -0
- {xync_client-0.0.25.dev100 → xync_client-0.0.25.dev101}/xync_client/Abc/AuthTrait.py +0 -0
- {xync_client-0.0.25.dev100 → xync_client-0.0.25.dev101}/xync_client/Abc/Base.py +0 -0
- {xync_client-0.0.25.dev100 → xync_client-0.0.25.dev101}/xync_client/Abc/BaseTest.py +0 -0
- {xync_client-0.0.25.dev100 → xync_client-0.0.25.dev101}/xync_client/Abc/InAgent.py +0 -0
- {xync_client-0.0.25.dev100 → xync_client-0.0.25.dev101}/xync_client/Abc/Order.py +0 -0
- {xync_client-0.0.25.dev100 → xync_client-0.0.25.dev101}/xync_client/Abc/types.py +0 -0
- {xync_client-0.0.25.dev100 → xync_client-0.0.25.dev101}/xync_client/Binance/__init__.py +0 -0
- {xync_client-0.0.25.dev100 → xync_client-0.0.25.dev101}/xync_client/Binance/binance_async.py +0 -0
- {xync_client-0.0.25.dev100 → xync_client-0.0.25.dev101}/xync_client/Binance/earn_api.py +0 -0
- {xync_client-0.0.25.dev100 → xync_client-0.0.25.dev101}/xync_client/Binance/etype/ad.py +0 -0
- {xync_client-0.0.25.dev100 → xync_client-0.0.25.dev101}/xync_client/Binance/etype/pm.py +0 -0
- {xync_client-0.0.25.dev100 → xync_client-0.0.25.dev101}/xync_client/Binance/ex.py +0 -0
- {xync_client-0.0.25.dev100 → xync_client-0.0.25.dev101}/xync_client/Binance/exceptions.py +0 -0
- {xync_client-0.0.25.dev100 → xync_client-0.0.25.dev101}/xync_client/Binance/sapi.py +0 -0
- {xync_client-0.0.25.dev100 → xync_client-0.0.25.dev101}/xync_client/Binance/web_c2c.py +0 -0
- {xync_client-0.0.25.dev100 → xync_client-0.0.25.dev101}/xync_client/BingX/__init__.py +0 -0
- {xync_client-0.0.25.dev100 → xync_client-0.0.25.dev101}/xync_client/BingX/agent.py +0 -0
- {xync_client-0.0.25.dev100 → xync_client-0.0.25.dev101}/xync_client/BingX/base.py +0 -0
- {xync_client-0.0.25.dev100 → xync_client-0.0.25.dev101}/xync_client/BingX/etype/ad.py +0 -0
- {xync_client-0.0.25.dev100 → xync_client-0.0.25.dev101}/xync_client/BingX/etype/pm.py +0 -0
- {xync_client-0.0.25.dev100 → xync_client-0.0.25.dev101}/xync_client/BingX/ex.py +0 -0
- {xync_client-0.0.25.dev100 → xync_client-0.0.25.dev101}/xync_client/BingX/req.mjs +0 -0
- {xync_client-0.0.25.dev100 → xync_client-0.0.25.dev101}/xync_client/BingX/sign.js +0 -0
- {xync_client-0.0.25.dev100 → xync_client-0.0.25.dev101}/xync_client/BitGet/__init__.py +0 -0
- {xync_client-0.0.25.dev100 → xync_client-0.0.25.dev101}/xync_client/BitGet/agent.py +0 -0
- {xync_client-0.0.25.dev100 → xync_client-0.0.25.dev101}/xync_client/BitGet/etype/ad.py +0 -0
- {xync_client-0.0.25.dev100 → xync_client-0.0.25.dev101}/xync_client/BitGet/ex.py +0 -0
- {xync_client-0.0.25.dev100 → xync_client-0.0.25.dev101}/xync_client/BitGet/req.mjs +0 -0
- {xync_client-0.0.25.dev100 → xync_client-0.0.25.dev101}/xync_client/BitPapa/ex.py +0 -0
- {xync_client-0.0.25.dev100 → xync_client-0.0.25.dev101}/xync_client/Bybit/agent.py +0 -0
- {xync_client-0.0.25.dev100 → xync_client-0.0.25.dev101}/xync_client/Bybit/etype/ad.py +0 -0
- {xync_client-0.0.25.dev100 → xync_client-0.0.25.dev101}/xync_client/Bybit/ex.py +0 -0
- {xync_client-0.0.25.dev100 → xync_client-0.0.25.dev101}/xync_client/Bybit/web_earn.py +0 -0
- {xync_client-0.0.25.dev100 → xync_client-0.0.25.dev101}/xync_client/Bybit/web_p2p.py +0 -0
- {xync_client-0.0.25.dev100 → xync_client-0.0.25.dev101}/xync_client/Gate/etype/ad.py +0 -0
- {xync_client-0.0.25.dev100 → xync_client-0.0.25.dev101}/xync_client/Gate/ex.py +0 -0
- {xync_client-0.0.25.dev100 → xync_client-0.0.25.dev101}/xync_client/Gate/premarket.py +0 -0
- {xync_client-0.0.25.dev100 → xync_client-0.0.25.dev101}/xync_client/Htx/agent.py +0 -0
- {xync_client-0.0.25.dev100 → xync_client-0.0.25.dev101}/xync_client/Htx/earn.py +0 -0
- {xync_client-0.0.25.dev100 → xync_client-0.0.25.dev101}/xync_client/Htx/etype/__init__.py +0 -0
- {xync_client-0.0.25.dev100 → xync_client-0.0.25.dev101}/xync_client/Htx/etype/ad.py +0 -0
- {xync_client-0.0.25.dev100 → xync_client-0.0.25.dev101}/xync_client/Htx/etype/cred.py +0 -0
- {xync_client-0.0.25.dev100 → xync_client-0.0.25.dev101}/xync_client/Htx/etype/pm.py +0 -0
- {xync_client-0.0.25.dev100 → xync_client-0.0.25.dev101}/xync_client/Htx/ex.py +0 -0
- {xync_client-0.0.25.dev100 → xync_client-0.0.25.dev101}/xync_client/KuCoin/etype/ad.py +0 -0
- {xync_client-0.0.25.dev100 → xync_client-0.0.25.dev101}/xync_client/KuCoin/etype/pm.py +0 -0
- {xync_client-0.0.25.dev100 → xync_client-0.0.25.dev101}/xync_client/KuCoin/ex.py +0 -0
- {xync_client-0.0.25.dev100 → xync_client-0.0.25.dev101}/xync_client/KuCoin/web.py +0 -0
- {xync_client-0.0.25.dev100 → xync_client-0.0.25.dev101}/xync_client/Mexc/etype/ad.py +0 -0
- {xync_client-0.0.25.dev100 → xync_client-0.0.25.dev101}/xync_client/Mexc/etype/pm.py +0 -0
- {xync_client-0.0.25.dev100 → xync_client-0.0.25.dev101}/xync_client/Mexc/ex.py +0 -0
- {xync_client-0.0.25.dev100 → xync_client-0.0.25.dev101}/xync_client/Okx/etype/ad.py +0 -0
- {xync_client-0.0.25.dev100 → xync_client-0.0.25.dev101}/xync_client/Okx/etype/pm.py +0 -0
- {xync_client-0.0.25.dev100 → xync_client-0.0.25.dev101}/xync_client/Okx/ex.py +0 -0
- {xync_client-0.0.25.dev100 → xync_client-0.0.25.dev101}/xync_client/TgWallet/agent.py +0 -0
- {xync_client-0.0.25.dev100 → xync_client-0.0.25.dev101}/xync_client/TgWallet/asset.py +0 -0
- {xync_client-0.0.25.dev100 → xync_client-0.0.25.dev101}/xync_client/TgWallet/auth.py +0 -0
- {xync_client-0.0.25.dev100 → xync_client-0.0.25.dev101}/xync_client/TgWallet/ex.py +0 -0
- {xync_client-0.0.25.dev100 → xync_client-0.0.25.dev101}/xync_client/TgWallet/inAgent.py +0 -0
- {xync_client-0.0.25.dev100 → xync_client-0.0.25.dev101}/xync_client/TgWallet/order.py +0 -0
- {xync_client-0.0.25.dev100 → xync_client-0.0.25.dev101}/xync_client/TgWallet/pyd.py +0 -0
- {xync_client-0.0.25.dev100 → xync_client-0.0.25.dev101}/xync_client/TgWallet/web.py +0 -0
- {xync_client-0.0.25.dev100 → xync_client-0.0.25.dev101}/xync_client/__init__.py +0 -0
- {xync_client-0.0.25.dev100 → xync_client-0.0.25.dev101}/xync_client/loader.py +0 -0
- {xync_client-0.0.25.dev100 → xync_client-0.0.25.dev101}/xync_client/pm_unifier.py +0 -0
- {xync_client-0.0.25.dev100 → xync_client-0.0.25.dev101}/xync_client.egg-info/SOURCES.txt +0 -0
- {xync_client-0.0.25.dev100 → xync_client-0.0.25.dev101}/xync_client.egg-info/dependency_links.txt +0 -0
- {xync_client-0.0.25.dev100 → xync_client-0.0.25.dev101}/xync_client.egg-info/top_level.txt +0 -0
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
Metadata-Version: 2.4
|
|
2
2
|
Name: xync-client
|
|
3
|
-
Version: 0.0.25.
|
|
3
|
+
Version: 0.0.25.dev101
|
|
4
4
|
Author-email: Mike Artemiev <mixartemev@gmail.com>
|
|
5
5
|
Project-URL: Homepage, https://gitlab.com/XyncNet/client
|
|
6
6
|
Project-URL: Repository, https://gitlab.com/XyncNet/client
|
|
@@ -12,9 +12,10 @@ Requires-Dist: msgspec
|
|
|
12
12
|
Requires-Dist: python-binance
|
|
13
13
|
Requires-Dist: pybit
|
|
14
14
|
Requires-Dist: pyotp
|
|
15
|
-
Requires-Dist:
|
|
15
|
+
Requires-Dist: kurigram
|
|
16
16
|
Requires-Dist: python-dotenv
|
|
17
17
|
Requires-Dist: python-okx
|
|
18
|
+
Requires-Dist: tgcrypto
|
|
18
19
|
Requires-Dist: xn-client>=0.0.3dev3
|
|
19
20
|
Requires-Dist: xync-schema
|
|
20
21
|
Provides-Extra: dev
|
|
@@ -1,5 +1,6 @@
|
|
|
1
1
|
import logging
|
|
2
2
|
from abc import abstractmethod
|
|
3
|
+
from asyncio import sleep
|
|
3
4
|
|
|
4
5
|
import msgspec
|
|
5
6
|
from msgspec import Struct
|
|
@@ -9,6 +10,7 @@ from xync_schema.types import CurEx, CoinEx, BaseAd, BaseAdIn
|
|
|
9
10
|
|
|
10
11
|
from xync_client.Abc.Base import BaseClient, MapOfIdsList
|
|
11
12
|
from xync_client.Abc.types import PmEx
|
|
13
|
+
from xync_client.TgWallet.pyro import PyroClient
|
|
12
14
|
from xync_client.pm_unifier import PmUnifier, PmUni
|
|
13
15
|
|
|
14
16
|
|
|
@@ -64,6 +66,8 @@ class BaseExClient(BaseClient):
|
|
|
64
66
|
|
|
65
67
|
# Импорт Pm-ов (с Pmcur-, Pmex- и Pmcurex-ами) и валют (с Curex-ами) с биржи в бд
|
|
66
68
|
async def set_pmcurexs(self):
|
|
69
|
+
pyrogent = await models.Agent.get(actor__person__user__username="xyncsup")
|
|
70
|
+
pyro = PyroClient(pyrogent)
|
|
67
71
|
# Curs
|
|
68
72
|
cur_pyds: dict[str, CurEx] = await self.curs()
|
|
69
73
|
curs: dict[int | str, models.Cur] = {
|
|
@@ -150,6 +154,15 @@ class BaseExClient(BaseClient):
|
|
|
150
154
|
# и добавляем.обновляем Pmex для него
|
|
151
155
|
await models.Pmex.update_or_create({"pm": pm_}, ex=self.ex, exid=k, name=pm.name)
|
|
152
156
|
else:
|
|
157
|
+
if pm.logo and not models.File.exists(name=pm.logo):
|
|
158
|
+
if not pm.logo.startswith("https:"):
|
|
159
|
+
if not pm.logo.startswith("/"):
|
|
160
|
+
pm.logo = "/" + pm.logo
|
|
161
|
+
pm.logo = "https://" + pm.logo
|
|
162
|
+
resp = await self.session.get(pm.logo)
|
|
163
|
+
await sleep(1)
|
|
164
|
+
ref = await pyro.save_photo(await resp.read())
|
|
165
|
+
await models.File.update_or_create({"ref": ref}, name=pm.logo)
|
|
153
166
|
pmin = models.Pm.validate(
|
|
154
167
|
{**pmu.model_dump(), "country_id": country_id, "typ": pm.typ, "logo": pm.logo}
|
|
155
168
|
)
|
|
@@ -0,0 +1,156 @@
|
|
|
1
|
+
from asyncio import run, sleep
|
|
2
|
+
from io import BytesIO
|
|
3
|
+
from urllib.parse import parse_qs
|
|
4
|
+
|
|
5
|
+
from aiogram import Bot
|
|
6
|
+
from pyrogram import Client
|
|
7
|
+
from pyrogram.errors import UserNotParticipant
|
|
8
|
+
from pyrogram.raw import functions
|
|
9
|
+
from pyrogram.raw.base.upload import File
|
|
10
|
+
from pyrogram.raw.functions.messages import UploadMedia
|
|
11
|
+
from pyrogram.raw.functions.photos import GetUserPhotos
|
|
12
|
+
from pyrogram.raw.functions.upload import GetFile
|
|
13
|
+
from pyrogram.raw.types import (
|
|
14
|
+
InputPeerSelf,
|
|
15
|
+
InputMediaUploadedDocument,
|
|
16
|
+
MessageMediaDocument,
|
|
17
|
+
InputMediaUploadedPhoto,
|
|
18
|
+
MessageMediaPhoto,
|
|
19
|
+
InputDocumentFileLocation,
|
|
20
|
+
InputPhotoFileLocation,
|
|
21
|
+
)
|
|
22
|
+
from pyrogram.raw.types.photos import Photos
|
|
23
|
+
from pyrogram.types import Chat, ChatPrivileges
|
|
24
|
+
from x_model import init_db
|
|
25
|
+
from xync_client.loader import TG_API_ID, TG_API_HASH, PG_DSN
|
|
26
|
+
from xync_schema import models
|
|
27
|
+
from xync_schema.models import Agent
|
|
28
|
+
|
|
29
|
+
|
|
30
|
+
class PyroClient:
|
|
31
|
+
max_privs = ChatPrivileges(
|
|
32
|
+
can_manage_chat=True, # default
|
|
33
|
+
can_delete_messages=True,
|
|
34
|
+
can_delete_stories=True, # Channels only
|
|
35
|
+
can_manage_video_chats=True, # Groups and supergroups only
|
|
36
|
+
can_restrict_members=True,
|
|
37
|
+
can_promote_members=True,
|
|
38
|
+
can_change_info=True,
|
|
39
|
+
can_post_messages=True, # Channels only
|
|
40
|
+
can_post_stories=True, # Channels only
|
|
41
|
+
can_edit_messages=True, # Channels only
|
|
42
|
+
can_edit_stories=True, # Channels only
|
|
43
|
+
can_invite_users=True,
|
|
44
|
+
can_pin_messages=True, # Groups and supergroups only
|
|
45
|
+
can_manage_topics=True, # Supergroups only
|
|
46
|
+
is_anonymous=True,
|
|
47
|
+
)
|
|
48
|
+
|
|
49
|
+
def __init__(self, ab: Agent | Bot):
|
|
50
|
+
name = str(ab.actor.person.user.id) if isinstance(ab, Agent) else str(ab.id)
|
|
51
|
+
auth = {"session_string": ab.auth["sess"]} if isinstance(ab, Agent) else {"bot_token": ab.token}
|
|
52
|
+
self.app: Client = Client(name, TG_API_ID, TG_API_HASH, **auth)
|
|
53
|
+
|
|
54
|
+
async def get_init_data(self) -> dict:
|
|
55
|
+
async with self.app as app:
|
|
56
|
+
app: Client
|
|
57
|
+
bot = await app.resolve_peer("wallet")
|
|
58
|
+
res = await app.invoke(functions.messages.RequestWebView(peer=InputPeerSelf(), bot=bot, platform="ios"))
|
|
59
|
+
raw = parse_qs(res.url)["tgWebAppUserId"][0].split("#tgWebAppData=")[1]
|
|
60
|
+
j = parse_qs(raw)
|
|
61
|
+
return {
|
|
62
|
+
"web_view_init_data": {
|
|
63
|
+
"query_id": j["query_id"][0],
|
|
64
|
+
"user": j["user"][0],
|
|
65
|
+
"auth_date": j["auth_date"][0],
|
|
66
|
+
"hash": j["hash"][0],
|
|
67
|
+
},
|
|
68
|
+
"web_view_init_data_raw": raw,
|
|
69
|
+
"ep": "menu",
|
|
70
|
+
}
|
|
71
|
+
|
|
72
|
+
async def create_orders_forum(self, uid: str | int) -> tuple[int, bool]:
|
|
73
|
+
async with self.app as app:
|
|
74
|
+
app: Client
|
|
75
|
+
await app.get_me()
|
|
76
|
+
chat: Chat = await app.create_supergroup("Xync Orders", "Xync Orders")
|
|
77
|
+
if not (await app.toggle_forum_topics(chat_id=chat.id, enabled=True)):
|
|
78
|
+
await app.delete_channel(chat.id)
|
|
79
|
+
await chat.leave()
|
|
80
|
+
raise Exception(f"Chat {chat.id} for {app.me.username} not converted to forum")
|
|
81
|
+
await chat.add_members(["XyncNetBot"]) # , "xync_bot"
|
|
82
|
+
await chat.promote_member("XyncNetBot", self.max_privs)
|
|
83
|
+
added = await chat.add_members([uid])
|
|
84
|
+
try:
|
|
85
|
+
await sleep(1, await chat.get_member(uid))
|
|
86
|
+
except UserNotParticipant:
|
|
87
|
+
added = False
|
|
88
|
+
# await chat.leave()
|
|
89
|
+
return chat.id, added
|
|
90
|
+
|
|
91
|
+
async def get_user_photos(self, uid: str | int) -> Photos:
|
|
92
|
+
async with self.app as app:
|
|
93
|
+
app: Client
|
|
94
|
+
try:
|
|
95
|
+
peer = await app.resolve_peer(uid)
|
|
96
|
+
except Exception as e:
|
|
97
|
+
raise e
|
|
98
|
+
return await app.invoke(GetUserPhotos(user_id=peer, offset=0, limit=1, max_id=-1))
|
|
99
|
+
|
|
100
|
+
async def send_message(self, uid, txt):
|
|
101
|
+
async with self.app as app:
|
|
102
|
+
app: Client
|
|
103
|
+
try:
|
|
104
|
+
return await app.send_message(uid, txt)
|
|
105
|
+
except Exception as e:
|
|
106
|
+
raise e
|
|
107
|
+
|
|
108
|
+
async def save_file(self, byts: bytes, ctype: str) -> bytes:
|
|
109
|
+
async with self.app as app:
|
|
110
|
+
in_file = await app.save_file(BytesIO(byts))
|
|
111
|
+
imud = InputMediaUploadedDocument(file=in_file, mime_type=ctype, attributes=[])
|
|
112
|
+
upf: MessageMediaDocument = await app.invoke(UploadMedia(peer=InputPeerSelf(), media=imud))
|
|
113
|
+
return (
|
|
114
|
+
upf.document.id.to_bytes(8, "big")
|
|
115
|
+
+ upf.document.access_hash.to_bytes(8, "big", signed=True)
|
|
116
|
+
+ upf.document.file_reference
|
|
117
|
+
)
|
|
118
|
+
|
|
119
|
+
@staticmethod
|
|
120
|
+
def ref_enc(ph_id: int, access_hash: int, ref: bytes) -> bytes:
|
|
121
|
+
return ph_id.to_bytes(8, "big") + access_hash.to_bytes(8, "big", signed=True) + ref
|
|
122
|
+
|
|
123
|
+
@staticmethod
|
|
124
|
+
def ref_dec(full_ref: bytes) -> tuple[int, int, bytes]:
|
|
125
|
+
pid, ah = int.from_bytes(full_ref[:8], "big"), int.from_bytes(full_ref[8:16], "big", signed=True)
|
|
126
|
+
return pid, ah, full_ref[16:]
|
|
127
|
+
|
|
128
|
+
async def save_photo(self, file: bytes) -> bytes:
|
|
129
|
+
async with self.app as app:
|
|
130
|
+
in_file = await app.save_file(BytesIO(file))
|
|
131
|
+
upm = UploadMedia(peer=InputPeerSelf(), media=InputMediaUploadedPhoto(file=in_file))
|
|
132
|
+
upp: MessageMediaPhoto = await app.invoke(upm)
|
|
133
|
+
return self.ref_enc(upp.photo.id, upp.photo.access_hash, upp.photo.file_reference)
|
|
134
|
+
|
|
135
|
+
async def get_file(self, fid: bytes) -> File:
|
|
136
|
+
async with self.app as app:
|
|
137
|
+
pid, ah, ref = self.ref_dec(fid)
|
|
138
|
+
loc = InputDocumentFileLocation(id=pid, access_hash=ah, file_reference=ref, thumb_size="x")
|
|
139
|
+
return await app.invoke(GetFile(location=loc, offset=0, limit=512 * 1024))
|
|
140
|
+
|
|
141
|
+
async def get_photo(self, fid: bytes, st: str = "a") -> File:
|
|
142
|
+
async with self.app as app:
|
|
143
|
+
pid, ah, ref = self.ref_dec(fid)
|
|
144
|
+
loc = InputPhotoFileLocation(id=pid, access_hash=ah, file_reference=ref, thumb_size=st)
|
|
145
|
+
return await app.invoke(GetFile(location=loc, offset=0, limit=512 * 1024))
|
|
146
|
+
|
|
147
|
+
|
|
148
|
+
async def main():
|
|
149
|
+
_ = await init_db(PG_DSN, models, True)
|
|
150
|
+
agent: Agent = await Agent.filter(auth__isnull=False, ex__name="TgWallet").prefetch_related("ex").first()
|
|
151
|
+
pcl = PyroClient(agent)
|
|
152
|
+
await pcl.create_orders_forum(agent.actor.user_id)
|
|
153
|
+
|
|
154
|
+
|
|
155
|
+
if __name__ == "__main__":
|
|
156
|
+
run(main())
|
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
Metadata-Version: 2.4
|
|
2
2
|
Name: xync-client
|
|
3
|
-
Version: 0.0.25.
|
|
3
|
+
Version: 0.0.25.dev101
|
|
4
4
|
Author-email: Mike Artemiev <mixartemev@gmail.com>
|
|
5
5
|
Project-URL: Homepage, https://gitlab.com/XyncNet/client
|
|
6
6
|
Project-URL: Repository, https://gitlab.com/XyncNet/client
|
|
@@ -12,9 +12,10 @@ Requires-Dist: msgspec
|
|
|
12
12
|
Requires-Dist: python-binance
|
|
13
13
|
Requires-Dist: pybit
|
|
14
14
|
Requires-Dist: pyotp
|
|
15
|
-
Requires-Dist:
|
|
15
|
+
Requires-Dist: kurigram
|
|
16
16
|
Requires-Dist: python-dotenv
|
|
17
17
|
Requires-Dist: python-okx
|
|
18
|
+
Requires-Dist: tgcrypto
|
|
18
19
|
Requires-Dist: xn-client>=0.0.3dev3
|
|
19
20
|
Requires-Dist: xync-schema
|
|
20
21
|
Provides-Extra: dev
|
|
@@ -1,52 +0,0 @@
|
|
|
1
|
-
from asyncio import run
|
|
2
|
-
from urllib.parse import parse_qs
|
|
3
|
-
from pyrogram import Client
|
|
4
|
-
from pyrogram.raw import functions
|
|
5
|
-
from pyrogram.raw.types import InputPeerSelf
|
|
6
|
-
from x_model import init_db
|
|
7
|
-
from xync_client.loader import TG_API_ID, TG_API_HASH, PG_DSN
|
|
8
|
-
from xync_schema import models
|
|
9
|
-
from xync_schema.models import Agent
|
|
10
|
-
|
|
11
|
-
|
|
12
|
-
class PyroClient:
|
|
13
|
-
def __init__(self, agent: Agent):
|
|
14
|
-
self.app: Client = Client(
|
|
15
|
-
str(agent.actor.person.user.id), TG_API_ID, TG_API_HASH, session_string=agent.auth["sess"]
|
|
16
|
-
)
|
|
17
|
-
|
|
18
|
-
async def get_init_data(self) -> dict:
|
|
19
|
-
async with self.app as app:
|
|
20
|
-
app: Client
|
|
21
|
-
bot = await app.resolve_peer("wallet")
|
|
22
|
-
res = await app.invoke(functions.messages.RequestWebView(peer=InputPeerSelf(), bot=bot, platform="ios"))
|
|
23
|
-
raw = parse_qs(res.url)["tgWebAppUserId"][0].split("#tgWebAppData=")[1]
|
|
24
|
-
j = parse_qs(raw)
|
|
25
|
-
return {
|
|
26
|
-
"web_view_init_data": {
|
|
27
|
-
"query_id": j["query_id"][0],
|
|
28
|
-
"user": j["user"][0],
|
|
29
|
-
"auth_date": j["auth_date"][0],
|
|
30
|
-
"hash": j["hash"][0],
|
|
31
|
-
},
|
|
32
|
-
"web_view_init_data_raw": raw,
|
|
33
|
-
"ep": "menu",
|
|
34
|
-
}
|
|
35
|
-
|
|
36
|
-
async def create_orders_forum(self, uid) -> int:
|
|
37
|
-
async with self.app as app:
|
|
38
|
-
app: Client
|
|
39
|
-
forum = await app.create_supergroup(f"xync{uid}", "Xync Orders Group")
|
|
40
|
-
await forum.add_members([uid, "xync_bot", "XyncNetBot"])
|
|
41
|
-
return forum.id
|
|
42
|
-
|
|
43
|
-
|
|
44
|
-
async def main():
|
|
45
|
-
_ = await init_db(PG_DSN, models, True)
|
|
46
|
-
agent: Agent = await Agent.filter(auth__isnull=False, ex__name="TgWallet").prefetch_related("ex").first()
|
|
47
|
-
pcl = PyroClient(agent)
|
|
48
|
-
await pcl.create_orders_forum(agent.actor.user_id)
|
|
49
|
-
|
|
50
|
-
|
|
51
|
-
if __name__ == "__main__":
|
|
52
|
-
run(main())
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
{xync_client-0.0.25.dev100 → xync_client-0.0.25.dev101}/tests/_todo_refact/Binance/test_binance.py
RENAMED
|
File without changes
|
{xync_client-0.0.25.dev100 → xync_client-0.0.25.dev101}/tests/_todo_refact/Bybit/test_bybit.py
RENAMED
|
File without changes
|
{xync_client-0.0.25.dev100 → xync_client-0.0.25.dev101}/tests/_todo_refact/Bybit/test_bybit_p2p.py
RENAMED
|
File without changes
|
{xync_client-0.0.25.dev100 → xync_client-0.0.25.dev101}/tests/_todo_refact/Gate/test_gate.py
RENAMED
|
File without changes
|
{xync_client-0.0.25.dev100 → xync_client-0.0.25.dev101}/tests/_todo_refact/Htx/test_htx_p2p.py
RENAMED
|
File without changes
|
{xync_client-0.0.25.dev100 → xync_client-0.0.25.dev101}/tests/_todo_refact/Wallet/test_agent.py
RENAMED
|
File without changes
|
{xync_client-0.0.25.dev100 → xync_client-0.0.25.dev101}/tests/_todo_refact/Wallet/test_ex.py
RENAMED
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
{xync_client-0.0.25.dev100 → xync_client-0.0.25.dev101}/xync_client/Binance/binance_async.py
RENAMED
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
{xync_client-0.0.25.dev100 → xync_client-0.0.25.dev101}/xync_client.egg-info/dependency_links.txt
RENAMED
|
File without changes
|
|
File without changes
|