xync-bot 0.3.24.dev5__py3-none-any.whl → 0.3.24.dev7__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-bot might be problematic. Click here for more details.
- xync_bot/routers/__init__.py +2 -2
- xync_bot/routers/pay/dep.py +13 -6
- xync_bot/routers/pay/handler.py +13 -23
- xync_bot/routers/pay/window.py +3 -3
- {xync_bot-0.3.24.dev5.dist-info → xync_bot-0.3.24.dev7.dist-info}/METADATA +1 -1
- {xync_bot-0.3.24.dev5.dist-info → xync_bot-0.3.24.dev7.dist-info}/RECORD +8 -8
- {xync_bot-0.3.24.dev5.dist-info → xync_bot-0.3.24.dev7.dist-info}/WHEEL +0 -0
- {xync_bot-0.3.24.dev5.dist-info → xync_bot-0.3.24.dev7.dist-info}/top_level.txt +0 -0
xync_bot/routers/__init__.py
CHANGED
|
@@ -61,9 +61,9 @@ class Store:
|
|
|
61
61
|
class Permanent:
|
|
62
62
|
msg_id: int = None
|
|
63
63
|
user: models.User = None
|
|
64
|
-
actors: dict[int, models.Actor] = None # key=
|
|
64
|
+
actors: dict[int, models.Actor] = None # key=actor_id
|
|
65
65
|
ex_actors: dict[int, list[int]] = None # key=ex_id
|
|
66
|
-
creds: dict[int, models.Cred] = None # key=
|
|
66
|
+
creds: dict[int, models.Cred] = None # key=cred_id
|
|
67
67
|
cur_creds: dict[int, list[int]] = None # pmcur_id:[cred_ids]
|
|
68
68
|
|
|
69
69
|
class Current:
|
xync_bot/routers/pay/dep.py
CHANGED
|
@@ -1,6 +1,7 @@
|
|
|
1
1
|
from asyncio import gather
|
|
2
2
|
from enum import IntEnum
|
|
3
3
|
|
|
4
|
+
from aiogram.exceptions import TelegramBadRequest
|
|
4
5
|
from aiogram.fsm.state import StatesGroup, State
|
|
5
6
|
from aiogram.types import Message, InlineKeyboardMarkup
|
|
6
7
|
from pyrogram.types import CallbackQuery
|
|
@@ -88,10 +89,13 @@ async def fill_creds(person_id: int) -> tuple[dict[int, models.Cred], dict[int,
|
|
|
88
89
|
async def fill_actors(person_id: int) -> tuple[dict[int, models.Actor], dict[int, list[int]]]:
|
|
89
90
|
aq = models.Actor.filter(person_id=person_id)
|
|
90
91
|
actors = {a.id: a for a in await aq}
|
|
91
|
-
|
|
92
|
-
exi: ids
|
|
92
|
+
ex_act_id = {
|
|
93
|
+
exi: ids[0]
|
|
94
|
+
for exi, ids in await aq.annotate(ids=ArrayAgg("id")) # todo: check len(ids) == 1
|
|
95
|
+
.group_by("ex_id")
|
|
96
|
+
.values_list("ex_id", "ids")
|
|
93
97
|
}
|
|
94
|
-
return actors,
|
|
98
|
+
return actors, ex_act_id
|
|
95
99
|
|
|
96
100
|
|
|
97
101
|
async def edit(msg: Message, txt: str, rm: InlineKeyboardMarkup):
|
|
@@ -110,6 +114,9 @@ async def edt(msg: Message, txt: str, rm: InlineKeyboardMarkup):
|
|
|
110
114
|
if msg.message_id == msg.bot.store.perm.msg_id:
|
|
111
115
|
await msg.edit_text(txt, reply_markup=rm)
|
|
112
116
|
else: # окно вызвано в ответ на текст, а не кнопку
|
|
113
|
-
|
|
114
|
-
|
|
115
|
-
|
|
117
|
+
try:
|
|
118
|
+
await msg.bot.edit_message_text(
|
|
119
|
+
txt, chat_id=msg.chat.id, message_id=msg.bot.store.perm.msg_id, reply_markup=rm
|
|
120
|
+
)
|
|
121
|
+
except TelegramBadRequest as e:
|
|
122
|
+
print(msg.bot.store.perm.msg_id, e)
|
xync_bot/routers/pay/handler.py
CHANGED
|
@@ -37,7 +37,7 @@ async def h_got_fiat_type(query: CallbackQuery, bot: PGram):
|
|
|
37
37
|
async def h_got_crypto_type(query: CallbackQuery, bot: PGram):
|
|
38
38
|
"""Step 2c: Select coin"""
|
|
39
39
|
bot.store.curr.is_fiat = False
|
|
40
|
-
(bot.store.perm.actors, bot.store.perm.
|
|
40
|
+
(bot.store.perm.actors, bot.store.perm.ex_actors), *_ = await gather(
|
|
41
41
|
fill_actors(bot.store.perm.user.person_id), window.coin_select(query.message), ans(query, "Понял, крипта")
|
|
42
42
|
)
|
|
43
43
|
|
|
@@ -97,14 +97,15 @@ async def h_got_cred_name(msg: Message, state: FSMContext):
|
|
|
97
97
|
|
|
98
98
|
|
|
99
99
|
@pay.callback_query(cd.Ex.filter())
|
|
100
|
-
async def h_got_ex(query: CallbackQuery, callback_data: cd.Ex):
|
|
100
|
+
async def h_got_ex(query: CallbackQuery, callback_data: cd.Ex, state: FSMContext):
|
|
101
101
|
"""Step 4c: Save target"""
|
|
102
102
|
store: Store = query.message.bot.store
|
|
103
103
|
ist = store.curr.is_target
|
|
104
|
-
setattr(store, ("t" if ist else "s") + "_ex_id", callback_data.id)
|
|
104
|
+
setattr(store.pay, ("t" if ist else "s") + "_ex_id", callback_data.id)
|
|
105
105
|
await gather(
|
|
106
106
|
(window.amount if ist else window.set_ppo)(query.message),
|
|
107
107
|
ans(query, f"Биржа {store.glob.exs[callback_data.id]} выбрана"),
|
|
108
|
+
state.set_state(dep.PaymentState.amount),
|
|
108
109
|
)
|
|
109
110
|
|
|
110
111
|
|
|
@@ -125,18 +126,18 @@ async def h_got_amount(msg: Message, state: FSMContext):
|
|
|
125
126
|
|
|
126
127
|
@pay.callback_query(cd.Pm.filter(F.is_target.__eq__(0)))
|
|
127
128
|
async def h_got_source_pm(query: CallbackQuery, callback_data: cd.Pm):
|
|
128
|
-
query.message.bot.store
|
|
129
|
+
store: Store = query.message.bot.store
|
|
130
|
+
store.pay.s_pmcur_id = callback_data.pmcur_id
|
|
129
131
|
await gather(
|
|
130
132
|
window.set_ppo(query.message),
|
|
131
|
-
query.
|
|
132
|
-
ans(query, callback_data.name),
|
|
133
|
+
ans(query, store.glob.pms[callback_data.pmcur_id]),
|
|
133
134
|
)
|
|
134
135
|
|
|
135
136
|
|
|
136
137
|
@pay.callback_query(cd.Ppo.filter())
|
|
137
138
|
async def h_got_ppo(query: CallbackQuery, callback_data: cd.Ppo):
|
|
138
139
|
query.message.bot.store.pay.ppo = callback_data.num
|
|
139
|
-
await gather(window.set_urgency(query.message),
|
|
140
|
+
await gather(window.set_urgency(query.message), ans(query, str(callback_data.num)))
|
|
140
141
|
|
|
141
142
|
|
|
142
143
|
@pay.callback_query(cd.Time.filter())
|
|
@@ -146,8 +147,8 @@ async def process_time_selection(query: CallbackQuery, callback_data: cd.Time, s
|
|
|
146
147
|
pay_until = datetime.now() + timedelta(minutes=callback_data.minutes)
|
|
147
148
|
|
|
148
149
|
if ex_id := (store.pay.t_ex_id or store.pay.s_ex_id):
|
|
149
|
-
actor_id = store.perm.
|
|
150
|
-
if not (addr_id := store.pay.
|
|
150
|
+
actor_id = store.perm.ex_actors[ex_id]
|
|
151
|
+
if not (addr_id := store.pay.addr_id):
|
|
151
152
|
coin_id = store.pay.t_coin_id or store.pay.s_coin_id
|
|
152
153
|
addr_id = await models.Addr.get(coin_id=coin_id, actor_id=actor_id).values_list("id", flat=True)
|
|
153
154
|
store.pay.addr_id = addr_id
|
|
@@ -190,7 +191,6 @@ async def payment_confirmed(query: CallbackQuery, state: FSMContext):
|
|
|
190
191
|
builder = InlineKeyboardBuilder()
|
|
191
192
|
builder.button(text="Новый платеж💸", callback_data=cd.PayNav(to=cd.PayStep.t_type))
|
|
192
193
|
await query.message.answer("✅ Платеж успешно подтвержден", reply_markup=builder.as_markup())
|
|
193
|
-
await query.message.delete()
|
|
194
194
|
await state.clear()
|
|
195
195
|
|
|
196
196
|
|
|
@@ -214,20 +214,17 @@ async def payment_not_specified(msg: Message, state: FSMContext):
|
|
|
214
214
|
f"Детали платежа: {data["text"]}\n"
|
|
215
215
|
f"Время: {msg.date.strftime('%Y-%m-%d %H:%M:%S')}"
|
|
216
216
|
)
|
|
217
|
-
await msg.bot.send_message(chat_id="
|
|
217
|
+
await msg.bot.send_message(chat_id="xyncpay", text=complaint_text)
|
|
218
218
|
|
|
219
219
|
|
|
220
220
|
# NAVIGATION
|
|
221
221
|
@pay.callback_query(cd.PayNav.filter(F.to.in_([cd.PayStep.t_type, cd.PayStep.s_type])))
|
|
222
222
|
async def handle_home(query: CallbackQuery, state: FSMContext):
|
|
223
|
-
await query.message.
|
|
224
|
-
await ans(query, None)
|
|
225
|
-
await window.type_select(query.message, await state.get_value("is_target"))
|
|
223
|
+
await gather(window.type_select(query.message), state.clear(), ans(query, "Создаем платеж заново"))
|
|
226
224
|
|
|
227
225
|
|
|
228
226
|
@pay.callback_query(cd.PayNav.filter(F.to.in_([cd.PayStep.t_coin, cd.PayStep.s_coin])))
|
|
229
227
|
async def to_coin_select(query: CallbackQuery, state: FSMContext):
|
|
230
|
-
await query.message.delete()
|
|
231
228
|
await ans(query, None)
|
|
232
229
|
is_target = await state.get_value("is_target")
|
|
233
230
|
pref = "t" if is_target else "s"
|
|
@@ -237,7 +234,6 @@ async def to_coin_select(query: CallbackQuery, state: FSMContext):
|
|
|
237
234
|
|
|
238
235
|
@pay.callback_query(cd.PayNav.filter(F.to.in_([cd.PayStep.t_cur, cd.PayStep.s_cur])))
|
|
239
236
|
async def to_cur_select(query: CallbackQuery, state: FSMContext):
|
|
240
|
-
await query.message.delete()
|
|
241
237
|
await ans(query, None)
|
|
242
238
|
is_target = await state.get_value("is_target")
|
|
243
239
|
pref = "t" if is_target else "s"
|
|
@@ -247,7 +243,6 @@ async def to_cur_select(query: CallbackQuery, state: FSMContext):
|
|
|
247
243
|
|
|
248
244
|
@pay.callback_query(cd.PayNav.filter(F.to.in_([cd.PayStep.t_pm, cd.PayStep.s_pm])))
|
|
249
245
|
async def to_pm_select(query: CallbackQuery, state: FSMContext):
|
|
250
|
-
await query.message.delete()
|
|
251
246
|
await ans(query, None)
|
|
252
247
|
await window.pm(query.message)
|
|
253
248
|
|
|
@@ -257,21 +252,17 @@ async def back_to_cred_detail(query: CallbackQuery, state: FSMContext):
|
|
|
257
252
|
await ans(query, None)
|
|
258
253
|
await state.update_data(detail=None)
|
|
259
254
|
await window.fill_cred_dtl(query.message)
|
|
260
|
-
await query.message.delete()
|
|
261
255
|
|
|
262
256
|
|
|
263
257
|
@pay.callback_query(cd.PayNav.filter(F.to.__eq__(cd.PayStep.t_cred_name)))
|
|
264
258
|
async def back_to_cred_name(query: CallbackQuery, state: FSMContext):
|
|
265
|
-
await query.message.delete()
|
|
266
259
|
await ans(query, None)
|
|
267
260
|
await state.update_data(name=None)
|
|
268
261
|
await window.fill_cred_name(query.message)
|
|
269
|
-
await query.message.delete()
|
|
270
262
|
|
|
271
263
|
|
|
272
264
|
@pay.callback_query(cd.PayNav.filter(F.to.in_([cd.PayStep.t_ex, cd.PayStep.s_ex])))
|
|
273
265
|
async def back_to_ex_select(query: CallbackQuery, state: FSMContext):
|
|
274
|
-
await query.message.delete()
|
|
275
266
|
await ans(query, None)
|
|
276
267
|
await state.update_data({("t" if await state.get_value("is_target") else "s") + "ex_id": None})
|
|
277
268
|
await window.ex_select(query.message)
|
|
@@ -279,15 +270,14 @@ async def back_to_ex_select(query: CallbackQuery, state: FSMContext):
|
|
|
279
270
|
|
|
280
271
|
@pay.callback_query(cd.PayNav.filter(F.to.__eq__(cd.PayStep.t_amount)))
|
|
281
272
|
async def back_to_amount(query: CallbackQuery, state: FSMContext):
|
|
282
|
-
await query.message.delete()
|
|
283
273
|
await ans(query, None)
|
|
284
274
|
await state.update_data(amount=None)
|
|
285
275
|
await window.amount(query.message)
|
|
276
|
+
await state.set_state(dep.PaymentState.amount)
|
|
286
277
|
|
|
287
278
|
|
|
288
279
|
@pay.callback_query(cd.PayNav.filter(F.to.in_([cd.PayStep.t_pm])))
|
|
289
280
|
async def back_to_payment(query: CallbackQuery, state: FSMContext):
|
|
290
|
-
await query.message.delete()
|
|
291
281
|
await ans(query, None)
|
|
292
282
|
await state.update_data(payment=None)
|
|
293
283
|
await window.pm(query.message)
|
xync_bot/routers/pay/window.py
CHANGED
|
@@ -42,7 +42,7 @@ async def cur_select(msg: Message):
|
|
|
42
42
|
builder.button(text="Назад к выбору типа", callback_data=cd.PayNav(to=cd.PayStep.t_type))
|
|
43
43
|
builder.adjust(3, 3, 3, 3, 3, 1)
|
|
44
44
|
sfx = "ую нужно" if ist else "ой платишь"
|
|
45
|
-
await msg
|
|
45
|
+
await edt(msg, "Выбери валюту котор" + sfx, builder.as_markup())
|
|
46
46
|
|
|
47
47
|
|
|
48
48
|
async def coin_select(msg: Message):
|
|
@@ -135,14 +135,14 @@ async def amount(msg: Message):
|
|
|
135
135
|
builder.button(text="Назад к вводу имени", callback_data=cd.PayNav(to=cd.PayStep.t_cred_name))
|
|
136
136
|
t_name = store.glob.pms[store.pay.t_pmcur_id]
|
|
137
137
|
else:
|
|
138
|
-
cur_coin = store.glob.
|
|
138
|
+
cur_coin = store.glob.coins[store.pay.t_coin_id]
|
|
139
139
|
builder.button(text="Назад к выбору биржи", callback_data=cd.PayNav(to=cd.PayStep.t_ex))
|
|
140
140
|
t_name = store.glob.exs[store.pay.t_ex_id]
|
|
141
141
|
|
|
142
142
|
builder.button(text="Домой", callback_data=cd.PayNav(to=cd.PayStep.t_type))
|
|
143
143
|
builder.adjust(2)
|
|
144
144
|
|
|
145
|
-
await msg
|
|
145
|
+
await edt(msg, f"Введите нужную сумму {cur_coin} для {t_name}", builder.as_markup())
|
|
146
146
|
|
|
147
147
|
|
|
148
148
|
async def set_ppo(msg: Message):
|
|
@@ -2,7 +2,7 @@ xync_bot/__init__.py,sha256=0m9zUYZUJHEJUMb24CU10wYfCIAg8eourNFlBLsHgWU,705
|
|
|
2
2
|
xync_bot/loader.py,sha256=4ZeR-yVMoOmswdLS0UEBG19K7JVcuvH6WpP-_0yAK3I,573
|
|
3
3
|
xync_bot/shared.py,sha256=MlKkTrsT29l7fF6-qAN9FO14cSuXuOuYxbNY5F4S2w4,137
|
|
4
4
|
xync_bot/typs.py,sha256=47DEQpj8HBSa-_TImW-5JCeuQeRkm5NMpJWZG3hSuFU,0
|
|
5
|
-
xync_bot/routers/__init__.py,sha256=
|
|
5
|
+
xync_bot/routers/__init__.py,sha256=oYmYlDhtk6Gmy3QaDNlWV9ym-JnaPNenWglfffJqQb4,3179
|
|
6
6
|
xync_bot/routers/main.py,sha256=FumWa48ORhV77Df6NbEosHfgmFIe_Y2ci6IkJCvU4Zs,9535
|
|
7
7
|
xync_bot/routers/order.py,sha256=ZKWDLyiWrXzcR-aHKLBTBCACwp-P0Vvnr22T-EuLHaM,274
|
|
8
8
|
xync_bot/routers/photo.py,sha256=aq6ImIOoZQYTW-lEy26qjgj5TYAuk4bQjgiCv64mPJs,1203
|
|
@@ -11,10 +11,10 @@ xync_bot/routers/xicon.png,sha256=O57_kvzhVcCXSoGYZ61m0dW9pizY6gxR8Yj5aeCP0RQ,42
|
|
|
11
11
|
xync_bot/routers/cond/__init__.py,sha256=It4djVO8AxXL1I76buRz8yYF12dsjXaa4WNtPdb7CFc,4333
|
|
12
12
|
xync_bot/routers/cond/func.py,sha256=m0NWDKunbqDJQmhv_5UnpjxjRzn78GFG94ThOFLVlQo,4720
|
|
13
13
|
xync_bot/routers/pay/cd.py,sha256=WGeGqFUvEeXWcL42EJ3jjyFAK1rg2X7yp5Z-W5GiWXE,900
|
|
14
|
-
xync_bot/routers/pay/dep.py,sha256=
|
|
15
|
-
xync_bot/routers/pay/handler.py,sha256=
|
|
16
|
-
xync_bot/routers/pay/window.py,sha256=
|
|
17
|
-
xync_bot-0.3.24.
|
|
18
|
-
xync_bot-0.3.24.
|
|
19
|
-
xync_bot-0.3.24.
|
|
20
|
-
xync_bot-0.3.24.
|
|
14
|
+
xync_bot/routers/pay/dep.py,sha256=QYB5vgDjdEDO-kZGdYsFq7nv3lRXjpquumJRArbg1jY,4038
|
|
15
|
+
xync_bot/routers/pay/handler.py,sha256=g_lPBK2reNB-miDo3rYkSVaOehuHm9L1hPLTgcFy8VA,11314
|
|
16
|
+
xync_bot/routers/pay/window.py,sha256=pr4oZpZii7SFQ5UsmzciPuZa_MM57OWseZTU1XRl7LY,9290
|
|
17
|
+
xync_bot-0.3.24.dev7.dist-info/METADATA,sha256=v2T5phN-9DwmyQxxlPVBp8JqPfl0f5q6M984F8dw2Ks,751
|
|
18
|
+
xync_bot-0.3.24.dev7.dist-info/WHEEL,sha256=_zCd3N1l69ArxyTb8rzEoP9TpbYXkqRFSNOD5OuxnTs,91
|
|
19
|
+
xync_bot-0.3.24.dev7.dist-info/top_level.txt,sha256=O2IjMc1ryAf0rwIXWohSNT5Kzcs9johgKRDz8lCC0rs,9
|
|
20
|
+
xync_bot-0.3.24.dev7.dist-info/RECORD,,
|
|
File without changes
|
|
File without changes
|