master
Ernest Litvinenko 2024-03-05 15:36:15 +03:00
parent 069ce87453
commit a6028da0ff
1 changed files with 5 additions and 0 deletions

View File

@ -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} остановил бот",