xync-bot 0.3.25.dev1__tar.gz → 0.3.26.dev0__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.dev0}/PKG-INFO +1 -1
- {xync_bot-0.3.25.dev1 → xync_bot-0.3.26.dev0}/xync_bot/__main__.py +3 -2
- {xync_bot-0.3.25.dev1 → xync_bot-0.3.26.dev0}/xync_bot/routers/pay/handler.py +37 -18
- {xync_bot-0.3.25.dev1 → xync_bot-0.3.26.dev0}/xync_bot/routers/pay/window.py +19 -15
- xync_bot-0.3.26.dev0/xync_bot/routers/send/__init__.py +117 -0
- {xync_bot-0.3.25.dev1 → xync_bot-0.3.26.dev0}/xync_bot/store.py +4 -10
- {xync_bot-0.3.25.dev1 → xync_bot-0.3.26.dev0/xync_bot.egg-info}/PKG-INFO +1 -1
- {xync_bot-0.3.25.dev1 → xync_bot-0.3.26.dev0}/xync_bot.egg-info/SOURCES.txt +2 -1
- {xync_bot-0.3.25.dev1 → xync_bot-0.3.26.dev0}/.env.dist +0 -0
- {xync_bot-0.3.25.dev1 → xync_bot-0.3.26.dev0}/.gitignore +0 -0
- {xync_bot-0.3.25.dev1 → xync_bot-0.3.26.dev0}/.pre-commit-config.yaml +0 -0
- {xync_bot-0.3.25.dev1 → xync_bot-0.3.26.dev0}/makefile +0 -0
- {xync_bot-0.3.25.dev1 → xync_bot-0.3.26.dev0}/pager.py +0 -0
- {xync_bot-0.3.25.dev1 → xync_bot-0.3.26.dev0}/pyproject.toml +0 -0
- {xync_bot-0.3.25.dev1 → xync_bot-0.3.26.dev0}/setup.cfg +0 -0
- {xync_bot-0.3.25.dev1 → xync_bot-0.3.26.dev0}/test_main.http +0 -0
- {xync_bot-0.3.25.dev1 → xync_bot-0.3.26.dev0}/xync_bot/loader.py +0 -0
- {xync_bot-0.3.25.dev1 → xync_bot-0.3.26.dev0}/xync_bot/routers/__init__.py +0 -0
- {xync_bot-0.3.25.dev1 → xync_bot-0.3.26.dev0}/xync_bot/routers/cond/__init__.py +0 -0
- {xync_bot-0.3.25.dev1 → xync_bot-0.3.26.dev0}/xync_bot/routers/cond/func.py +0 -0
- {xync_bot-0.3.25.dev1 → xync_bot-0.3.26.dev0}/xync_bot/routers/main/__init__.py +0 -0
- {xync_bot-0.3.25.dev1 → xync_bot-0.3.26.dev0}/xync_bot/routers/main/handler.py +0 -0
- {xync_bot-0.3.25.dev1 → xync_bot-0.3.26.dev0}/xync_bot/routers/order.py +0 -0
- {xync_bot-0.3.25.dev1 → xync_bot-0.3.26.dev0}/xync_bot/routers/pay/cd.py +0 -0
- {xync_bot-0.3.25.dev1 → xync_bot-0.3.26.dev0}/xync_bot/routers/pay/dep.py +0 -0
- {xync_bot-0.3.25.dev1 → xync_bot-0.3.26.dev0}/xync_bot/routers/photo.py +0 -0
- {xync_bot-0.3.25.dev1 → xync_bot-0.3.26.dev0}/xync_bot/routers/vpn.py +0 -0
- {xync_bot-0.3.25.dev1 → xync_bot-0.3.26.dev0}/xync_bot/routers/xicon.png +0 -0
- {xync_bot-0.3.25.dev1 → xync_bot-0.3.26.dev0}/xync_bot/shared.py +0 -0
- {xync_bot-0.3.25.dev1 → xync_bot-0.3.26.dev0}/xync_bot/typs.py +0 -0
- {xync_bot-0.3.25.dev1 → xync_bot-0.3.26.dev0}/xync_bot.egg-info/dependency_links.txt +0 -0
- {xync_bot-0.3.25.dev1 → xync_bot-0.3.26.dev0}/xync_bot.egg-info/requires.txt +0 -0
- {xync_bot-0.3.25.dev1 → xync_bot-0.3.26.dev0}/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,46 +15,53 @@ 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
|
-
|
|
40
|
+
uid = query.from_user.id
|
|
41
|
+
store.pers.curr.is_fiat = False
|
|
38
42
|
await gather(window.coin_select(query.message, store), ans(query, "Понял, крипта"))
|
|
39
43
|
|
|
40
44
|
|
|
41
45
|
@pr.callback_query(cd.Coin.filter())
|
|
42
46
|
async def h_got_coin(query: CallbackQuery, callback_data: cd.Coin, store: Store):
|
|
43
47
|
"""Step 3c: Select target ex"""
|
|
44
|
-
|
|
48
|
+
uid = query.from_user.id
|
|
49
|
+
setattr(store.pay, ("t" if store.pers.curr.is_target else "s") + "_coin_id", callback_data.id)
|
|
45
50
|
await gather(window.ex_select(query.message, store), ans(query, "Эта монета есть на следующих биржах"))
|
|
46
51
|
|
|
47
52
|
|
|
48
53
|
@pr.callback_query(cd.Cur.filter())
|
|
49
54
|
async def h_got_cur(query: CallbackQuery, callback_data: cd.Cur, store: Store):
|
|
50
55
|
"""Step 3f: Select target pm"""
|
|
51
|
-
|
|
56
|
+
uid = query.from_user.id
|
|
57
|
+
setattr(store.pay, ("t" if store.pers.curr.is_target else "s") + "_cur_id", callback_data.id)
|
|
52
58
|
await gather(window.pm(query.message, store), ans(query, "Вот платежные системы доступные для этой валюты"))
|
|
53
59
|
|
|
54
60
|
|
|
55
61
|
@pr.callback_query(cd.Pm.filter(F.is_target))
|
|
56
62
|
async def h_got_target_pm(query: CallbackQuery, callback_data: cd.Pm, state: FSMContext, store: Store):
|
|
57
63
|
"""Step 4f: Fill target cred.detail"""
|
|
64
|
+
uid = query.from_user.id
|
|
58
65
|
store.pay.t_pmcur_id = callback_data.pmcur_id
|
|
59
66
|
await gather(
|
|
60
67
|
window.fill_cred_dtl(query.message, store),
|
|
@@ -65,6 +72,7 @@ async def h_got_target_pm(query: CallbackQuery, callback_data: cd.Pm, state: FSM
|
|
|
65
72
|
|
|
66
73
|
@pr.callback_query(cd.Cred.filter())
|
|
67
74
|
async def h_got_cred(query: CallbackQuery, callback_data: cd.Cred, state: FSMContext, store: Store):
|
|
75
|
+
uid = query.from_user.id
|
|
68
76
|
store.pay.cred_id = callback_data.id
|
|
69
77
|
await gather(
|
|
70
78
|
window.amount(query.message, store), ans(query, "Теперь нужна сумма"), state.set_state(dep.PaymentState.amount)
|
|
@@ -81,25 +89,27 @@ async def h_got_cred_dtl(msg: Message, state: FSMContext, store: Store):
|
|
|
81
89
|
@pr.message(dep.CredState.name)
|
|
82
90
|
async def h_got_cred_name(msg: Message, state: FSMContext, store: Store):
|
|
83
91
|
"""Step 5f: Save target cred"""
|
|
92
|
+
uid = msg.from_user.id
|
|
84
93
|
cred, _ = await models.Cred.update_or_create(
|
|
85
94
|
{"name": msg.text},
|
|
86
95
|
detail=store.pay.cred_dtl,
|
|
87
|
-
person_id=store.
|
|
96
|
+
person_id=store.pers[uid].user.person_id,
|
|
88
97
|
pmcur_id=store.pay.t_pmcur_id,
|
|
89
98
|
)
|
|
90
99
|
store.pay.cred_id = cred.id
|
|
91
|
-
store.
|
|
100
|
+
store.pers[uid].creds[cred.id] = cred
|
|
92
101
|
await gather(window.amount(msg, store), dlt(msg), state.set_state(dep.PaymentState.amount))
|
|
93
102
|
|
|
94
103
|
|
|
95
104
|
@pr.callback_query(cd.Ex.filter())
|
|
96
105
|
async def h_got_ex(query: CallbackQuery, callback_data: cd.Ex, state: FSMContext, store: Store):
|
|
97
106
|
"""Step 4c: Save target"""
|
|
98
|
-
|
|
107
|
+
uid = query.from_user.id
|
|
108
|
+
ist = store.pers.curr.is_target
|
|
99
109
|
setattr(store.pay, ("t" if ist else "s") + "_ex_id", callback_data.id)
|
|
100
110
|
if ist:
|
|
101
111
|
await window.amount(query.message, store)
|
|
102
|
-
actor_id = store.
|
|
112
|
+
actor_id = store.pers[uid].actors[store.pay.t_ex_id]
|
|
103
113
|
addr = await models.Addr.get(coin_id=store.pay.t_coin_id, actor_id=actor_id)
|
|
104
114
|
store.pay.addr_id = addr.id
|
|
105
115
|
else:
|
|
@@ -111,19 +121,23 @@ async def h_got_ex(query: CallbackQuery, callback_data: cd.Ex, state: FSMContext
|
|
|
111
121
|
@pr.message(dep.PaymentState.amount)
|
|
112
122
|
async def h_got_amount(msg: Message, state: FSMContext, store: Store):
|
|
113
123
|
"""Step 6: Save a target amount"""
|
|
124
|
+
uid = msg.from_user.id
|
|
114
125
|
if not msg.text.isnumeric():
|
|
115
|
-
store.curr.msg_to_del = await msg.answer("Пожалуйста, введите корректное число")
|
|
126
|
+
store.pers.curr.msg_to_del = await msg.answer("Пожалуйста, введите корректное число")
|
|
116
127
|
return
|
|
117
|
-
if store.curr.msg_to_del:
|
|
118
|
-
await store.curr.msg_to_del.delete()
|
|
128
|
+
if store.pers.curr.msg_to_del:
|
|
129
|
+
await store.pers.curr.msg_to_del.delete()
|
|
119
130
|
store.pay.amount = float(msg.text)
|
|
120
131
|
"""Step 7: Select source type"""
|
|
121
|
-
store.curr.is_target = False
|
|
122
|
-
await gather(
|
|
132
|
+
store.pers.curr.is_target = False
|
|
133
|
+
await gather(
|
|
134
|
+
(window.type_select if store.pers.curr.is_fiat else window.cur_select)(msg, store), dlt(msg), state.clear()
|
|
135
|
+
)
|
|
123
136
|
|
|
124
137
|
|
|
125
138
|
@pr.callback_query(cd.Pm.filter(F.is_target.__eq__(0)))
|
|
126
139
|
async def h_got_source_pm(query: CallbackQuery, callback_data: cd.Pm, store: Store):
|
|
140
|
+
uid = query.from_user.id
|
|
127
141
|
store.pay.s_pmcur_id = callback_data.pmcur_id
|
|
128
142
|
await gather(
|
|
129
143
|
window.set_ppo(query.message, store),
|
|
@@ -133,12 +147,14 @@ async def h_got_source_pm(query: CallbackQuery, callback_data: cd.Pm, store: Sto
|
|
|
133
147
|
|
|
134
148
|
@pr.callback_query(cd.Ppo.filter())
|
|
135
149
|
async def h_got_ppo(query: CallbackQuery, callback_data: cd.Ppo, store: Store):
|
|
150
|
+
uid = query.from_user.id
|
|
136
151
|
store.pay.ppo = callback_data.num
|
|
137
152
|
await gather(window.set_urgency(query.message, store), ans(query, str(callback_data.num)))
|
|
138
153
|
|
|
139
154
|
|
|
140
155
|
@pr.callback_query(cd.Time.filter())
|
|
141
156
|
async def h_got_urgency(query: CallbackQuery, callback_data: cd.Time, store: Store):
|
|
157
|
+
# payreq_id = store.pers[query.from_user.id].
|
|
142
158
|
store.pay.urg = callback_data.minutes
|
|
143
159
|
await window.create_payreq(query.message, store)
|
|
144
160
|
await ans(query, f"Ok {callback_data.minutes} min.")
|
|
@@ -147,6 +163,7 @@ async def h_got_urgency(query: CallbackQuery, callback_data: cd.Time, store: Sto
|
|
|
147
163
|
# ACTIONS
|
|
148
164
|
@pr.callback_query(cd.Action.filter(F.act.__eq__(cd.ActionType.received)))
|
|
149
165
|
async def payment_confirmed(query: CallbackQuery, state: FSMContext):
|
|
166
|
+
uid = query.from_user.id
|
|
150
167
|
await ans(query, None)
|
|
151
168
|
payed_at = datetime.now()
|
|
152
169
|
await state.update_data(timer_active=False, payed_at_formatted=payed_at)
|
|
@@ -161,6 +178,7 @@ async def payment_confirmed(query: CallbackQuery, state: FSMContext):
|
|
|
161
178
|
|
|
162
179
|
@pr.callback_query(cd.Action.filter(F.act.__eq__(cd.ActionType.not_received)))
|
|
163
180
|
async def no_payment(query: CallbackQuery, state: FSMContext):
|
|
181
|
+
uid = query.from_user.id
|
|
164
182
|
await ans(query, None)
|
|
165
183
|
await state.update_data(timer_active=False)
|
|
166
184
|
await query.message.edit_text("Платеж не получен!")
|
|
@@ -171,6 +189,7 @@ async def no_payment(query: CallbackQuery, state: FSMContext):
|
|
|
171
189
|
|
|
172
190
|
@pr.message(dep.Report.text)
|
|
173
191
|
async def payment_not_specified(msg: Message, state: FSMContext):
|
|
192
|
+
uid = msg.from_user.id
|
|
174
193
|
await state.update_data(text=msg.text)
|
|
175
194
|
data = await state.get_data()
|
|
176
195
|
complaint_text = (
|
|
@@ -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
|
+
)
|
|
@@ -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
|
|
@@ -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
|