xync-bot 0.3.25.dev1__tar.gz → 0.3.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.
Potentially problematic release.
This version of xync-bot might be problematic. Click here for more details.
- {xync_bot-0.3.25.dev1/xync_bot.egg-info → xync_bot-0.3.26}/PKG-INFO +1 -1
- {xync_bot-0.3.25.dev1 → xync_bot-0.3.26}/xync_bot/__main__.py +3 -2
- {xync_bot-0.3.25.dev1 → xync_bot-0.3.26}/xync_bot/routers/pay/handler.py +26 -18
- {xync_bot-0.3.25.dev1 → xync_bot-0.3.26}/xync_bot/routers/pay/window.py +19 -15
- xync_bot-0.3.26/xync_bot/routers/send/__init__.py +117 -0
- {xync_bot-0.3.25.dev1 → xync_bot-0.3.26}/xync_bot/store.py +9 -15
- {xync_bot-0.3.25.dev1 → xync_bot-0.3.26/xync_bot.egg-info}/PKG-INFO +1 -1
- {xync_bot-0.3.25.dev1 → xync_bot-0.3.26}/xync_bot.egg-info/SOURCES.txt +2 -1
- {xync_bot-0.3.25.dev1 → xync_bot-0.3.26}/.env.dist +0 -0
- {xync_bot-0.3.25.dev1 → xync_bot-0.3.26}/.gitignore +0 -0
- {xync_bot-0.3.25.dev1 → xync_bot-0.3.26}/.pre-commit-config.yaml +0 -0
- {xync_bot-0.3.25.dev1 → xync_bot-0.3.26}/makefile +0 -0
- {xync_bot-0.3.25.dev1 → xync_bot-0.3.26}/pager.py +0 -0
- {xync_bot-0.3.25.dev1 → xync_bot-0.3.26}/pyproject.toml +0 -0
- {xync_bot-0.3.25.dev1 → xync_bot-0.3.26}/setup.cfg +0 -0
- {xync_bot-0.3.25.dev1 → xync_bot-0.3.26}/test_main.http +0 -0
- {xync_bot-0.3.25.dev1 → xync_bot-0.3.26}/xync_bot/loader.py +0 -0
- {xync_bot-0.3.25.dev1 → xync_bot-0.3.26}/xync_bot/routers/__init__.py +0 -0
- {xync_bot-0.3.25.dev1 → xync_bot-0.3.26}/xync_bot/routers/cond/__init__.py +0 -0
- {xync_bot-0.3.25.dev1 → xync_bot-0.3.26}/xync_bot/routers/cond/func.py +0 -0
- {xync_bot-0.3.25.dev1 → xync_bot-0.3.26}/xync_bot/routers/main/__init__.py +0 -0
- {xync_bot-0.3.25.dev1 → xync_bot-0.3.26}/xync_bot/routers/main/handler.py +0 -0
- {xync_bot-0.3.25.dev1 → xync_bot-0.3.26}/xync_bot/routers/order.py +0 -0
- {xync_bot-0.3.25.dev1 → xync_bot-0.3.26}/xync_bot/routers/pay/cd.py +0 -0
- {xync_bot-0.3.25.dev1 → xync_bot-0.3.26}/xync_bot/routers/pay/dep.py +0 -0
- {xync_bot-0.3.25.dev1 → xync_bot-0.3.26}/xync_bot/routers/photo.py +0 -0
- {xync_bot-0.3.25.dev1 → xync_bot-0.3.26}/xync_bot/routers/vpn.py +0 -0
- {xync_bot-0.3.25.dev1 → xync_bot-0.3.26}/xync_bot/routers/xicon.png +0 -0
- {xync_bot-0.3.25.dev1 → xync_bot-0.3.26}/xync_bot/shared.py +0 -0
- {xync_bot-0.3.25.dev1 → xync_bot-0.3.26}/xync_bot/typs.py +0 -0
- {xync_bot-0.3.25.dev1 → xync_bot-0.3.26}/xync_bot.egg-info/dependency_links.txt +0 -0
- {xync_bot-0.3.25.dev1 → xync_bot-0.3.26}/xync_bot.egg-info/requires.txt +0 -0
- {xync_bot-0.3.25.dev1 → xync_bot-0.3.26}/xync_bot.egg-info/top_level.txt +0 -0
|
@@ -6,11 +6,12 @@ from aiogram.client.default import DefaultBotProperties
|
|
|
6
6
|
from aiogram.enums import UpdateType
|
|
7
7
|
from x_model import init_db
|
|
8
8
|
|
|
9
|
+
from xync_bot.store import Store
|
|
9
10
|
from xync_bot.routers.main.handler import mr
|
|
10
11
|
from xync_bot.routers.cond import cr
|
|
11
12
|
from xync_bot.routers.pay.handler import pr
|
|
12
13
|
from xync_bot.routers import last
|
|
13
|
-
from xync_bot.
|
|
14
|
+
from xync_bot.routers.send import sd
|
|
14
15
|
|
|
15
16
|
au = [
|
|
16
17
|
UpdateType.MESSAGE,
|
|
@@ -18,7 +19,7 @@ au = [
|
|
|
18
19
|
UpdateType.CHAT_MEMBER,
|
|
19
20
|
UpdateType.MY_CHAT_MEMBER,
|
|
20
21
|
] # , UpdateType.CHAT_JOIN_REQUEST
|
|
21
|
-
bot = Bot([cr, pr, mr, last], Store(), au, default=DefaultBotProperties(parse_mode="HTML"))
|
|
22
|
+
bot = Bot([sd, cr, pr, mr, last], Store(), au, default=DefaultBotProperties(parse_mode="HTML"))
|
|
22
23
|
|
|
23
24
|
if __name__ == "__main__":
|
|
24
25
|
from xync_bot.loader import TOKEN, TORM
|
|
@@ -15,40 +15,43 @@ pr = Router(name="pay")
|
|
|
15
15
|
|
|
16
16
|
|
|
17
17
|
@pr.message(Command("pay"))
|
|
18
|
-
async def h_start(msg: Message, store: Store):
|
|
18
|
+
async def h_start(msg: Message, store: Store, **kwargs):
|
|
19
19
|
"""Step 1: Select a target type"""
|
|
20
|
-
|
|
20
|
+
uid = msg.from_user.id
|
|
21
|
+
store.pers[uid] = Store.Personal(1)
|
|
22
|
+
store.pers[uid].curr.is_target = True
|
|
21
23
|
await gather(window.type_select(msg, store), dlt(msg))
|
|
22
|
-
store.
|
|
23
|
-
store.
|
|
24
|
-
store.
|
|
24
|
+
store.pers[uid].user = await models.User.get(username_id=msg.from_user.id)
|
|
25
|
+
store.pers[uid].creds, store.pers[uid].cur_creds = await fill_creds(store.pers[uid].user.person_id)
|
|
26
|
+
store.pers[uid].actors = await fill_actors(store.pers[uid].user.person_id)
|
|
25
27
|
|
|
26
28
|
|
|
27
29
|
@pr.callback_query(cd.MoneyType.filter(F.is_fiat))
|
|
28
30
|
async def h_got_fiat_type(query: CallbackQuery, store: Store):
|
|
29
31
|
"""Step 2f: Select cur"""
|
|
30
|
-
|
|
32
|
+
uid = query.from_user.id
|
|
33
|
+
store.pers[uid].curr.is_fiat = True
|
|
31
34
|
await gather(window.cur_select(query.message, store), ans(query, "Понял, фиат"))
|
|
32
35
|
|
|
33
36
|
|
|
34
37
|
@pr.callback_query(cd.MoneyType.filter(F.is_fiat.__eq__(0)))
|
|
35
38
|
async def h_got_crypto_type(query: CallbackQuery, store: Store):
|
|
36
39
|
"""Step 2c: Select coin"""
|
|
37
|
-
store.curr.is_fiat = False
|
|
40
|
+
store.pers.curr.is_fiat = False
|
|
38
41
|
await gather(window.coin_select(query.message, store), ans(query, "Понял, крипта"))
|
|
39
42
|
|
|
40
43
|
|
|
41
44
|
@pr.callback_query(cd.Coin.filter())
|
|
42
45
|
async def h_got_coin(query: CallbackQuery, callback_data: cd.Coin, store: Store):
|
|
43
46
|
"""Step 3c: Select target ex"""
|
|
44
|
-
setattr(store.pay, ("t" if store.curr.is_target else "s") + "_coin_id", callback_data.id)
|
|
47
|
+
setattr(store.pay, ("t" if store.pers.curr.is_target else "s") + "_coin_id", callback_data.id)
|
|
45
48
|
await gather(window.ex_select(query.message, store), ans(query, "Эта монета есть на следующих биржах"))
|
|
46
49
|
|
|
47
50
|
|
|
48
51
|
@pr.callback_query(cd.Cur.filter())
|
|
49
52
|
async def h_got_cur(query: CallbackQuery, callback_data: cd.Cur, store: Store):
|
|
50
53
|
"""Step 3f: Select target pm"""
|
|
51
|
-
setattr(store.pay, ("t" if store.curr.is_target else "s") + "_cur_id", callback_data.id)
|
|
54
|
+
setattr(store.pay, ("t" if store.pers.curr.is_target else "s") + "_cur_id", callback_data.id)
|
|
52
55
|
await gather(window.pm(query.message, store), ans(query, "Вот платежные системы доступные для этой валюты"))
|
|
53
56
|
|
|
54
57
|
|
|
@@ -81,25 +84,27 @@ async def h_got_cred_dtl(msg: Message, state: FSMContext, store: Store):
|
|
|
81
84
|
@pr.message(dep.CredState.name)
|
|
82
85
|
async def h_got_cred_name(msg: Message, state: FSMContext, store: Store):
|
|
83
86
|
"""Step 5f: Save target cred"""
|
|
87
|
+
uid = msg.from_user.id
|
|
84
88
|
cred, _ = await models.Cred.update_or_create(
|
|
85
89
|
{"name": msg.text},
|
|
86
90
|
detail=store.pay.cred_dtl,
|
|
87
|
-
person_id=store.
|
|
91
|
+
person_id=store.pers[uid].user.person_id,
|
|
88
92
|
pmcur_id=store.pay.t_pmcur_id,
|
|
89
93
|
)
|
|
90
94
|
store.pay.cred_id = cred.id
|
|
91
|
-
store.
|
|
95
|
+
store.pers[uid].creds[cred.id] = cred
|
|
92
96
|
await gather(window.amount(msg, store), dlt(msg), state.set_state(dep.PaymentState.amount))
|
|
93
97
|
|
|
94
98
|
|
|
95
99
|
@pr.callback_query(cd.Ex.filter())
|
|
96
100
|
async def h_got_ex(query: CallbackQuery, callback_data: cd.Ex, state: FSMContext, store: Store):
|
|
97
101
|
"""Step 4c: Save target"""
|
|
98
|
-
|
|
102
|
+
uid = query.from_user.id
|
|
103
|
+
ist = store.pers.curr.is_target
|
|
99
104
|
setattr(store.pay, ("t" if ist else "s") + "_ex_id", callback_data.id)
|
|
100
105
|
if ist:
|
|
101
106
|
await window.amount(query.message, store)
|
|
102
|
-
actor_id = store.
|
|
107
|
+
actor_id = store.pers[uid].actors[store.pay.t_ex_id]
|
|
103
108
|
addr = await models.Addr.get(coin_id=store.pay.t_coin_id, actor_id=actor_id)
|
|
104
109
|
store.pay.addr_id = addr.id
|
|
105
110
|
else:
|
|
@@ -112,14 +117,16 @@ async def h_got_ex(query: CallbackQuery, callback_data: cd.Ex, state: FSMContext
|
|
|
112
117
|
async def h_got_amount(msg: Message, state: FSMContext, store: Store):
|
|
113
118
|
"""Step 6: Save a target amount"""
|
|
114
119
|
if not msg.text.isnumeric():
|
|
115
|
-
store.curr.msg_to_del = await msg.answer("Пожалуйста, введите корректное число")
|
|
120
|
+
store.pers.curr.msg_to_del = await msg.answer("Пожалуйста, введите корректное число")
|
|
116
121
|
return
|
|
117
|
-
if store.curr.msg_to_del:
|
|
118
|
-
await store.curr.msg_to_del.delete()
|
|
122
|
+
if store.pers.curr.msg_to_del:
|
|
123
|
+
await store.pers.curr.msg_to_del.delete()
|
|
119
124
|
store.pay.amount = float(msg.text)
|
|
120
125
|
"""Step 7: Select source type"""
|
|
121
|
-
store.curr.is_target = False
|
|
122
|
-
await gather(
|
|
126
|
+
store.pers.curr.is_target = False
|
|
127
|
+
await gather(
|
|
128
|
+
(window.type_select if store.pers.curr.is_fiat else window.cur_select)(msg, store), dlt(msg), state.clear()
|
|
129
|
+
)
|
|
123
130
|
|
|
124
131
|
|
|
125
132
|
@pr.callback_query(cd.Pm.filter(F.is_target.__eq__(0)))
|
|
@@ -139,6 +146,7 @@ async def h_got_ppo(query: CallbackQuery, callback_data: cd.Ppo, store: Store):
|
|
|
139
146
|
|
|
140
147
|
@pr.callback_query(cd.Time.filter())
|
|
141
148
|
async def h_got_urgency(query: CallbackQuery, callback_data: cd.Time, store: Store):
|
|
149
|
+
# payreq_id = store.pers[query.from_user.id].
|
|
142
150
|
store.pay.urg = callback_data.minutes
|
|
143
151
|
await window.create_payreq(query.message, store)
|
|
144
152
|
await ans(query, f"Ok {callback_data.minutes} min.")
|
|
@@ -13,7 +13,8 @@ from xync_bot.store import Store
|
|
|
13
13
|
|
|
14
14
|
async def type_select(msg: Message, store: Store):
|
|
15
15
|
"""Step 1: Select type"""
|
|
16
|
-
|
|
16
|
+
uid = msg.from_user.id
|
|
17
|
+
ist: bool = store.pers[uid].curr.is_target
|
|
17
18
|
rm = InlineKeyboardMarkup(
|
|
18
19
|
inline_keyboard=[
|
|
19
20
|
[
|
|
@@ -21,26 +22,27 @@ async def type_select(msg: Message, store: Store):
|
|
|
21
22
|
text="Банковская валюта", callback_data=cd.MoneyType(is_fiat=1, is_target=ist).pack()
|
|
22
23
|
),
|
|
23
24
|
InlineKeyboardButton(
|
|
24
|
-
text="Крипта",
|
|
25
|
+
text="Крипта",
|
|
26
|
+
callback_data=cd.MoneyType(is_fiat=0, is_target=store.pers[uid].curr.is_target).pack(),
|
|
25
27
|
),
|
|
26
28
|
]
|
|
27
29
|
]
|
|
28
30
|
)
|
|
29
|
-
if store.curr.is_target:
|
|
31
|
+
if store.pers[uid].curr.is_target:
|
|
30
32
|
txt = "Что нужно?"
|
|
31
33
|
else:
|
|
32
|
-
if store.pay.t_coin_id:
|
|
33
|
-
inf = f"{store.glob.coins[store.pay.t_coin_id]} на {store.glob.exs[store.pay.t_ex_id]}:{store.pay.addr_id}"
|
|
34
|
+
if store.pers[uid].pay.t_coin_id:
|
|
35
|
+
inf = f"{store.glob.coins[store.pers[uid].pay.t_coin_id]} на {store.glob.exs[store.pers[uid].pay.t_ex_id]}:{store.pay.addr_id}"
|
|
34
36
|
else:
|
|
35
37
|
cur = store.glob.curs[store.pay.t_cur_id].ticker
|
|
36
|
-
cred: models.Cred = store.
|
|
38
|
+
cred: models.Cred = store.pers[uid].creds[store.pay.cred_id]
|
|
37
39
|
inf = f"{cur} на {store.glob.pmcurs[store.pay.t_pmcur_id]}: {cred.repr()}"
|
|
38
40
|
txt = f"Нужен платеж: {store.pay.amount} {inf}\nЧем будете платить?"
|
|
39
|
-
if store.
|
|
41
|
+
if store.pers[uid].msg_id:
|
|
40
42
|
await edt(msg, txt, rm)
|
|
41
43
|
else:
|
|
42
44
|
msg = await msg.answer(txt, reply_markup=rm)
|
|
43
|
-
store.
|
|
45
|
+
store.pers[uid].msg_id = msg.message_id
|
|
44
46
|
|
|
45
47
|
|
|
46
48
|
async def cur_select(msg: Message, store: Store):
|
|
@@ -100,11 +102,12 @@ async def pm(msg: Message, store: Store):
|
|
|
100
102
|
|
|
101
103
|
|
|
102
104
|
async def fill_cred_dtl(msg: Message, store: Store):
|
|
105
|
+
uid = msg.from_user.id
|
|
103
106
|
builder = InlineKeyboardBuilder()
|
|
104
107
|
txt = "В"
|
|
105
|
-
if cred_ids := store.
|
|
108
|
+
if cred_ids := store.pers[uid].cur_creds.get(store.pay.t_pmcur_id):
|
|
106
109
|
for cred_id in cred_ids:
|
|
107
|
-
cred = store.
|
|
110
|
+
cred = store.pers[uid].creds[cred_id]
|
|
108
111
|
builder.button(text=cred.repr(), callback_data=cd.Cred(id=cred_id))
|
|
109
112
|
txt = "Выберите реквизиты куда нужно получить деньги, если в списке нет нужных, то\nв"
|
|
110
113
|
|
|
@@ -182,13 +185,14 @@ async def set_urgency(msg: Message, store: Store):
|
|
|
182
185
|
|
|
183
186
|
|
|
184
187
|
async def create_payreq(msg: Message, store: Store):
|
|
188
|
+
uid = msg.from_user.id
|
|
185
189
|
pay_req, _ = await models.PayReq.update_or_create(
|
|
186
190
|
{"pay_until": datetime.now() + timedelta(minutes=store.pay.urg)},
|
|
187
191
|
amount=store.pay.amount,
|
|
188
192
|
parts=store.pay.ppo,
|
|
189
193
|
addr_id=store.pay.addr_id,
|
|
190
194
|
cred_id=store.pay.cred_id,
|
|
191
|
-
user=store.
|
|
195
|
+
user=store.pers[uid].user,
|
|
192
196
|
)
|
|
193
197
|
store.pay.pr_id = pay_req.id
|
|
194
198
|
inp, txt = await store.get_merch_target()
|
|
@@ -206,14 +210,14 @@ async def create_payreq(msg: Message, store: Store):
|
|
|
206
210
|
# create_task(window.run_timer(msg))В
|
|
207
211
|
|
|
208
212
|
|
|
209
|
-
async def run_timer(
|
|
213
|
+
async def run_timer(msg, state: FSMContext):
|
|
210
214
|
builder = InlineKeyboardBuilder()
|
|
211
215
|
builder.button(text="Платеж получен", callback_data=cd.Action(act=cd.ActionType.received))
|
|
212
216
|
|
|
213
217
|
seconds = await state.get_value("timer") * 60
|
|
214
218
|
|
|
215
219
|
try:
|
|
216
|
-
await
|
|
220
|
+
await msg.edit_text(f"⏳ Осталось {fmt_sec(seconds)}", reply_markup=builder.as_markup())
|
|
217
221
|
except Exception:
|
|
218
222
|
return
|
|
219
223
|
|
|
@@ -221,7 +225,7 @@ async def run_timer(message, state: FSMContext):
|
|
|
221
225
|
await sleep(1)
|
|
222
226
|
seconds -= 1
|
|
223
227
|
try:
|
|
224
|
-
await
|
|
228
|
+
await msg.edit_text(f"⏳ Осталось {fmt_sec(seconds)}", reply_markup=builder.as_markup())
|
|
225
229
|
await state.update_data(timer=seconds)
|
|
226
230
|
except Exception:
|
|
227
231
|
break
|
|
@@ -231,7 +235,7 @@ async def run_timer(message, state: FSMContext):
|
|
|
231
235
|
builder.button(text="Платеж получен", callback_data=cd.Action(act=cd.ActionType.received))
|
|
232
236
|
builder.button(text="Денег нет", callback_data=cd.Action(act=cd.ActionType.not_received))
|
|
233
237
|
try:
|
|
234
|
-
await
|
|
238
|
+
await msg.edit_text("⏳ Время вышло!", reply_markup=builder.as_markup())
|
|
235
239
|
except Exception:
|
|
236
240
|
pass
|
|
237
241
|
|
|
@@ -0,0 +1,117 @@
|
|
|
1
|
+
from aiogram import Router
|
|
2
|
+
from aiogram.fsm.context import FSMContext
|
|
3
|
+
from aiogram.fsm.state import StatesGroup, State
|
|
4
|
+
from aiogram.types import Message
|
|
5
|
+
from aiogram.utils.keyboard import InlineKeyboardBuilder
|
|
6
|
+
from aiogram.filters import Command
|
|
7
|
+
from xync_schema import models
|
|
8
|
+
from aiogram.filters.callback_data import CallbackData
|
|
9
|
+
from aiogram import types
|
|
10
|
+
|
|
11
|
+
sd = Router()
|
|
12
|
+
|
|
13
|
+
|
|
14
|
+
class SendStates(StatesGroup):
|
|
15
|
+
waiting_for_recipient = State()
|
|
16
|
+
waiting_for_amount = State()
|
|
17
|
+
|
|
18
|
+
|
|
19
|
+
class Cur(CallbackData, prefix="Сur"):
|
|
20
|
+
id: int
|
|
21
|
+
|
|
22
|
+
|
|
23
|
+
@sd.message(Command("send"))
|
|
24
|
+
async def start(message: Message, state: FSMContext):
|
|
25
|
+
await message.answer(
|
|
26
|
+
"Введите ID/username получателя:",
|
|
27
|
+
)
|
|
28
|
+
|
|
29
|
+
await state.set_state(SendStates.waiting_for_recipient)
|
|
30
|
+
|
|
31
|
+
|
|
32
|
+
@sd.message(SendStates.waiting_for_recipient)
|
|
33
|
+
async def process_recipient(message: Message, state: FSMContext):
|
|
34
|
+
recipient = message.text
|
|
35
|
+
|
|
36
|
+
if recipient.isdigit():
|
|
37
|
+
user_id = int(recipient)
|
|
38
|
+
user_receiver = await models.User.get_or_none(username_id=user_id)
|
|
39
|
+
|
|
40
|
+
if not user_receiver:
|
|
41
|
+
my_id = message.from_user.id
|
|
42
|
+
await message.answer(
|
|
43
|
+
f"Такого пользователя еще нет в XyncPay, вот ссылка для регистрации с вашим реферальным бонусом: \n"
|
|
44
|
+
f"https://t.me/XyncPayBot?start={my_id}"
|
|
45
|
+
)
|
|
46
|
+
return
|
|
47
|
+
else:
|
|
48
|
+
await state.update_data(receiver=user_receiver)
|
|
49
|
+
else:
|
|
50
|
+
user_receiver = await models.User.get_or_none(username__username=recipient)
|
|
51
|
+
|
|
52
|
+
if not user_receiver:
|
|
53
|
+
my_id = message.from_user.id
|
|
54
|
+
await message.answer(
|
|
55
|
+
f"Такого пользователя еще нет в XyncPay, вот ссылка для регистрации с вашим реферальным бонусом: \n"
|
|
56
|
+
f"https://t.me/XyncPayBot?start={my_id}"
|
|
57
|
+
)
|
|
58
|
+
return
|
|
59
|
+
await state.update_data(receiver=user_receiver)
|
|
60
|
+
|
|
61
|
+
# Продолжаем процесс выбора валюты
|
|
62
|
+
builder = InlineKeyboardBuilder()
|
|
63
|
+
curs = await models.Cur.filter(
|
|
64
|
+
ticker__in=[
|
|
65
|
+
"CNY",
|
|
66
|
+
"HKD",
|
|
67
|
+
"USD",
|
|
68
|
+
"VND",
|
|
69
|
+
"MYR",
|
|
70
|
+
"TWD",
|
|
71
|
+
"RUB",
|
|
72
|
+
"AUD",
|
|
73
|
+
"CAD",
|
|
74
|
+
"SGD",
|
|
75
|
+
"GBP",
|
|
76
|
+
"EUR",
|
|
77
|
+
"PHP",
|
|
78
|
+
"INR",
|
|
79
|
+
"CHF",
|
|
80
|
+
"IDR",
|
|
81
|
+
"BRL",
|
|
82
|
+
"SAR",
|
|
83
|
+
"AED",
|
|
84
|
+
"TRY",
|
|
85
|
+
"THB",
|
|
86
|
+
]
|
|
87
|
+
)
|
|
88
|
+
|
|
89
|
+
for cur in curs:
|
|
90
|
+
builder.button(text=cur.ticker, callback_data=Cur(id=cur.id).pack())
|
|
91
|
+
|
|
92
|
+
builder.adjust(3, 3, 3)
|
|
93
|
+
await message.answer("Выбери валюту", reply_markup=builder.as_markup())
|
|
94
|
+
|
|
95
|
+
|
|
96
|
+
@sd.callback_query(Cur.filter())
|
|
97
|
+
async def waiting_for_amount(query: types.CallbackQuery, state: FSMContext, callback_data: Cur):
|
|
98
|
+
await state.update_data(cur=callback_data.id)
|
|
99
|
+
await query.message.answer("Введите сумму: ")
|
|
100
|
+
await state.set_state(SendStates.waiting_for_amount)
|
|
101
|
+
|
|
102
|
+
|
|
103
|
+
@sd.message(SendStates.waiting_for_amount)
|
|
104
|
+
async def waiting_for_recipient(message: Message, state: FSMContext):
|
|
105
|
+
amount = int(message.text)
|
|
106
|
+
if amount < 0:
|
|
107
|
+
await message.answer("Введите положительное число")
|
|
108
|
+
else:
|
|
109
|
+
await state.update_data(amount=amount)
|
|
110
|
+
my_id = message.from_user.id
|
|
111
|
+
await state.update_data(sender=my_id)
|
|
112
|
+
data = await state.get_data()
|
|
113
|
+
await state.clear()
|
|
114
|
+
me = await models.User.get(username_id=my_id)
|
|
115
|
+
await models.Transfer.create(
|
|
116
|
+
amount=data["amount"], cur_id=data["cur"], receiver_id=data["receiver"].id, sender=me
|
|
117
|
+
)
|
|
@@ -3,7 +3,7 @@ from aiogram.types import Message
|
|
|
3
3
|
from tortoise.functions import Min
|
|
4
4
|
from x_model.func import ArrayAgg
|
|
5
5
|
from x_auth.enums import Role
|
|
6
|
-
from xync_schema.models import Addr, Asset, Cred, Coin,
|
|
6
|
+
from xync_schema.models import Addr, Asset, Cred, Coin, PmCur, Cur, User, Ex, PmEx
|
|
7
7
|
|
|
8
8
|
from xync_bot.shared import flags
|
|
9
9
|
|
|
@@ -20,7 +20,7 @@ class SingleStore(type):
|
|
|
20
20
|
cls._store.exs = {k: v for k, v in await Ex.all().values_list("id", "name")}
|
|
21
21
|
cls._store.pmcurs = {
|
|
22
22
|
k: v
|
|
23
|
-
for k, v in await
|
|
23
|
+
for k, v in await PmEx.filter(pm__pmcurs__cur_id__in=cls._store.curs.keys())
|
|
24
24
|
.annotate(sname=Min("name"))
|
|
25
25
|
.group_by("pm__pmcurs__id")
|
|
26
26
|
.values_list("pm__pmcurs__id", "sname")
|
|
@@ -30,14 +30,14 @@ class SingleStore(type):
|
|
|
30
30
|
}
|
|
31
31
|
cls._store.curpms = {
|
|
32
32
|
cur_id: ids
|
|
33
|
-
for cur_id, ids in await
|
|
33
|
+
for cur_id, ids in await PmCur.filter(cur_id__in=curs.keys())
|
|
34
34
|
.annotate(ids=ArrayAgg("id"))
|
|
35
35
|
.group_by("cur_id")
|
|
36
36
|
.values_list("cur_id", "ids")
|
|
37
37
|
}
|
|
38
38
|
cls._store.curpms = {
|
|
39
39
|
cur_id: ids
|
|
40
|
-
for cur_id, ids in await
|
|
40
|
+
for cur_id, ids in await PmCur.filter(cur_id__in=curs.keys())
|
|
41
41
|
.annotate(ids=ArrayAgg("id"))
|
|
42
42
|
.group_by("cur_id")
|
|
43
43
|
.values_list("cur_id", "ids")
|
|
@@ -62,17 +62,15 @@ class Store:
|
|
|
62
62
|
msg_to_del: Message = None
|
|
63
63
|
|
|
64
64
|
msg_id: int = None
|
|
65
|
-
user: User = None
|
|
66
65
|
actors: dict[int, int] = None # key=ex_id
|
|
67
66
|
creds: dict[int, Cred] = None # key=cred_id
|
|
68
67
|
cur_creds: dict[int, list[int]] = None # pmcur_id:[cred_ids]
|
|
69
68
|
|
|
70
|
-
def __init__(self,
|
|
71
|
-
self.
|
|
69
|
+
def __init__(self, user: User):
|
|
70
|
+
self.user: User = user
|
|
71
|
+
self.curr = self.Current()
|
|
72
72
|
|
|
73
|
-
|
|
74
|
-
|
|
75
|
-
class PayReq:
|
|
73
|
+
class Pr:
|
|
76
74
|
t_cur_id: int = None
|
|
77
75
|
s_cur_id: int = None
|
|
78
76
|
t_coin_id: int = None
|
|
@@ -142,7 +140,7 @@ class Store:
|
|
|
142
140
|
logging.error(f"No {coin} addr in {ex}")
|
|
143
141
|
return addr_in, f"{coin} на {ex} по id: `{addr_in.actor.exid}`"
|
|
144
142
|
# иначе: реквизиты для фиатной оплаты
|
|
145
|
-
s_pmcur = await
|
|
143
|
+
s_pmcur = await PmCur.get(id=self.s_pmcur_id).prefetch_related("pm__grp")
|
|
146
144
|
cred = await Cred.filter(
|
|
147
145
|
**({"pmcur__pm__grp": s_pmcur.pm.grp} if s_pmcur.pm.grp else {"pmcur_id": self.s_pmcur_id}),
|
|
148
146
|
person__user__role__gte=Role.ADMIN,
|
|
@@ -151,7 +149,3 @@ class Store:
|
|
|
151
149
|
if not cred:
|
|
152
150
|
logging.error(f"No {cur.ticker} cred for {pm}")
|
|
153
151
|
return cred, f"{cur.ticker} на {pm} по номеру: {cred.repr()}"
|
|
154
|
-
|
|
155
|
-
glob: Global
|
|
156
|
-
pers: dict[int, Personal] = {}
|
|
157
|
-
payreq: dict[int, PayReq] = {}
|
|
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
|