diff --git a/main.py b/main.py index 03ca164..0947804 100644 --- a/main.py +++ b/main.py @@ -284,6 +284,9 @@ async def message_handler(message: Message): markup_start = ReplyKeyboardMarkup(keyboard=[[KeyboardButton(text="Запустить Бот")]]) markup_shutdown = ReplyKeyboardMarkup(keyboard=[[KeyboardButton(text="Остановить Бот")]]) if message.text == "Запустить Бот": + if PARSER_ALIVE: + await message.answer("Бот уже запущен", reply_markup=markup_shutdown) + return PARSER_ALIVE = True for chat_id in s.get_users(): await bot.send_message(chat_id, @@ -292,6 +295,8 @@ async def message_handler(message: Message): parser_thread.start() return if message.text == "Остановить Бот": + if not PARSER_ALIVE: + await message.answer("Бот уже остановлен", reply_markup=markup_start) for chat_id in s.get_users(): await bot.send_message(chat_id, f"Пользователь {message.from_user.full_name} остановил бот",