11import asyncio
22import json
3+ from secrets import token_hex
34
45from aiogram import Router , F
56from aiogram .types import CallbackQuery , Message , BufferedInputFile
67from aiogram .filters import StateFilter
78from aiogram .fsm .state import State , StatesGroup
89from aiogram .fsm .context import FSMContext
910
10- from app .keys import BotKeys , PageCB , Pages , Actions , SelectCB , SelectAll , JsonHandler
11+ from app .keys import (
12+ BotKeys ,
13+ PageCB ,
14+ Pages ,
15+ Actions ,
16+ SelectCB ,
17+ SelectAll ,
18+ JsonHandler ,
19+ RandomHandler ,
20+ )
1121from app .db import crud
1222from app .settings .language import MessageTexts
1323from app .api import ClinetManager
@@ -75,10 +85,14 @@ async def adminselect(
7585 return await callback .message .edit_text (
7686 text = MessageTexts .ASK_REMARK ,
7787 reply_markup = BotKeys .selector (
78- data = [(MessageTexts .CREATE_WITH_JSON , JsonHandler .USER )],
88+ data = [
89+ (MessageTexts .RANDOM_USERNAME , RandomHandler .USERNAME ),
90+ (MessageTexts .CREATE_WITH_JSON , JsonHandler .USER ),
91+ ],
7992 types = Pages .USERS ,
8093 action = Actions .JSON ,
8194 panel = callback_data .panel ,
95+ width = 1 ,
8296 ),
8397 )
8498
@@ -90,9 +104,15 @@ async def adminselect(
90104async def json_start (
91105 callback : CallbackQuery , callback_data : SelectCB , state : FSMContext
92106):
93- await state .set_state (UserCreateForm .JSON )
107+ if callback_data .select == JsonHandler .USER :
108+ await state .set_state (UserCreateForm .JSON )
109+ text = MessageTexts .ASK_JSON
110+ else :
111+ await state .update_data (username = str (token_hex (3 )))
112+ await state .set_state (UserCreateForm .USERCOUNT )
113+ text = MessageTexts .ASK_COUNT
94114 return await callback .message .edit_text (
95- text = MessageTexts . ASK_JSON ,
115+ text = text ,
96116 reply_markup = BotKeys .cancel (),
97117 )
98118
0 commit comments