xync-bot 0.3.7.dev4__py3-none-any.whl → 0.3.24.dev3__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/__init__.py +6 -3
- xync_bot/loader.py +2 -0
- xync_bot/routers/__init__.py +64 -0
- xync_bot/routers/pay/cd.py +50 -0
- xync_bot/routers/pay/dep.py +70 -0
- xync_bot/routers/pay/handler.py +299 -0
- xync_bot/routers/pay/window.py +232 -0
- {xync_bot-0.3.7.dev4.dist-info → xync_bot-0.3.24.dev3.dist-info}/METADATA +1 -1
- xync_bot-0.3.24.dev3.dist-info/RECORD +20 -0
- xync_bot/routers/pay/main.py +0 -133
- xync_bot-0.3.7.dev4.dist-info/RECORD +0 -17
- {xync_bot-0.3.7.dev4.dist-info → xync_bot-0.3.24.dev3.dist-info}/WHEEL +0 -0
- {xync_bot-0.3.7.dev4.dist-info → xync_bot-0.3.24.dev3.dist-info}/top_level.txt +0 -0
xync_bot/__init__.py
CHANGED
|
@@ -5,10 +5,11 @@ from PGram import Bot
|
|
|
5
5
|
from aiogram.client.default import DefaultBotProperties
|
|
6
6
|
from x_model import init_db
|
|
7
7
|
|
|
8
|
-
from xync_bot.routers
|
|
8
|
+
from xync_bot.routers import Store
|
|
9
|
+
from xync_bot.routers.cond import cr as cr
|
|
9
10
|
|
|
10
11
|
# from xync_bot.routers.main import mr
|
|
11
|
-
from xync_bot.routers.pay.
|
|
12
|
+
from xync_bot.routers.pay.handler import pay as pay
|
|
12
13
|
|
|
13
14
|
if __name__ == "__main__":
|
|
14
15
|
from xync_bot.loader import TOKEN, TORM
|
|
@@ -17,7 +18,9 @@ if __name__ == "__main__":
|
|
|
17
18
|
|
|
18
19
|
async def main() -> None:
|
|
19
20
|
cn = await init_db(TORM)
|
|
20
|
-
|
|
21
|
+
store = Store()
|
|
22
|
+
store.glob = await Store.Global()
|
|
23
|
+
bot = Bot(TOKEN, [pay], cn, default=DefaultBotProperties(parse_mode="HTML"), store=store)
|
|
21
24
|
await bot.start()
|
|
22
25
|
|
|
23
26
|
run(main())
|
xync_bot/loader.py
CHANGED
xync_bot/routers/__init__.py
CHANGED
|
@@ -0,0 +1,64 @@
|
|
|
1
|
+
from tortoise.functions import Min
|
|
2
|
+
from xync_schema import models
|
|
3
|
+
|
|
4
|
+
from xync_bot.routers.pay.dep import flags
|
|
5
|
+
|
|
6
|
+
|
|
7
|
+
class SingleStore(type):
|
|
8
|
+
_store = None
|
|
9
|
+
|
|
10
|
+
async def __call__(cls):
|
|
11
|
+
if not cls._store:
|
|
12
|
+
cls._store = super(SingleStore, cls).__call__()
|
|
13
|
+
cls._store.coins = {k: v for k, v in await models.Coin.all().order_by("ticker").values_list("id", "ticker")}
|
|
14
|
+
cls._store.curs = {
|
|
15
|
+
k: v
|
|
16
|
+
for k, v in await models.Cur.filter(ticker__in=flags.keys())
|
|
17
|
+
.order_by("ticker")
|
|
18
|
+
.values_list("id", "ticker")
|
|
19
|
+
}
|
|
20
|
+
cls._store.exs = {k: v for k, v in await models.Ex.all().values_list("id", "name")}
|
|
21
|
+
cls._store.pms = {
|
|
22
|
+
k: v
|
|
23
|
+
for k, v in await models.Pmex.filter(pm__pmcurs__id__in=cls._store.curs.keys())
|
|
24
|
+
.annotate(sname=Min("name"))
|
|
25
|
+
.group_by("pm_id")
|
|
26
|
+
.values_list("pm_id", "sname")
|
|
27
|
+
}
|
|
28
|
+
cls._store.coinexs = {
|
|
29
|
+
c.id: [ex.ex_id for ex in c.coinexs] for c in await models.Coin.all().prefetch_related("coinexs")
|
|
30
|
+
}
|
|
31
|
+
cls._store.curpms = {
|
|
32
|
+
c.id: [pmc.pm_id for pmc in c.pmcurs]
|
|
33
|
+
for c in await models.Cur.filter(id__in=cls._store.curs.keys()).prefetch_related("pmcurs")
|
|
34
|
+
}
|
|
35
|
+
|
|
36
|
+
return cls._store
|
|
37
|
+
|
|
38
|
+
|
|
39
|
+
class Store:
|
|
40
|
+
class Global(metaclass=SingleStore):
|
|
41
|
+
coins: dict[int, str] # id:ticker
|
|
42
|
+
curs: dict[int, str] # id:ticker
|
|
43
|
+
exs: dict[int, str] # id:name
|
|
44
|
+
pms: dict[int, models.Pm] # id:name
|
|
45
|
+
|
|
46
|
+
class Permanent:
|
|
47
|
+
user: models.User
|
|
48
|
+
actors: dict[int, models.Actor] # key=ex_id
|
|
49
|
+
|
|
50
|
+
class Current:
|
|
51
|
+
t_cur_id: int = None
|
|
52
|
+
s_cur_id: int = None
|
|
53
|
+
t_coin_id: int = None
|
|
54
|
+
s_coin_id: int = None
|
|
55
|
+
t_pm_id: int = None
|
|
56
|
+
s_pm_id: int = None
|
|
57
|
+
t_ex_id: int = None
|
|
58
|
+
s_ex_id: int = None
|
|
59
|
+
addr: models.Addr = None
|
|
60
|
+
cred: models.Cred = None
|
|
61
|
+
|
|
62
|
+
glob: Global
|
|
63
|
+
perm: Permanent = Permanent()
|
|
64
|
+
curr: Current = Current()
|
|
@@ -0,0 +1,50 @@
|
|
|
1
|
+
from aiogram.filters.callback_data import CallbackData
|
|
2
|
+
|
|
3
|
+
from xync_bot.routers.pay.dep import PayStep, ActionType
|
|
4
|
+
|
|
5
|
+
|
|
6
|
+
class TargetType(CallbackData, prefix="target"):
|
|
7
|
+
is_fiat: int # bool
|
|
8
|
+
is_target: int # bool
|
|
9
|
+
|
|
10
|
+
|
|
11
|
+
class Cur(CallbackData, prefix="cur"):
|
|
12
|
+
id: int
|
|
13
|
+
is_target: int # bool
|
|
14
|
+
|
|
15
|
+
|
|
16
|
+
class Coin(CallbackData, prefix="coin"):
|
|
17
|
+
id: int
|
|
18
|
+
is_target: int # bool
|
|
19
|
+
|
|
20
|
+
|
|
21
|
+
class Cred(CallbackData, prefix="cred"):
|
|
22
|
+
id: int
|
|
23
|
+
|
|
24
|
+
|
|
25
|
+
class Ex(CallbackData, prefix="ex"):
|
|
26
|
+
id: int
|
|
27
|
+
name: str
|
|
28
|
+
is_target: int # bool
|
|
29
|
+
|
|
30
|
+
|
|
31
|
+
class Pm(CallbackData, prefix="pm"):
|
|
32
|
+
pmcur_id: int
|
|
33
|
+
name: str
|
|
34
|
+
is_target: bool
|
|
35
|
+
|
|
36
|
+
|
|
37
|
+
class Ppo(CallbackData, prefix="ppo"):
|
|
38
|
+
num: int
|
|
39
|
+
|
|
40
|
+
|
|
41
|
+
class PayNav(CallbackData, prefix="pay_nav"):
|
|
42
|
+
to: PayStep
|
|
43
|
+
|
|
44
|
+
|
|
45
|
+
class Time(CallbackData, prefix="time"):
|
|
46
|
+
minutes: int # время в минутах
|
|
47
|
+
|
|
48
|
+
|
|
49
|
+
class Action(CallbackData, prefix="action"):
|
|
50
|
+
act: ActionType # "received" или "not_received"
|
|
@@ -0,0 +1,70 @@
|
|
|
1
|
+
from enum import IntEnum
|
|
2
|
+
|
|
3
|
+
from aiogram.fsm.state import StatesGroup, State
|
|
4
|
+
|
|
5
|
+
|
|
6
|
+
class Report(StatesGroup):
|
|
7
|
+
text = State()
|
|
8
|
+
|
|
9
|
+
|
|
10
|
+
class CredState(StatesGroup):
|
|
11
|
+
detail = State()
|
|
12
|
+
name = State()
|
|
13
|
+
|
|
14
|
+
|
|
15
|
+
class PaymentState(StatesGroup):
|
|
16
|
+
amount = State()
|
|
17
|
+
timer = State()
|
|
18
|
+
timer_active = State()
|
|
19
|
+
|
|
20
|
+
|
|
21
|
+
class ActionType(IntEnum):
|
|
22
|
+
"""Цель (назначение) платежа (target)"""
|
|
23
|
+
|
|
24
|
+
sent = 1 # Отправил
|
|
25
|
+
received = 2 # Получил
|
|
26
|
+
not_received = 3 # Не получил
|
|
27
|
+
|
|
28
|
+
|
|
29
|
+
class PayStep(IntEnum):
|
|
30
|
+
"""Цель (назначение) платежа (target)"""
|
|
31
|
+
|
|
32
|
+
t_type = 1 # Выбор типа
|
|
33
|
+
t_cur = 2 # Выбор валюты
|
|
34
|
+
t_coin = 3 # Выбор монеты
|
|
35
|
+
t_pm = 4 # Выбор платежки
|
|
36
|
+
t_ex = 5 # Выбор биржи
|
|
37
|
+
t_cred_dtl = 6 # Ввод номера карты
|
|
38
|
+
t_cred_name = 7 # Ввод имени
|
|
39
|
+
# t_addr = 8 # todo: позже добавим: Выбор/ввод крипто кошелька
|
|
40
|
+
t_amount = 9 # Ввод суммы
|
|
41
|
+
""" Источник платежа (source) """
|
|
42
|
+
s_type = 10 # Выбор типа
|
|
43
|
+
s_cur = 11 # Выбор типа
|
|
44
|
+
s_pm = 12 # Выбор типа
|
|
45
|
+
s_coin = 13 # Выбор типа
|
|
46
|
+
s_ex = 14 # Выбор типа
|
|
47
|
+
ppo = 15 # Выбор возможности разбивки платежа
|
|
48
|
+
urgency = 16 # Выбор срочности получения платежа
|
|
49
|
+
pending_send = 17 # Ожидание отправки (если мы платим фиатом)
|
|
50
|
+
pending_confirm = 18 # Ожидание пока на той стороне подтвердят получение нашего фиата (если мы платим фиатом)
|
|
51
|
+
pending_receive = 19 # Ожидание поступления (если мы получаем фиат)
|
|
52
|
+
|
|
53
|
+
|
|
54
|
+
flags = {
|
|
55
|
+
"RUB": "🇷🇺",
|
|
56
|
+
"THB": "🇹🇭",
|
|
57
|
+
"IDR": "🇮🇩",
|
|
58
|
+
"TRY": "🇹🇷",
|
|
59
|
+
"GEL": "🇬🇪",
|
|
60
|
+
"VND": "🇻🇳",
|
|
61
|
+
"AED": "🇦🇪",
|
|
62
|
+
"AMD": "🇦🇲",
|
|
63
|
+
"AZN": "🇦🇿",
|
|
64
|
+
"CNY": "🇨🇳",
|
|
65
|
+
"EUR": "🇪🇺",
|
|
66
|
+
"HKD": "🇭🇰",
|
|
67
|
+
"INR": "🇮🇳",
|
|
68
|
+
"PHP": "🇵🇭",
|
|
69
|
+
"USD": "🇺🇸",
|
|
70
|
+
}
|
|
@@ -0,0 +1,299 @@
|
|
|
1
|
+
from asyncio import create_task
|
|
2
|
+
from datetime import timedelta, datetime
|
|
3
|
+
from aiogram import Router, F
|
|
4
|
+
from aiogram.filters import Command
|
|
5
|
+
from aiogram.types import Message, CallbackQuery
|
|
6
|
+
from aiogram.fsm.context import FSMContext
|
|
7
|
+
from xync_schema import models
|
|
8
|
+
from aiogram.utils.keyboard import InlineKeyboardBuilder
|
|
9
|
+
from xync_bot.routers.pay import cd, dep, window
|
|
10
|
+
|
|
11
|
+
pay = Router()
|
|
12
|
+
|
|
13
|
+
|
|
14
|
+
@pay.message(Command("pay"))
|
|
15
|
+
async def h_start(msg: Message, state: FSMContext, **kwargs):
|
|
16
|
+
"""Step 1: Select target type"""
|
|
17
|
+
# await window.amount(msg, state)
|
|
18
|
+
await state.set_data({"is_target": True})
|
|
19
|
+
await window.type_select(msg, True)
|
|
20
|
+
|
|
21
|
+
|
|
22
|
+
@pay.callback_query(cd.TargetType.filter(F.is_fiat))
|
|
23
|
+
async def h_got_fiat_type(query: CallbackQuery, state: FSMContext):
|
|
24
|
+
"""Step 2f: Select cur"""
|
|
25
|
+
await query.message.delete()
|
|
26
|
+
await state.update_data(is_fiat=True)
|
|
27
|
+
await query.answer("Понял, фиат")
|
|
28
|
+
await window.cur_select(query.message, state)
|
|
29
|
+
|
|
30
|
+
|
|
31
|
+
@pay.callback_query(cd.TargetType.filter(F.is_fiat.__eq__(0)))
|
|
32
|
+
async def h_got_crypto_type(query: CallbackQuery, state: FSMContext):
|
|
33
|
+
"""Step 2c: Select coin"""
|
|
34
|
+
await query.message.delete()
|
|
35
|
+
await state.update_data(is_fiat=False)
|
|
36
|
+
await query.answer("Понял, крипта")
|
|
37
|
+
await window.coin_select(query.message, state)
|
|
38
|
+
|
|
39
|
+
|
|
40
|
+
@pay.callback_query(cd.Coin.filter())
|
|
41
|
+
async def h_got_coin(query: CallbackQuery, callback_data: cd.Coin, state: FSMContext):
|
|
42
|
+
"""Step 3c: Select target ex"""
|
|
43
|
+
await query.message.delete()
|
|
44
|
+
await state.update_data({("t" if await state.get_value("is_target") else "s") + "_coin_id": callback_data.id})
|
|
45
|
+
await query.answer("Эта монета есть на следующих биржах")
|
|
46
|
+
await window.ex_select(query.message, state)
|
|
47
|
+
|
|
48
|
+
|
|
49
|
+
@pay.callback_query(cd.Cur.filter())
|
|
50
|
+
async def h_got_cur(query: CallbackQuery, callback_data: cd.Cur, state: FSMContext):
|
|
51
|
+
"""Step 3f: Select target pm"""
|
|
52
|
+
await query.message.delete()
|
|
53
|
+
await state.update_data({("t" if await state.get_value("is_target") else "s") + "_cur_id": callback_data.id})
|
|
54
|
+
await query.answer("Вот платежные системы доступные для этой валюты")
|
|
55
|
+
await window.pm(query.message, state)
|
|
56
|
+
|
|
57
|
+
|
|
58
|
+
@pay.callback_query(cd.Pm.filter(F.is_target))
|
|
59
|
+
async def h_got_target_pm(query: CallbackQuery, callback_data: cd.Pm, state: FSMContext):
|
|
60
|
+
"""Step 4f: Fill target cred.detail"""
|
|
61
|
+
await query.message.delete()
|
|
62
|
+
await state.update_data(t_pmcur_id=callback_data.pmcur_id, t_name=callback_data.name)
|
|
63
|
+
await query.answer("Теперь нужны реквизиты")
|
|
64
|
+
await window.fill_cred_dtl(query.message, state)
|
|
65
|
+
|
|
66
|
+
|
|
67
|
+
@pay.callback_query(cd.Cred.filter())
|
|
68
|
+
async def h_got_cred(query: CallbackQuery, callback_data: cd.Cred, state: FSMContext):
|
|
69
|
+
await query.message.delete()
|
|
70
|
+
await state.update_data(cred_id=callback_data.id)
|
|
71
|
+
await query.answer("Теперь нужна сумма")
|
|
72
|
+
await window.amount(query.message, state)
|
|
73
|
+
|
|
74
|
+
|
|
75
|
+
@pay.message(dep.CredState.detail)
|
|
76
|
+
async def h_got_cred_dtl(msg: Message, state: FSMContext):
|
|
77
|
+
"""Step 4.1f: Fill target cred.name"""
|
|
78
|
+
while True:
|
|
79
|
+
if msg.text.isdigit():
|
|
80
|
+
await state.update_data(detail=int(msg.text))
|
|
81
|
+
break
|
|
82
|
+
else:
|
|
83
|
+
await msg.answer("Пожалуйста, введите корректное число")
|
|
84
|
+
return
|
|
85
|
+
await window.fill_cred_name(msg, state)
|
|
86
|
+
|
|
87
|
+
|
|
88
|
+
@pay.message(dep.CredState.name)
|
|
89
|
+
async def h_got_cred_name(msg: Message, state: FSMContext):
|
|
90
|
+
"""Step 5f: Save target cred"""
|
|
91
|
+
data = await state.get_data()
|
|
92
|
+
await state.set_state(None)
|
|
93
|
+
cred, _ = await models.Cred.update_or_create(
|
|
94
|
+
{"name": msg.text}, detail=data["detail"], person_id=data["person_id"], pmcur_id=data["t_pmcur_id"]
|
|
95
|
+
)
|
|
96
|
+
await state.update_data(cred_id=cred.id)
|
|
97
|
+
await window.amount(msg, state)
|
|
98
|
+
|
|
99
|
+
|
|
100
|
+
@pay.callback_query(cd.Ex.filter())
|
|
101
|
+
async def h_got_ex(query: CallbackQuery, callback_data: cd.Ex, state: FSMContext):
|
|
102
|
+
"""Step 4c: Save target"""
|
|
103
|
+
await query.message.delete()
|
|
104
|
+
if is_target := await state.get_value("is_target"):
|
|
105
|
+
await state.update_data(t_name=callback_data.name)
|
|
106
|
+
await state.update_data({("t" if is_target else "s") + "_ex_id": callback_data.id})
|
|
107
|
+
await query.answer(f"Биржа {callback_data.name} выбрана")
|
|
108
|
+
await (window.amount(query.message, state) if is_target else window.set_ppo(query.message))
|
|
109
|
+
|
|
110
|
+
|
|
111
|
+
@pay.message(dep.PaymentState.amount)
|
|
112
|
+
async def h_got_amount(msg: Message, state: FSMContext):
|
|
113
|
+
"""Step 6: Save target amount"""
|
|
114
|
+
while True:
|
|
115
|
+
if msg.text.isdigit():
|
|
116
|
+
await state.update_data(amount=int(msg.text))
|
|
117
|
+
break
|
|
118
|
+
else:
|
|
119
|
+
await msg.answer("Пожалуйста, введите корректное число")
|
|
120
|
+
return
|
|
121
|
+
await state.set_state(None)
|
|
122
|
+
"""Step 7: Select source type"""
|
|
123
|
+
await state.update_data(is_target=False)
|
|
124
|
+
if await state.get_value("is_fiat"):
|
|
125
|
+
await window.type_select(msg, False)
|
|
126
|
+
else:
|
|
127
|
+
await window.cur_select(msg, state) # сразу выбор валюты источника, тк если цель крипта
|
|
128
|
+
|
|
129
|
+
|
|
130
|
+
@pay.callback_query(cd.Pm.filter(F.is_target.__eq__(0)))
|
|
131
|
+
async def h_got_source_pm(query: CallbackQuery, callback_data: cd.Pm, state: FSMContext):
|
|
132
|
+
await query.message.delete()
|
|
133
|
+
await state.update_data(s_pmcur_id=callback_data.pmcur_id)
|
|
134
|
+
await query.answer(callback_data.name)
|
|
135
|
+
await window.set_ppo(query.message)
|
|
136
|
+
|
|
137
|
+
|
|
138
|
+
@pay.callback_query(cd.Ppo.filter())
|
|
139
|
+
async def h_got_ppo(query: CallbackQuery, state: FSMContext, callback_data: cd.Ppo):
|
|
140
|
+
await query.message.delete()
|
|
141
|
+
await state.update_data(ppo=callback_data.num)
|
|
142
|
+
await query.answer(str(callback_data.num))
|
|
143
|
+
await window.set_urgency(query.message)
|
|
144
|
+
|
|
145
|
+
|
|
146
|
+
@pay.callback_query(cd.Time.filter())
|
|
147
|
+
async def process_time_selection(callback: CallbackQuery, callback_data: cd.Time, state: FSMContext):
|
|
148
|
+
await callback.answer()
|
|
149
|
+
pay_until = datetime.now() + timedelta(minutes=callback_data.minutes)
|
|
150
|
+
|
|
151
|
+
data = await state.get_data()
|
|
152
|
+
if ex_id := data.get("t_ex_id", data.get("s_ex_id")):
|
|
153
|
+
if not (actor_id := data.get("actor_id")):
|
|
154
|
+
person_id = data.get("person_id")
|
|
155
|
+
actor_id = await models.Actor.get(ex_id=ex_id, person_id=person_id).values_list("id", flat=True)
|
|
156
|
+
await state.update_data(actor_id=actor_id)
|
|
157
|
+
if not (addr_id := data.get("addr_id")):
|
|
158
|
+
coin_id = data.get("t_coin_id", data.get("s_coin_id"))
|
|
159
|
+
addr_id = await models.Addr.get(coin_id=coin_id, actor_id=actor_id).values_list("id", flat=True)
|
|
160
|
+
await state.update_data(addr_id=addr_id)
|
|
161
|
+
else:
|
|
162
|
+
addr_id = None
|
|
163
|
+
|
|
164
|
+
pay_req = await models.PayReq.create(
|
|
165
|
+
pay_until=pay_until,
|
|
166
|
+
amount=data["amount"],
|
|
167
|
+
parts=data["ppo"],
|
|
168
|
+
payed_at=None,
|
|
169
|
+
addr_id=addr_id,
|
|
170
|
+
cred_id=data["cred_id"],
|
|
171
|
+
user_id=1,
|
|
172
|
+
)
|
|
173
|
+
await state.update_data(
|
|
174
|
+
timer=callback_data.minutes,
|
|
175
|
+
timer_active=True,
|
|
176
|
+
pay_until=pay_until,
|
|
177
|
+
pay_req_id=pay_req.id,
|
|
178
|
+
)
|
|
179
|
+
|
|
180
|
+
await state.set_state(dep.PaymentState.timer)
|
|
181
|
+
create_task(window.run_timer(callback.message, state))
|
|
182
|
+
|
|
183
|
+
|
|
184
|
+
# ACTIONS
|
|
185
|
+
@pay.callback_query(cd.Action.filter(F.act.__eq__(cd.ActionType.received)))
|
|
186
|
+
async def payment_confirmed(query: CallbackQuery, state: FSMContext):
|
|
187
|
+
await query.answer()
|
|
188
|
+
payed_at = datetime.now()
|
|
189
|
+
await state.update_data(timer_active=False, payed_at_formatted=payed_at)
|
|
190
|
+
data = await state.get_data()
|
|
191
|
+
if data.get("pay_req_id"):
|
|
192
|
+
pay_req = await models.PayReq.get(id=data["pay_req_id"])
|
|
193
|
+
pay_req.payed_at = payed_at
|
|
194
|
+
await pay_req.save()
|
|
195
|
+
|
|
196
|
+
builder = InlineKeyboardBuilder()
|
|
197
|
+
builder.button(text="Новый платеж💸", callback_data=cd.PayNav(to=cd.PayStep.t_type))
|
|
198
|
+
await query.message.answer("✅ Платеж успешно подтвержден", reply_markup=builder.as_markup())
|
|
199
|
+
await query.message.delete()
|
|
200
|
+
await state.clear()
|
|
201
|
+
|
|
202
|
+
|
|
203
|
+
@pay.callback_query(cd.Action.filter(F.act.__eq__(cd.ActionType.not_received)))
|
|
204
|
+
async def no_payment(query: CallbackQuery, state: FSMContext):
|
|
205
|
+
await query.answer()
|
|
206
|
+
await state.update_data(timer_active=False)
|
|
207
|
+
await query.message.edit_text("Платеж не получен!")
|
|
208
|
+
await query.message.answer("укажите детали платежа")
|
|
209
|
+
await state.clear()
|
|
210
|
+
await state.set_state(dep.Report.text)
|
|
211
|
+
|
|
212
|
+
|
|
213
|
+
@pay.message(dep.Report.text)
|
|
214
|
+
async def payment_not_specified(msg: Message, state: FSMContext):
|
|
215
|
+
await state.update_data(text=msg.text)
|
|
216
|
+
data = await state.get_data()
|
|
217
|
+
complaint_text = (
|
|
218
|
+
f"Жалоба на неполученный платеж:\n"
|
|
219
|
+
f"Пользователь: @{msg.from_user.username or msg.from_user.id}\n"
|
|
220
|
+
f"Детали платежа: {data["text"]}\n"
|
|
221
|
+
f"Время: {msg.date.strftime('%Y-%m-%d %H:%M:%S')}"
|
|
222
|
+
)
|
|
223
|
+
await msg.bot.send_message(chat_id="1779829771", text=complaint_text)
|
|
224
|
+
|
|
225
|
+
|
|
226
|
+
# NAVIGATION
|
|
227
|
+
@pay.callback_query(cd.PayNav.filter(F.to.in_([cd.PayStep.t_type, cd.PayStep.s_type])))
|
|
228
|
+
async def handle_home(query: CallbackQuery, state: FSMContext):
|
|
229
|
+
await query.message.delete()
|
|
230
|
+
await query.answer()
|
|
231
|
+
await window.type_select(query.message, await state.get_value("is_target"))
|
|
232
|
+
|
|
233
|
+
|
|
234
|
+
@pay.callback_query(cd.PayNav.filter(F.to.in_([cd.PayStep.t_coin, cd.PayStep.s_coin])))
|
|
235
|
+
async def to_coin_select(query: CallbackQuery, state: FSMContext):
|
|
236
|
+
await query.message.delete()
|
|
237
|
+
await query.answer()
|
|
238
|
+
is_target = await state.get_value("is_target")
|
|
239
|
+
pref = "t" if is_target else "s"
|
|
240
|
+
await state.update_data({pref + "_ex_id": None, pref + "_coin_id": None})
|
|
241
|
+
await window.coin_select(query.message, state)
|
|
242
|
+
|
|
243
|
+
|
|
244
|
+
@pay.callback_query(cd.PayNav.filter(F.to.in_([cd.PayStep.t_cur, cd.PayStep.s_cur])))
|
|
245
|
+
async def to_cur_select(query: CallbackQuery, state: FSMContext):
|
|
246
|
+
await query.message.delete()
|
|
247
|
+
await query.answer()
|
|
248
|
+
is_target = await state.get_value("is_target")
|
|
249
|
+
pref = "t" if is_target else "s"
|
|
250
|
+
await state.update_data({pref + "_pmcur_id": None, pref + "_cur_id": None})
|
|
251
|
+
await window.cur_select(query.message, state)
|
|
252
|
+
|
|
253
|
+
|
|
254
|
+
@pay.callback_query(cd.PayNav.filter(F.to.in_([cd.PayStep.t_pm, cd.PayStep.s_pm])))
|
|
255
|
+
async def to_pm_select(query: CallbackQuery, state: FSMContext):
|
|
256
|
+
await query.message.delete()
|
|
257
|
+
await query.answer()
|
|
258
|
+
await window.pm(query.message, state)
|
|
259
|
+
|
|
260
|
+
|
|
261
|
+
@pay.callback_query(cd.PayNav.filter(F.to.__eq__(cd.PayStep.t_cred_dtl)))
|
|
262
|
+
async def back_to_cred_detail(query: CallbackQuery, state: FSMContext):
|
|
263
|
+
await query.answer()
|
|
264
|
+
await state.update_data(detail=None)
|
|
265
|
+
await window.fill_cred_dtl(query.message, state)
|
|
266
|
+
await query.message.delete()
|
|
267
|
+
|
|
268
|
+
|
|
269
|
+
@pay.callback_query(cd.PayNav.filter(F.to.__eq__(cd.PayStep.t_cred_name)))
|
|
270
|
+
async def back_to_cred_name(query: CallbackQuery, state: FSMContext):
|
|
271
|
+
await query.message.delete()
|
|
272
|
+
await query.answer()
|
|
273
|
+
await state.update_data(name=None)
|
|
274
|
+
await window.fill_cred_name(query.message, state)
|
|
275
|
+
await query.message.delete()
|
|
276
|
+
|
|
277
|
+
|
|
278
|
+
@pay.callback_query(cd.PayNav.filter(F.to.in_([cd.PayStep.t_ex, cd.PayStep.s_ex])))
|
|
279
|
+
async def back_to_ex_select(query: CallbackQuery, state: FSMContext):
|
|
280
|
+
await query.message.delete()
|
|
281
|
+
await query.answer()
|
|
282
|
+
await state.update_data({("t" if await state.get_value("is_target") else "s") + "ex_id": None})
|
|
283
|
+
await window.ex_select(query.message, state)
|
|
284
|
+
|
|
285
|
+
|
|
286
|
+
@pay.callback_query(cd.PayNav.filter(F.to.__eq__(cd.PayStep.t_amount)))
|
|
287
|
+
async def back_to_amount(query: CallbackQuery, state: FSMContext):
|
|
288
|
+
await query.message.delete()
|
|
289
|
+
await query.answer()
|
|
290
|
+
await state.update_data(amount=None)
|
|
291
|
+
await window.amount(query.message, state)
|
|
292
|
+
|
|
293
|
+
|
|
294
|
+
@pay.callback_query(cd.PayNav.filter(F.to.in_([cd.PayStep.t_pm])))
|
|
295
|
+
async def back_to_payment(query: CallbackQuery, state: FSMContext):
|
|
296
|
+
await query.message.delete()
|
|
297
|
+
await query.answer()
|
|
298
|
+
await state.update_data(payment=None)
|
|
299
|
+
await window.pm(query.message, state)
|
|
@@ -0,0 +1,232 @@
|
|
|
1
|
+
from asyncio import sleep
|
|
2
|
+
|
|
3
|
+
from aiogram.fsm.context import FSMContext
|
|
4
|
+
from aiogram.types import Message, InlineKeyboardMarkup, InlineKeyboardButton
|
|
5
|
+
from aiogram.utils.keyboard import InlineKeyboardBuilder
|
|
6
|
+
from tortoise.functions import Max
|
|
7
|
+
from xync_schema import models
|
|
8
|
+
|
|
9
|
+
from xync_bot.routers.pay import cd, dep
|
|
10
|
+
|
|
11
|
+
|
|
12
|
+
async def type_select(msg: Message, is_target: bool):
|
|
13
|
+
"""Step 1: Select type"""
|
|
14
|
+
if is_target is False:
|
|
15
|
+
await msg.bot.delete_messages(chat_id=msg.chat.id, message_ids=[msg.message_id, msg.message_id - 1])
|
|
16
|
+
rm = InlineKeyboardMarkup(
|
|
17
|
+
inline_keyboard=[
|
|
18
|
+
[
|
|
19
|
+
InlineKeyboardButton(
|
|
20
|
+
text="Банковская валюта", callback_data=cd.TargetType(is_fiat=1, is_target=is_target).pack()
|
|
21
|
+
),
|
|
22
|
+
InlineKeyboardButton(text="Крипта", callback_data=cd.TargetType(is_fiat=0, is_target=is_target).pack()),
|
|
23
|
+
]
|
|
24
|
+
]
|
|
25
|
+
)
|
|
26
|
+
await msg.answer("Что нужно?" if is_target else "Чем платишь?", reply_markup=rm)
|
|
27
|
+
|
|
28
|
+
|
|
29
|
+
async def amount(msg: Message, state: FSMContext):
|
|
30
|
+
await msg.bot.delete_messages(chat_id=msg.chat.id, message_ids=[msg.message_id, msg.message_id - 1])
|
|
31
|
+
"""Step 5: Filling target amount"""
|
|
32
|
+
builder = InlineKeyboardBuilder()
|
|
33
|
+
|
|
34
|
+
if await state.get_value("is_fiat"):
|
|
35
|
+
cur_coin = (await state.get_value("curs"))[await state.get_value("t_cur_id")]
|
|
36
|
+
builder.button(text="Назад к вводу имени", callback_data=cd.PayNav(to=cd.PayStep.t_cred_name))
|
|
37
|
+
else:
|
|
38
|
+
cur_coin = (await state.get_value("coins"))[await state.get_value("t_coin_id")]
|
|
39
|
+
builder.button(text="Назад к выбору биржи", callback_data=cd.PayNav(to=cd.PayStep.t_ex))
|
|
40
|
+
|
|
41
|
+
builder.button(text="Домой", callback_data=cd.PayNav(to=cd.PayStep.t_type))
|
|
42
|
+
builder.adjust(2)
|
|
43
|
+
|
|
44
|
+
await msg.answer(
|
|
45
|
+
f"Введите нужную сумму {cur_coin} для {await state.get_value('t_name')}", reply_markup=builder.as_markup()
|
|
46
|
+
)
|
|
47
|
+
await state.set_state(dep.PaymentState.amount)
|
|
48
|
+
|
|
49
|
+
|
|
50
|
+
async def cur_select(msg: Message, state: FSMContext):
|
|
51
|
+
"""Common using cur func"""
|
|
52
|
+
if not (curs := await state.get_value("curs")):
|
|
53
|
+
await state.update_data(curs=curs)
|
|
54
|
+
builder = InlineKeyboardBuilder()
|
|
55
|
+
is_target = await state.get_value("is_target")
|
|
56
|
+
for cur_id, ticker in curs.items():
|
|
57
|
+
builder.button(text=ticker + dep.flags[ticker], callback_data=cd.Cur(id=cur_id, is_target=is_target))
|
|
58
|
+
builder.button(text="Назад к выбору типа", callback_data=cd.PayNav(to=cd.PayStep.t_type))
|
|
59
|
+
builder.adjust(3, 3, 3, 3, 3, 1)
|
|
60
|
+
sfx = "ую нужно" if is_target else "ой платишь"
|
|
61
|
+
await msg.answer("Выбери валюту котор" + sfx, reply_markup=builder.as_markup())
|
|
62
|
+
|
|
63
|
+
|
|
64
|
+
async def coin_select(msg: Message, state: FSMContext):
|
|
65
|
+
"""Common using coin func"""
|
|
66
|
+
builder = InlineKeyboardBuilder()
|
|
67
|
+
if not (coins := await state.get_value("coins")):
|
|
68
|
+
coins = {k: v for k, v in await models.Coin.all().values_list("id", "ticker")}
|
|
69
|
+
await state.update_data(coins=coins)
|
|
70
|
+
is_target = await state.get_value("is_target")
|
|
71
|
+
for coin_id, ticker in coins.items():
|
|
72
|
+
builder.button(text=ticker, callback_data=cd.Coin(id=coin_id, is_target=is_target))
|
|
73
|
+
builder.button(
|
|
74
|
+
text="Назад к выбору типа", callback_data=cd.PayNav(to=cd.PayStep.t_type if is_target else cd.PayStep.s_type)
|
|
75
|
+
)
|
|
76
|
+
builder.adjust(1)
|
|
77
|
+
sfx = "ую нужно" if is_target else "ой платишь"
|
|
78
|
+
await msg.answer("Выберите монету котор" + sfx, reply_markup=builder.as_markup())
|
|
79
|
+
|
|
80
|
+
|
|
81
|
+
async def ex_select(msg: Message, state: FSMContext):
|
|
82
|
+
data = await state.get_data()
|
|
83
|
+
is_target = data["is_target"]
|
|
84
|
+
coin_id = data[("t" if is_target else "s") + "_coin_id"]
|
|
85
|
+
if not (exs := data.get("exs", {}).get(coin_id)):
|
|
86
|
+
await state.update_data({"exs": {coin_id: exs}})
|
|
87
|
+
builder = InlineKeyboardBuilder()
|
|
88
|
+
for eid, name in exs:
|
|
89
|
+
builder.button(text=name, callback_data=cd.Ex(id=eid, name=name, is_target=is_target))
|
|
90
|
+
builder.button(
|
|
91
|
+
text="Назад к выбору монеты", callback_data=cd.PayNav(to=cd.PayStep.t_coin if is_target else cd.PayStep.s_coin)
|
|
92
|
+
)
|
|
93
|
+
builder.button(text="Домой", callback_data=cd.PayNav(to=cd.PayStep.t_type))
|
|
94
|
+
builder.adjust(1)
|
|
95
|
+
keyboard = builder.as_markup()
|
|
96
|
+
await msg.answer("На какую биржу?" if is_target else "С какой биржи?", reply_markup=keyboard)
|
|
97
|
+
|
|
98
|
+
|
|
99
|
+
async def pm(msg: Message, state: FSMContext):
|
|
100
|
+
data = await state.get_data()
|
|
101
|
+
is_target = data["is_target"]
|
|
102
|
+
cur_id = data[("t" if is_target else "s") + "_cur_id"]
|
|
103
|
+
if not (pms := data.get("pms", {}).get(cur_id)):
|
|
104
|
+
pms = await (
|
|
105
|
+
models.Pmex.filter(pm__pmcurs__cur_id=cur_id)
|
|
106
|
+
.annotate(lname=Max("name"))
|
|
107
|
+
.group_by("pm__pmcurs__id")
|
|
108
|
+
.values_list("pm__pmcurs__id", "lname")
|
|
109
|
+
)
|
|
110
|
+
await state.update_data({"pms": {cur_id: pms}})
|
|
111
|
+
builder = InlineKeyboardBuilder()
|
|
112
|
+
for pmcur_id, name in pms:
|
|
113
|
+
builder.button(text=name, callback_data=cd.Pm(pmcur_id=pmcur_id, name=name[:50], is_target=is_target))
|
|
114
|
+
builder.button(
|
|
115
|
+
text="Назад к выбору валюты", callback_data=cd.PayNav(to=cd.PayStep.t_cur if is_target else cd.PayStep.s_cur)
|
|
116
|
+
)
|
|
117
|
+
builder.button(text="Домой", callback_data=cd.PayNav(to=cd.PayStep.t_type))
|
|
118
|
+
builder.adjust(1)
|
|
119
|
+
keyboard = builder.as_markup()
|
|
120
|
+
txt = "На какую платежную систему?" if is_target else "C какой платежной системы?"
|
|
121
|
+
await msg.answer(txt, reply_markup=keyboard)
|
|
122
|
+
|
|
123
|
+
|
|
124
|
+
async def fill_cred_dtl(msg: Message, state: FSMContext):
|
|
125
|
+
builder = InlineKeyboardBuilder()
|
|
126
|
+
data = await state.get_data()
|
|
127
|
+
if not (person_id := data.get("person_id")):
|
|
128
|
+
person_id = await models.User.get(username_id=193017646).values_list("person_id", flat=True)
|
|
129
|
+
await state.update_data(person_id=person_id)
|
|
130
|
+
pmcur_id = data["t_pmcur_id"]
|
|
131
|
+
if not (creds := data.get("creds", {}).get(pmcur_id)):
|
|
132
|
+
creds = await models.Cred.filter(person_id=person_id, pmcur_id=pmcur_id)
|
|
133
|
+
await state.update_data({"creds": {pmcur_id: creds}})
|
|
134
|
+
for cred in creds:
|
|
135
|
+
txt = f"{cred.detail}\n{cred.name}"
|
|
136
|
+
if cred.extra:
|
|
137
|
+
txt += f" ({cred.extra})"
|
|
138
|
+
builder.button(text=txt, callback_data=cd.Cred(id=cred.id))
|
|
139
|
+
|
|
140
|
+
builder.button(text="Назад к выбору платежной системы", callback_data=cd.PayNav(to=cd.PayStep.t_pm))
|
|
141
|
+
builder.button(text="Домой", callback_data=cd.PayNav(to=cd.PayStep.t_type))
|
|
142
|
+
builder.adjust(2)
|
|
143
|
+
txt = "Выберите реквизиты куда нужно получить деньги, если в списке нет нужных, то\n"
|
|
144
|
+
await msg.answer(f"{txt}Введите номер для {await state.get_value('t_name')}:", reply_markup=builder.as_markup())
|
|
145
|
+
await state.set_state(dep.CredState.detail)
|
|
146
|
+
|
|
147
|
+
|
|
148
|
+
async def fill_cred_name(msg: Message, state: FSMContext):
|
|
149
|
+
await msg.bot.delete_messages(chat_id=msg.chat.id, message_ids=[msg.message_id, msg.message_id - 1])
|
|
150
|
+
await state.update_data(detail=msg.text)
|
|
151
|
+
builder = InlineKeyboardBuilder()
|
|
152
|
+
builder.button(text="Назад к вводу реквизитов", callback_data=cd.PayNav(to=cd.PayStep.t_cred_dtl))
|
|
153
|
+
builder.button(text="Домой", callback_data=cd.PayNav(to=cd.PayStep.t_type))
|
|
154
|
+
builder.adjust(2)
|
|
155
|
+
data = await state.get_data()
|
|
156
|
+
cur = data["curs"].get(data["t_cur_id"])
|
|
157
|
+
payment = data["t_name"]
|
|
158
|
+
detail = data["detail"]
|
|
159
|
+
await msg.answer(f"{cur}:{payment}:{detail}: Введите имя получателя", reply_markup=builder.as_markup())
|
|
160
|
+
await state.set_state(dep.CredState.name)
|
|
161
|
+
|
|
162
|
+
|
|
163
|
+
async def set_ppo(msg: Message):
|
|
164
|
+
rm = InlineKeyboardMarkup(
|
|
165
|
+
inline_keyboard=[
|
|
166
|
+
[
|
|
167
|
+
InlineKeyboardButton(text="Нет", callback_data="ppo:1"),
|
|
168
|
+
InlineKeyboardButton(text="Да", callback_data="ppo:2"),
|
|
169
|
+
],
|
|
170
|
+
[InlineKeyboardButton(text="Да хоть на 3", callback_data="ppo:3")],
|
|
171
|
+
]
|
|
172
|
+
)
|
|
173
|
+
await msg.answer("На 2 платежа сможем разбить?", reply_markup=rm)
|
|
174
|
+
|
|
175
|
+
|
|
176
|
+
async def set_urgency(msg: Message):
|
|
177
|
+
builder = InlineKeyboardBuilder()
|
|
178
|
+
builder.button(text="1 мин", callback_data=cd.Time(minutes=1))
|
|
179
|
+
builder.button(text="5 мин", callback_data=cd.Time(minutes=5))
|
|
180
|
+
builder.button(text="30 мин", callback_data=cd.Time(minutes=30))
|
|
181
|
+
builder.button(text="3 часа", callback_data=cd.Time(minutes=180))
|
|
182
|
+
builder.button(text="сутки", callback_data=cd.Time(minutes=60 * 24))
|
|
183
|
+
builder.button(text="Назад к вводу платежей", callback_data=cd.PayNav(to=cd.PayStep.t_pm))
|
|
184
|
+
builder.button(text="Домой", callback_data=cd.PayNav(to=cd.PayStep.t_type))
|
|
185
|
+
builder.adjust(2, 2, 1, 1, 1)
|
|
186
|
+
await msg.answer("Сколько можешь ждать?", reply_markup=builder.as_markup())
|
|
187
|
+
|
|
188
|
+
|
|
189
|
+
async def run_timer(message, state: FSMContext):
|
|
190
|
+
builder = InlineKeyboardBuilder()
|
|
191
|
+
builder.button(text="Платеж получен", callback_data=cd.Action(act=cd.ActionType.received))
|
|
192
|
+
|
|
193
|
+
data = await state.get_value("timer")
|
|
194
|
+
seconds = data * 60
|
|
195
|
+
|
|
196
|
+
def format(sec):
|
|
197
|
+
days = sec // (24 * 3600)
|
|
198
|
+
sec %= 24 * 3600
|
|
199
|
+
hours = sec // 3600
|
|
200
|
+
sec %= 3600
|
|
201
|
+
minutes = sec // 60
|
|
202
|
+
sec %= 60
|
|
203
|
+
|
|
204
|
+
if days > 0:
|
|
205
|
+
return f"{days}д {hours:02d}:{minutes:02d}:{sec:02d}"
|
|
206
|
+
elif hours > 0:
|
|
207
|
+
return f"{hours:02d}:{minutes:02d}:{sec:02d}"
|
|
208
|
+
else:
|
|
209
|
+
return f"{minutes:02d}:{sec:02d}"
|
|
210
|
+
|
|
211
|
+
try:
|
|
212
|
+
await message.edit_text(f"⏳ Осталось {format(seconds)}", reply_markup=builder.as_markup())
|
|
213
|
+
except Exception:
|
|
214
|
+
return
|
|
215
|
+
|
|
216
|
+
while seconds > 0:
|
|
217
|
+
await sleep(1)
|
|
218
|
+
seconds -= 1
|
|
219
|
+
try:
|
|
220
|
+
await message.edit_text(f"⏳ Осталось {format(seconds)}", reply_markup=builder.as_markup())
|
|
221
|
+
await state.update_data(timer=seconds)
|
|
222
|
+
except Exception:
|
|
223
|
+
break
|
|
224
|
+
|
|
225
|
+
if seconds <= 0:
|
|
226
|
+
builder = InlineKeyboardBuilder()
|
|
227
|
+
builder.button(text="Платеж получен", callback_data=cd.Action(act=cd.ActionType.received))
|
|
228
|
+
builder.button(text="Денег нет", callback_data=cd.Action(act=cd.ActionType.not_received))
|
|
229
|
+
try:
|
|
230
|
+
await message.edit_text("⏳ Время вышло!", reply_markup=builder.as_markup())
|
|
231
|
+
except Exception:
|
|
232
|
+
pass
|
|
@@ -0,0 +1,20 @@
|
|
|
1
|
+
xync_bot/__init__.py,sha256=0m9zUYZUJHEJUMb24CU10wYfCIAg8eourNFlBLsHgWU,705
|
|
2
|
+
xync_bot/loader.py,sha256=4ZeR-yVMoOmswdLS0UEBG19K7JVcuvH6WpP-_0yAK3I,573
|
|
3
|
+
xync_bot/shared.py,sha256=MlKkTrsT29l7fF6-qAN9FO14cSuXuOuYxbNY5F4S2w4,137
|
|
4
|
+
xync_bot/typs.py,sha256=47DEQpj8HBSa-_TImW-5JCeuQeRkm5NMpJWZG3hSuFU,0
|
|
5
|
+
xync_bot/routers/__init__.py,sha256=mX0m3U_l0AHq9xmyN98RLZ9qc6s3BTumeKTpUR0bmKY,2126
|
|
6
|
+
xync_bot/routers/main.py,sha256=FumWa48ORhV77Df6NbEosHfgmFIe_Y2ci6IkJCvU4Zs,9535
|
|
7
|
+
xync_bot/routers/order.py,sha256=ZKWDLyiWrXzcR-aHKLBTBCACwp-P0Vvnr22T-EuLHaM,274
|
|
8
|
+
xync_bot/routers/photo.py,sha256=aq6ImIOoZQYTW-lEy26qjgj5TYAuk4bQjgiCv64mPJs,1203
|
|
9
|
+
xync_bot/routers/vpn.py,sha256=qKK55UrjEZeDvu7ljWXNUFBFgXTPTIEaCT2OAmKWky4,2219
|
|
10
|
+
xync_bot/routers/xicon.png,sha256=O57_kvzhVcCXSoGYZ61m0dW9pizY6gxR8Yj5aeCP0RQ,429283
|
|
11
|
+
xync_bot/routers/cond/__init__.py,sha256=It4djVO8AxXL1I76buRz8yYF12dsjXaa4WNtPdb7CFc,4333
|
|
12
|
+
xync_bot/routers/cond/func.py,sha256=m0NWDKunbqDJQmhv_5UnpjxjRzn78GFG94ThOFLVlQo,4720
|
|
13
|
+
xync_bot/routers/pay/cd.py,sha256=3rHgdaT4VdnxEdqhc1fbptoI1vSws-e2B6ZLUJnwYw0,929
|
|
14
|
+
xync_bot/routers/pay/dep.py,sha256=QoOhmqKj8QesiIT6QqEomR2xu83cg9Z8mh6oquJKZnM,2208
|
|
15
|
+
xync_bot/routers/pay/handler.py,sha256=wJI-SCg7e8GrMJs1YtOhoa0-5zR05HiCfdpcBqqc0zo,11961
|
|
16
|
+
xync_bot/routers/pay/window.py,sha256=3JIITGEJN74UESKF5AdWYVGALgoCUxojlvYf5V_kPVs,10641
|
|
17
|
+
xync_bot-0.3.24.dev3.dist-info/METADATA,sha256=h63aQRapKWhCRnjbMjSc3c5Gmol0K6innCm4P-XJRaY,751
|
|
18
|
+
xync_bot-0.3.24.dev3.dist-info/WHEEL,sha256=_zCd3N1l69ArxyTb8rzEoP9TpbYXkqRFSNOD5OuxnTs,91
|
|
19
|
+
xync_bot-0.3.24.dev3.dist-info/top_level.txt,sha256=O2IjMc1ryAf0rwIXWohSNT5Kzcs9johgKRDz8lCC0rs,9
|
|
20
|
+
xync_bot-0.3.24.dev3.dist-info/RECORD,,
|
xync_bot/routers/pay/main.py
DELETED
|
@@ -1,133 +0,0 @@
|
|
|
1
|
-
from aiogram import Router, F
|
|
2
|
-
from aiogram.filters import Command
|
|
3
|
-
from aiogram.types import Message
|
|
4
|
-
from xync_schema import models
|
|
5
|
-
from aiogram.types import ReplyKeyboardMarkup, KeyboardButton
|
|
6
|
-
from aiogram.utils.keyboard import InlineKeyboardMarkup, InlineKeyboardButton
|
|
7
|
-
from aiogram import types
|
|
8
|
-
|
|
9
|
-
from aiogram.fsm.state import State, StatesGroup
|
|
10
|
-
from aiogram.fsm.context import FSMContext
|
|
11
|
-
|
|
12
|
-
pay = Router()
|
|
13
|
-
|
|
14
|
-
|
|
15
|
-
class Cred(StatesGroup):
|
|
16
|
-
detail = State()
|
|
17
|
-
extra = State()
|
|
18
|
-
|
|
19
|
-
|
|
20
|
-
class Addr(StatesGroup):
|
|
21
|
-
name = State()
|
|
22
|
-
|
|
23
|
-
|
|
24
|
-
@pay.message(Command("pay"))
|
|
25
|
-
async def main(msg: Message):
|
|
26
|
-
start = ReplyKeyboardMarkup(
|
|
27
|
-
keyboard=[[KeyboardButton(text="крипта"), KeyboardButton(text="валюта (фиат)")]], resize_keyboard=True
|
|
28
|
-
)
|
|
29
|
-
await msg.answer("что нужно?", reply_markup=start)
|
|
30
|
-
|
|
31
|
-
|
|
32
|
-
@pay.message(F.text == "валюта (фиат)")
|
|
33
|
-
async def cur(msg: types.Message):
|
|
34
|
-
currencies = await models.Cur.all()
|
|
35
|
-
buttons = [[InlineKeyboardButton(text=cur.ticker, callback_data=f"cur_{cur.id}")] for cur in currencies]
|
|
36
|
-
keyboard = InlineKeyboardMarkup(inline_keyboard=buttons)
|
|
37
|
-
await msg.answer("Выберите валюту:", reply_markup=keyboard)
|
|
38
|
-
|
|
39
|
-
|
|
40
|
-
@pay.message(F.text == "крипта")
|
|
41
|
-
async def coin(msg: types.Message):
|
|
42
|
-
crypt = await models.Coin.all()
|
|
43
|
-
buttons = [[InlineKeyboardButton(text=coin.ticker, callback_data=f"coin_{coin.id}")] for coin in crypt]
|
|
44
|
-
keyboard = InlineKeyboardMarkup(inline_keyboard=buttons)
|
|
45
|
-
await msg.answer("Выберите крипту:", reply_markup=keyboard)
|
|
46
|
-
|
|
47
|
-
|
|
48
|
-
@pay.callback_query(F.data.startswith("coin_"))
|
|
49
|
-
async def coinex(query: types.CallbackQuery):
|
|
50
|
-
ticker = query.data.replace("coin_", "")
|
|
51
|
-
ex_id = await models.Coinex.filter(coin_id=ticker).values_list("ex_id", flat=True)
|
|
52
|
-
ex = await models.Ex.filter(id__in=ex_id).values_list("name", flat=True)
|
|
53
|
-
if not ex:
|
|
54
|
-
await query.message.answer("Такой биржи нет")
|
|
55
|
-
else:
|
|
56
|
-
buttons = [[InlineKeyboardButton(text=i, callback_data=f"ad_{i}")] for i in ex]
|
|
57
|
-
keyboard = InlineKeyboardMarkup(inline_keyboard=buttons)
|
|
58
|
-
await query.message.answer("Выберите биржу", reply_markup=keyboard)
|
|
59
|
-
|
|
60
|
-
|
|
61
|
-
@pay.callback_query(F.data.startswith("cur_"))
|
|
62
|
-
async def pm(query: types.CallbackQuery, state: FSMContext):
|
|
63
|
-
ticker = query.data.replace("cur_", "")
|
|
64
|
-
pmcur = await models.Pmcur.filter(cur_id=ticker).values_list("pm_id", flat=True)
|
|
65
|
-
pmex = await models.Pmex.filter(pm_id__in=pmcur).values_list("id", flat=True)
|
|
66
|
-
pm = await models.PmexBank.filter(pmex_id__in=pmex).values_list("name", flat=True)
|
|
67
|
-
if not pm:
|
|
68
|
-
await query.message.answer("Такой платежки нет")
|
|
69
|
-
else:
|
|
70
|
-
buttons = [[InlineKeyboardButton(text=i, callback_data=f"pm_{i}")] for i in pm]
|
|
71
|
-
keyboard = InlineKeyboardMarkup(inline_keyboard=buttons)
|
|
72
|
-
await query.message.answer("Выберите платежку", reply_markup=keyboard)
|
|
73
|
-
|
|
74
|
-
|
|
75
|
-
# 4) для cur
|
|
76
|
-
@pay.callback_query(F.data.startswith("pm_"))
|
|
77
|
-
async def cred(query: types.CallbackQuery, state: FSMContext):
|
|
78
|
-
name = query.data.replace("pm_", "")
|
|
79
|
-
await state.update_data(name=name)
|
|
80
|
-
pmex_id = await models.PmexBank.filter(name=name).values_list("pmex_id", flat=True)
|
|
81
|
-
pm_id = await models.Pmex.filter(id__in=pmex_id).values_list("pm_id", flat=True)
|
|
82
|
-
pmcur = await models.Pmcur.get(id__in=pm_id)
|
|
83
|
-
await state.update_data(pmcur_id=pmcur.id)
|
|
84
|
-
await query.message.answer("Введите реквизиты")
|
|
85
|
-
await state.set_state(Cred.detail)
|
|
86
|
-
|
|
87
|
-
|
|
88
|
-
@pay.message(Cred.detail)
|
|
89
|
-
async def cred_detail(msg: types.Message, state: FSMContext):
|
|
90
|
-
user_id = msg.from_user.id
|
|
91
|
-
# user_id = 193017646
|
|
92
|
-
person_id = await models.User.get(username_id=user_id)
|
|
93
|
-
await state.update_data(person_id=person_id.person_id)
|
|
94
|
-
await state.update_data(detail=msg.text)
|
|
95
|
-
await msg.answer("Введите доп информацию")
|
|
96
|
-
await state.set_state(Cred.extra)
|
|
97
|
-
|
|
98
|
-
|
|
99
|
-
@pay.message(Cred.extra)
|
|
100
|
-
async def create_cred(msg: types.Message, state: FSMContext):
|
|
101
|
-
await state.update_data(extra=msg.text)
|
|
102
|
-
data = await state.get_data()
|
|
103
|
-
await state.clear()
|
|
104
|
-
# print(data)
|
|
105
|
-
data_create = {
|
|
106
|
-
"detail": data["detail"],
|
|
107
|
-
"name": data["name"],
|
|
108
|
-
"extra": data["extra"],
|
|
109
|
-
"person_id": data["person_id"],
|
|
110
|
-
"pmcur_id": data["pmcur_id"],
|
|
111
|
-
}
|
|
112
|
-
await models.Cred.create(**data_create)
|
|
113
|
-
|
|
114
|
-
|
|
115
|
-
# 4) для coin
|
|
116
|
-
@pay.callback_query(F.data.startswith("ad_"))
|
|
117
|
-
async def addr(query: types.CallbackQuery, state: FSMContext):
|
|
118
|
-
name = query.data.replace("ad_", "")
|
|
119
|
-
ex = await models.Ex.filter(name=name).values_list("id", flat=True)
|
|
120
|
-
await state.update_data(ex_id=ex)
|
|
121
|
-
await query.message.answer("Введите имя")
|
|
122
|
-
await state.set_state(Addr.name)
|
|
123
|
-
|
|
124
|
-
|
|
125
|
-
@pay.message(Addr.name)
|
|
126
|
-
async def addr_name(msg: types.Message, state: FSMContext):
|
|
127
|
-
# user_id = msg.from_user.id
|
|
128
|
-
user_id = 193017646
|
|
129
|
-
person_id = await models.User.get(username_id=user_id)
|
|
130
|
-
await state.update_data(person_id=person_id.person_id)
|
|
131
|
-
await state.update_data(name=msg.text)
|
|
132
|
-
await state.get_data()
|
|
133
|
-
await state.clear()
|
|
@@ -1,17 +0,0 @@
|
|
|
1
|
-
xync_bot/__init__.py,sha256=wiZpB8Bv4jjaHeGS_yt9HKtuLTHwx4nCsCgcrMesCFE,586
|
|
2
|
-
xync_bot/loader.py,sha256=wnhRRMJ6KSFAFZnDBGg9mbbktq34VHtcNSt89WuPn04,558
|
|
3
|
-
xync_bot/shared.py,sha256=MlKkTrsT29l7fF6-qAN9FO14cSuXuOuYxbNY5F4S2w4,137
|
|
4
|
-
xync_bot/typs.py,sha256=47DEQpj8HBSa-_TImW-5JCeuQeRkm5NMpJWZG3hSuFU,0
|
|
5
|
-
xync_bot/routers/__init__.py,sha256=47DEQpj8HBSa-_TImW-5JCeuQeRkm5NMpJWZG3hSuFU,0
|
|
6
|
-
xync_bot/routers/main.py,sha256=FumWa48ORhV77Df6NbEosHfgmFIe_Y2ci6IkJCvU4Zs,9535
|
|
7
|
-
xync_bot/routers/order.py,sha256=ZKWDLyiWrXzcR-aHKLBTBCACwp-P0Vvnr22T-EuLHaM,274
|
|
8
|
-
xync_bot/routers/photo.py,sha256=aq6ImIOoZQYTW-lEy26qjgj5TYAuk4bQjgiCv64mPJs,1203
|
|
9
|
-
xync_bot/routers/vpn.py,sha256=qKK55UrjEZeDvu7ljWXNUFBFgXTPTIEaCT2OAmKWky4,2219
|
|
10
|
-
xync_bot/routers/xicon.png,sha256=O57_kvzhVcCXSoGYZ61m0dW9pizY6gxR8Yj5aeCP0RQ,429283
|
|
11
|
-
xync_bot/routers/cond/__init__.py,sha256=It4djVO8AxXL1I76buRz8yYF12dsjXaa4WNtPdb7CFc,4333
|
|
12
|
-
xync_bot/routers/cond/func.py,sha256=m0NWDKunbqDJQmhv_5UnpjxjRzn78GFG94ThOFLVlQo,4720
|
|
13
|
-
xync_bot/routers/pay/main.py,sha256=5swOvvKF2XA2UAwHewdidMoMONV4acTwR0mPyzA0ezA,5116
|
|
14
|
-
xync_bot-0.3.7.dev4.dist-info/METADATA,sha256=4T0s0NFTh9QNuQ3JpSLKarYsXY-OZjN0vTjGrkNbeQI,750
|
|
15
|
-
xync_bot-0.3.7.dev4.dist-info/WHEEL,sha256=_zCd3N1l69ArxyTb8rzEoP9TpbYXkqRFSNOD5OuxnTs,91
|
|
16
|
-
xync_bot-0.3.7.dev4.dist-info/top_level.txt,sha256=O2IjMc1ryAf0rwIXWohSNT5Kzcs9johgKRDz8lCC0rs,9
|
|
17
|
-
xync_bot-0.3.7.dev4.dist-info/RECORD,,
|
|
File without changes
|
|
File without changes
|