diff --git a/bot.py b/bot.py index 809a9e3..08074bf 100644 --- a/bot.py +++ b/bot.py @@ -61,7 +61,6 @@ OK_APPLICATION_KEY = os.getenv('OK_APPLICATION_KEY') OK_APPLICATION_SECRET_KEY = os.getenv('OK_APPLICATION_SECRET_KEY') OK_GROUP_ID = os.getenv('OK_GROUP_ID') ARRAY_INLINE = [] -# TODO: change usernames in message_handlers to id ALLOWED_USERS = json.loads(os.environ['ALLOWED_USERS']) bot = Bot(token=API_BOT_TOKEN) @@ -69,7 +68,7 @@ storage = MemoryStorage() dp = Dispatcher(bot, storage=storage) # /create_post_vk -@dp.message_handler(commands=['create_post_vk']) +@dp.message_handler(lambda message: message.from_user.id, commands=['create_post_vk']) async def create_post_vk(message: types.Message) -> None: result = subprocess.run( ['C:\OSPanel\modules\php\PHP_7.3\php.exe', "C:/OSPanel/domains/localhost/vk/create_post.php"], stdout=subprocess.PIPE, stderr=subprocess.PIPE @@ -593,8 +592,8 @@ async def show_thumbs(chat_id, res): # start или help @dp.callback_query_handler(text="help") -@dp.message_handler(lambda message: message.from_user.username in ALLOWED_USERS, commands=["help"]) -@dp.message_handler(lambda message: message.from_user.username in ALLOWED_USERS, commands=["start"]) +@dp.message_handler(lambda message: message.from_user.id in ALLOWED_USERS, commands=["help"]) +@dp.message_handler(lambda message: message.from_user.id in ALLOWED_USERS, commands=["start"]) async def cmd_start(message: Union[types.Message, types.CallbackQuery]) -> None: logging.info("cmd_start") txt = "Это бот для локального запуска SD\n" + getTxt() @@ -602,7 +601,7 @@ async def cmd_start(message: Union[types.Message, types.CallbackQuery]) -> None: # TODO optimize # Запуск/Остановка SD. Завязываемся на глобальную иконку sd -@dp.message_handler(lambda message: message.from_user.username in ALLOWED_USERS, commands=["stop"]) +@dp.message_handler(lambda message: message.from_user.id in ALLOWED_USERS, commands=["stop"]) @dp.callback_query_handler(text="sd") async def inl_sd(message: Union[types.Message, types.CallbackQuery]) -> None: logging.info("inl_sd") @@ -720,7 +719,7 @@ async def inl_uplora(callback: types.CallbackQuery) -> None: await callback.message.reply(f"Файл '{file_name}' загружен в {folder_path}") # Вызов reset_param, сброс JSON -@dp.message_handler(lambda message: message.from_user.username in ALLOWED_USERS, commands=["reset_param"]) +@dp.message_handler(lambda message: message.from_user.id in ALLOWED_USERS, commands=["reset_param"]) @dp.callback_query_handler(text="reset_param") async def inl_reset_param(message: Union[types.Message, types.CallbackQuery]) -> None: logging.info("inl_reset_param") @@ -735,7 +734,7 @@ async def inl_reset_param(message: Union[types.Message, types.CallbackQuery]) -> await getKeyboardUnion(txt, message, keyboard, '') # Вызов fast_param, быстрые настройки -@dp.message_handler(lambda message: message.from_user.username in ALLOWED_USERS, commands=["fast_param"]) +@dp.message_handler(lambda message: message.from_user.id in ALLOWED_USERS, commands=["fast_param"]) @dp.callback_query_handler(text="fast_param") async def inl_fast_param(message: Union[types.Message, types.CallbackQuery]) -> None: logging.info("inl_fast_param") @@ -743,13 +742,13 @@ async def inl_fast_param(message: Union[types.Message, types.CallbackQuery]) -> await getKeyboardUnion('Выбери быстрые настройки', message, keyboard, '') # Список быстрых настроек -@dp.message_handler(lambda message: message.from_user.username in ALLOWED_USERS, commands=["fp_comp"]) -@dp.message_handler(lambda message: message.from_user.username in ALLOWED_USERS, commands=["fp_mobile"]) -@dp.message_handler(lambda message: message.from_user.username in ALLOWED_USERS, commands=["fp_no_hr"]) -@dp.message_handler(lambda message: message.from_user.username in ALLOWED_USERS, commands=["fp_sdxl"]) -@dp.message_handler(lambda message: message.from_user.username in ALLOWED_USERS, commands=["fp_big"]) -@dp.message_handler(lambda message: message.from_user.username in ALLOWED_USERS, commands=["fp_inc"]) -@dp.message_handler(lambda message: message.from_user.username in ALLOWED_USERS, commands=["fp_wh"]) +@dp.message_handler(lambda message: message.from_user.id in ALLOWED_USERS, commands=["fp_comp"]) +@dp.message_handler(lambda message: message.from_user.id in ALLOWED_USERS, commands=["fp_mobile"]) +@dp.message_handler(lambda message: message.from_user.id in ALLOWED_USERS, commands=["fp_no_hr"]) +@dp.message_handler(lambda message: message.from_user.id in ALLOWED_USERS, commands=["fp_sdxl"]) +@dp.message_handler(lambda message: message.from_user.id in ALLOWED_USERS, commands=["fp_big"]) +@dp.message_handler(lambda message: message.from_user.id in ALLOWED_USERS, commands=["fp_inc"]) +@dp.message_handler(lambda message: message.from_user.id in ALLOWED_USERS, commands=["fp_wh"]) @dp.callback_query_handler(text="fp_comp") @dp.callback_query_handler(text="fp_mobile") @dp.callback_query_handler(text="fp_no_hr") @@ -779,7 +778,7 @@ async def inl_fp(message: Union[types.Message, types.CallbackQuery]) -> None: data['height'] = '768' data['restore_faces'] = 'false' data['do_not_save_grid'] = 'true' - data['negative_prompt'] = 'easynegative, bad-hands-5, bad-picture-chill-75v, bad-artist, bad_prompt_version2, rmadanegative4_sd15-neg, bad-image-v2-39000, illustration, painting, cartoons, sketch, (worst quality:2), (low quality:2), (normal quality:2), lowres, bad anatomy, bad hands, ((monochrome)), ((grayscale)), collapsed eyeshadow, multiple eyeblows, vaginas in breasts, (cropped), oversaturated, extra limb, missing limbs, deformed hands, long neck, long body, imperfect, (bad hands), signature, watermark, username, artist name, conjoined fingers, deformed fingers, ugly eyes, imperfect eyes, skewed eyes, unnatural face, unnatural body, error, asian, obese, tatoo, stacked torsos, totem pole, watermark, black and white, close up, cartoon, 3d, denim, (disfigured), (deformed), (poorly drawn), (extra limbs), blurry, boring, sketch, lackluster, signature, letters' + data['negative_prompt'] = 'easynegative, bad-hands-5, bad-picture-chill-75v, bad-artist, bad_prompt_version2, rmadanegative4_sd15-neg, bad-image-v2-39000, illustration, painting, cartoons, sketch, (worst quality:2), (low quality:2), (normal quality:2), lowres, bad anatomy, bad hands, ((monochrome)), ((grayscale)), collapsed eyeshadow, multiple eyeblows, vaginas in breasts, (cropped), oversaturated, extra limb, missing limbs, deformed hands, long neck, long body, imperfect, (bad hands), signature, watermark, id, artist name, conjoined fingers, deformed fingers, ugly eyes, imperfect eyes, skewed eyes, unnatural face, unnatural body, error, asian, obese, tatoo, stacked torsos, totem pole, watermark, black and white, close up, cartoon, 3d, denim, (disfigured), (deformed), (poorly drawn), (extra limbs), blurry, boring, sketch, lackluster, signature, letters' data['save_images'] = 'true' dataParams = {"img_thumb": "false", "img_tg": "true", @@ -794,7 +793,7 @@ async def inl_fp(message: Union[types.Message, types.CallbackQuery]) -> None: data['width'] = '512' data['height'] = '768' data['do_not_save_grid'] = 'true' - data['negative_prompt'] = 'easynegative, bad-hands-5, bad-picture-chill-75v, bad-artist, bad_prompt_version2, rmadanegative4_sd15-neg, bad-image-v2-39000, illustration, painting, cartoons, sketch, (worst quality:2), (low quality:2), (normal quality:2), lowres, bad anatomy, bad hands, ((monochrome)), ((grayscale)), collapsed eyeshadow, multiple eyeblows, vaginas in breasts, (cropped), oversaturated, extra limb, missing limbs, deformed hands, long neck, long body, imperfect, (bad hands), signature, watermark, username, artist name, conjoined fingers, deformed fingers, ugly eyes, imperfect eyes, skewed eyes, unnatural face, unnatural body, error, asian, obese, tatoo, stacked torsos, totem pole, watermark, black and white, close up, cartoon, 3d, denim, (disfigured), (deformed), (poorly drawn), (extra limbs), blurry, boring, sketch, lackluster, signature, letters' + data['negative_prompt'] = 'easynegative, bad-hands-5, bad-picture-chill-75v, bad-artist, bad_prompt_version2, rmadanegative4_sd15-neg, bad-image-v2-39000, illustration, painting, cartoons, sketch, (worst quality:2), (low quality:2), (normal quality:2), lowres, bad anatomy, bad hands, ((monochrome)), ((grayscale)), collapsed eyeshadow, multiple eyeblows, vaginas in breasts, (cropped), oversaturated, extra limb, missing limbs, deformed hands, long neck, long body, imperfect, (bad hands), signature, watermark, id, artist name, conjoined fingers, deformed fingers, ugly eyes, imperfect eyes, skewed eyes, unnatural face, unnatural body, error, asian, obese, tatoo, stacked torsos, totem pole, watermark, black and white, close up, cartoon, 3d, denim, (disfigured), (deformed), (poorly drawn), (extra limbs), blurry, boring, sketch, lackluster, signature, letters' data['save_images'] = 'true' dataParams = {"img_thumb": "true", "img_tg": "false", @@ -809,7 +808,7 @@ async def inl_fp(message: Union[types.Message, types.CallbackQuery]) -> None: data['width'] = '512' data['height'] = '768' data['do_not_save_grid'] = 'true' - data['negative_prompt'] = 'easynegative, bad-hands-5, bad-picture-chill-75v, bad-artist, bad_prompt_version2, rmadanegative4_sd15-neg, bad-image-v2-39000, illustration, painting, cartoons, sketch, (worst quality:2), (low quality:2), (normal quality:2), lowres, bad anatomy, bad hands, ((monochrome)), ((grayscale)), collapsed eyeshadow, multiple eyeblows, vaginas in breasts, (cropped), oversaturated, extra limb, missing limbs, deformed hands, long neck, long body, imperfect, (bad hands), signature, watermark, username, artist name, conjoined fingers, deformed fingers, ugly eyes, imperfect eyes, skewed eyes, unnatural face, unnatural body, error, asian, obese, tatoo, stacked torsos, totem pole, watermark, black and white, close up, cartoon, 3d, denim, (disfigured), (deformed), (poorly drawn), (extra limbs), blurry, boring, sketch, lackluster, signature, letters' + data['negative_prompt'] = 'easynegative, bad-hands-5, bad-picture-chill-75v, bad-artist, bad_prompt_version2, rmadanegative4_sd15-neg, bad-image-v2-39000, illustration, painting, cartoons, sketch, (worst quality:2), (low quality:2), (normal quality:2), lowres, bad anatomy, bad hands, ((monochrome)), ((grayscale)), collapsed eyeshadow, multiple eyeblows, vaginas in breasts, (cropped), oversaturated, extra limb, missing limbs, deformed hands, long neck, long body, imperfect, (bad hands), signature, watermark, id, artist name, conjoined fingers, deformed fingers, ugly eyes, imperfect eyes, skewed eyes, unnatural face, unnatural body, error, asian, obese, tatoo, stacked torsos, totem pole, watermark, black and white, close up, cartoon, 3d, denim, (disfigured), (deformed), (poorly drawn), (extra limbs), blurry, boring, sketch, lackluster, signature, letters' data['save_images'] = 'true' dataParams = {"img_thumb": "true", "img_tg": "false", @@ -829,7 +828,7 @@ async def inl_fp(message: Union[types.Message, types.CallbackQuery]) -> None: data['height'] = '768' data['restore_faces'] = 'false' data['do_not_save_grid'] = 'true' - data['negative_prompt'] = 'easynegative, bad-hands-5, bad-picture-chill-75v, bad-artist, bad_prompt_version2, rmadanegative4_sd15-neg, bad-image-v2-39000, illustration, painting, cartoons, sketch, (worst quality:2), (low quality:2), (normal quality:2), lowres, bad anatomy, bad hands, ((monochrome)), ((grayscale)), collapsed eyeshadow, multiple eyeblows, vaginas in breasts, (cropped), oversaturated, extra limb, missing limbs, deformed hands, long neck, long body, imperfect, (bad hands), signature, watermark, username, artist name, conjoined fingers, deformed fingers, ugly eyes, imperfect eyes, skewed eyes, unnatural face, unnatural body, error, asian, obese, tatoo, stacked torsos, totem pole, watermark, black and white, close up, cartoon, 3d, denim, (disfigured), (deformed), (poorly drawn), (extra limbs), blurry, boring, sketch, lackluster, signature, letters' + data['negative_prompt'] = 'easynegative, bad-hands-5, bad-picture-chill-75v, bad-artist, bad_prompt_version2, rmadanegative4_sd15-neg, bad-image-v2-39000, illustration, painting, cartoons, sketch, (worst quality:2), (low quality:2), (normal quality:2), lowres, bad anatomy, bad hands, ((monochrome)), ((grayscale)), collapsed eyeshadow, multiple eyeblows, vaginas in breasts, (cropped), oversaturated, extra limb, missing limbs, deformed hands, long neck, long body, imperfect, (bad hands), signature, watermark, id, artist name, conjoined fingers, deformed fingers, ugly eyes, imperfect eyes, skewed eyes, unnatural face, unnatural body, error, asian, obese, tatoo, stacked torsos, totem pole, watermark, black and white, close up, cartoon, 3d, denim, (disfigured), (deformed), (poorly drawn), (extra limbs), blurry, boring, sketch, lackluster, signature, letters' data['save_images'] = 'true' dataParams = {"img_thumb": "false", "img_tg": "true", @@ -845,7 +844,7 @@ async def inl_fp(message: Union[types.Message, types.CallbackQuery]) -> None: data['width'] = '512' data['height'] = '768' data['do_not_save_grid'] = 'true' - data['negative_prompt'] = 'easynegative, bad-hands-5, bad-picture-chill-75v, bad-artist, bad_prompt_version2, rmadanegative4_sd15-neg, bad-image-v2-39000, illustration, painting, cartoons, sketch, (worst quality:2), (low quality:2), (normal quality:2), lowres, bad anatomy, bad hands, ((monochrome)), ((grayscale)), collapsed eyeshadow, multiple eyeblows, vaginas in breasts, (cropped), oversaturated, extra limb, missing limbs, deformed hands, long neck, long body, imperfect, (bad hands), signature, watermark, username, artist name, conjoined fingers, deformed fingers, ugly eyes, imperfect eyes, skewed eyes, unnatural face, unnatural body, error, asian, obese, tatoo, stacked torsos, totem pole, watermark, black and white, close up, cartoon, 3d, denim, (disfigured), (deformed), (poorly drawn), (extra limbs), blurry, boring, sketch, lackluster, signature, letters' + data['negative_prompt'] = 'easynegative, bad-hands-5, bad-picture-chill-75v, bad-artist, bad_prompt_version2, rmadanegative4_sd15-neg, bad-image-v2-39000, illustration, painting, cartoons, sketch, (worst quality:2), (low quality:2), (normal quality:2), lowres, bad anatomy, bad hands, ((monochrome)), ((grayscale)), collapsed eyeshadow, multiple eyeblows, vaginas in breasts, (cropped), oversaturated, extra limb, missing limbs, deformed hands, long neck, long body, imperfect, (bad hands), signature, watermark, id, artist name, conjoined fingers, deformed fingers, ugly eyes, imperfect eyes, skewed eyes, unnatural face, unnatural body, error, asian, obese, tatoo, stacked torsos, totem pole, watermark, black and white, close up, cartoon, 3d, denim, (disfigured), (deformed), (poorly drawn), (extra limbs), blurry, boring, sketch, lackluster, signature, letters' data['save_images'] = 'false' dataParams = {"img_thumb": "true", "img_tg": "false", @@ -877,7 +876,7 @@ async def inl_fp(message: Union[types.Message, types.CallbackQuery]) -> None: await getKeyboardUnion(txt, message, keyboard, '') # Обработчик команды /skip -@dp.message_handler(lambda message: message.from_user.username in ALLOWED_USERS, commands=["skip"]) +@dp.message_handler(lambda message: message.from_user.id in ALLOWED_USERS, commands=["skip"]) @dp.callback_query_handler(text="skip") async def inl_skip(message: Union[types.Message, types.CallbackQuery]) -> None: logging.info('inl_skip') @@ -897,7 +896,7 @@ async def inl_skip(message: Union[types.Message, types.CallbackQuery]) -> None: reply_markup=getStart(), ) -@dp.message_handler(lambda message: message.from_user.username in ALLOWED_USERS, commands=["gen"]) +@dp.message_handler(lambda message: message.from_user.id in ALLOWED_USERS, commands=["gen"]) @dp.callback_query_handler(text="gen") async def inl_gen(message: Union[types.Message, types.CallbackQuery]) -> None: if hasattr(message, "content_type"): @@ -1046,7 +1045,7 @@ async def cmd_prompt(message: Union[types.Message, types.CallbackQuery]) -> None await getKeyboardUnion("Опции", message, keyboard) # Получить опции -@dp.message_handler(lambda message: message.from_user.username in ALLOWED_USERS, commands=["opt"]) +@dp.message_handler(lambda message: message.from_user.id in ALLOWED_USERS, commands=["opt"]) @dp.callback_query_handler(text="opt") async def cmd_opt(message: Union[types.Message, types.CallbackQuery]) -> None: logging.info("cmd_opt") @@ -1054,7 +1053,7 @@ async def cmd_opt(message: Union[types.Message, types.CallbackQuery]) -> None: await getKeyboardUnion("Опции", message, keyboard) # Вызов sttngs -@dp.message_handler(lambda message: message.from_user.username in ALLOWED_USERS, commands=["sttngs"]) +@dp.message_handler(lambda message: message.from_user.id in ALLOWED_USERS, commands=["sttngs"]) @dp.callback_query_handler(text="sttngs") async def inl_sttngs(message: Union[types.Message, types.CallbackQuery]) -> None: logging.info("inl_sttngs") @@ -1062,7 +1061,7 @@ async def inl_sttngs(message: Union[types.Message, types.CallbackQuery]) -> None await getKeyboardUnion("Настройки", message, keyboard) # Вызов script -@dp.message_handler(lambda message: message.from_user.username in ALLOWED_USERS, commands=["scrpts"]) +@dp.message_handler(lambda message: message.from_user.id in ALLOWED_USERS, commands=["scrpts"]) @dp.callback_query_handler(text="scrpts") async def inl_scrpts(message: Union[types.Message, types.CallbackQuery]) -> None: logging.info("inl_scrpts") @@ -1070,7 +1069,7 @@ async def inl_scrpts(message: Union[types.Message, types.CallbackQuery]) -> None await getKeyboardUnion("Скрипты", message, keyboard) # Вызов get_models -@dp.message_handler(lambda message: message.from_user.username in ALLOWED_USERS, commands=["mdl"]) +@dp.message_handler(lambda message: message.from_user.id in ALLOWED_USERS, commands=["mdl"]) @dp.callback_query_handler(text="mdl") async def inl_mdl(message: Union[types.Message, types.CallbackQuery]) -> None: logging.info("inl_mdl") @@ -1085,8 +1084,8 @@ async def inl_mdl(message: Union[types.Message, types.CallbackQuery]) -> None: await getKeyboardUnion("Turn on SD"+sd, message, keyboard) # Вызов get_samplers -@dp.message_handler(lambda message: message.from_user.username in ALLOWED_USERS, commands=["smplr"]) -@dp.message_handler(lambda message: message.from_user.username in ALLOWED_USERS, commands=["sampler_name"]) +@dp.message_handler(lambda message: message.from_user.id in ALLOWED_USERS, commands=["smplr"]) +@dp.message_handler(lambda message: message.from_user.id in ALLOWED_USERS, commands=["sampler_name"]) @dp.callback_query_handler(text="smplr") async def inl_smplr(message: Union[types.Message, types.CallbackQuery]) -> None: logging.info("inl_smplr") @@ -1101,8 +1100,8 @@ async def inl_smplr(message: Union[types.Message, types.CallbackQuery]) -> None: await getKeyboardUnion("Turn on SD"+sd, message, keyboard) # Вызов get_hr_list -@dp.message_handler(lambda message: message.from_user.username in ALLOWED_USERS, commands=["hr"]) -@dp.message_handler(lambda message: message.from_user.username in ALLOWED_USERS, commands=["hr_upscaler"]) +@dp.message_handler(lambda message: message.from_user.id in ALLOWED_USERS, commands=["hr"]) +@dp.message_handler(lambda message: message.from_user.id in ALLOWED_USERS, commands=["hr_upscaler"]) @dp.callback_query_handler(text="hr") async def inl_hr(message: Union[types.Message, types.CallbackQuery]) -> None: logging.info("inl_hr") @@ -1130,14 +1129,14 @@ async def inl_change_param(callback: types.CallbackQuery) -> None: ) # script random gen from models -@dp.message_handler(lambda message: message.from_user.username in ALLOWED_USERS, commands=["rnd_mdl"]) +@dp.message_handler(lambda message: message.from_user.id in ALLOWED_USERS, commands=["rnd_mdl"]) @dp.callback_query_handler(text='rnd_mdl') async def inl_rnd_mdl(message: Union[types.Message, types.CallbackQuery]) -> None: logging.info('inl_rnd_mdl') await rnd_script(message, 'models') # script random gen from models -@dp.message_handler(lambda message: message.from_user.username in ALLOWED_USERS, commands=["rnd_smp"]) +@dp.message_handler(lambda message: message.from_user.id in ALLOWED_USERS, commands=["rnd_smp"]) @dp.callback_query_handler(text='rnd_smp') async def inl_rnd_smp(message: Union[types.Message, types.CallbackQuery]) -> None: logging.info('inl_rnd_smp') @@ -1191,7 +1190,7 @@ async def inf_func(chatId): ) # script random infinity gen from https://random-word-api.herokuapp.com/word?lang=en -@dp.message_handler(lambda message: message.from_user.username in ALLOWED_USERS, commands=["inf"]) +@dp.message_handler(lambda message: message.from_user.id in ALLOWED_USERS, commands=["inf"]) @dp.callback_query_handler(text='inf') async def inl_rnd_inf(message: Union[types.Message, types.CallbackQuery]) -> None: logging.info('inl_rnd_inf') @@ -1230,7 +1229,7 @@ async def inl_rnd_inf(message: Union[types.Message, types.CallbackQuery]) -> Non await inf_func(chatId) # Получить LORA -@dp.message_handler(lambda message: message.from_user.username in ALLOWED_USERS, commands=["get_lora"]) +@dp.message_handler(lambda message: message.from_user.id in ALLOWED_USERS, commands=["get_lora"]) @dp.callback_query_handler(text="get_lora") async def getLora(message: Union[types.Message, types.CallbackQuery]) -> None: logging.info("getLora") @@ -1254,7 +1253,7 @@ async def getLora(message: Union[types.Message, types.CallbackQuery]) -> None: await getKeyboardUnion(arr, message, keyboard) # Рандомный промпт с lexica.art на основе data['prompt'] -@dp.message_handler(lambda message: message.from_user.username in ALLOWED_USERS, commands=["lxc_prompt"]) +@dp.message_handler(lambda message: message.from_user.id in ALLOWED_USERS, commands=["lxc_prompt"]) @dp.callback_query_handler(text="lxc_prompt") async def get_lxc_prompt(message: Union[types.Message, types.CallbackQuery]) -> None: logging.info("get_lxc_prompt") @@ -1354,7 +1353,7 @@ async def handle_channel_post(message: types.Message): ) # Ввели любой текст -@dp.message_handler(lambda message: True and message.from_user.username in ALLOWED_USERS) +@dp.message_handler(lambda message: True and message.from_user.id in ALLOWED_USERS) async def change_json(message: types.Message): logging.info("change_json") keyboard = InlineKeyboardMarkup(inline_keyboard=[getSet(0), getOpt(0), getStart(0)]) @@ -1411,7 +1410,7 @@ async def change_json(message: types.Message): ) # Ввели ответ на change_json -@dp.message_handler(lambda message: message.from_user.username in ALLOWED_USERS, state=Form) +@dp.message_handler(lambda message: message.from_user.id in ALLOWED_USERS, state=Form) async def answer_handler(message: types.Message, state: FSMContext): logging.info('answer_handler') keyboard = InlineKeyboardMarkup(inline_keyboard=[getSet(0), getOpt(0), getStart(0)]) @@ -1434,7 +1433,7 @@ async def answer_handler(message: types.Message, state: FSMContext): f"JSON параметры:\n{getJson()}\n{getJson(1)}", reply_markup=keyboard ) -@dp.message_handler(lambda message: message.from_user.username in ALLOWED_USERS, content_types=['document']) +@dp.message_handler(lambda message: message.from_user.id in ALLOWED_USERS, content_types=['document']) async def handle_file(message: types.Message): logging.info('handle_file') diff --git a/example.env b/example.env index 866f690..aee8973 100644 --- a/example.env +++ b/example.env @@ -10,5 +10,4 @@ SD_PORT = '7861' SD_USERNAME = 'user' SD_PASSWORD = '1234' DEBUG = 'no' # 'yes' to debug -# TODO: change usernames to id -ALLOWED_USERS = '["username1", "username2", "usernameN"]' \ No newline at end of file +ALLOWED_USERS = '["id1", "id2", "idN"]' # must not be empty, at least one value #TODO handle this \ No newline at end of file