diff --git a/main.py b/main.py index 6572f86..03ca164 100644 --- a/main.py +++ b/main.py @@ -252,14 +252,12 @@ PARSER_ALIVE = True def parse_runner(): - with Parser() as parser: - parser.login() - while True: - if PARSER_ALIVE: + while True: + with Parser() as parser: + parser.login() + while PARSER_ALIVE: parser.search() time.sleep(60) - else: - time.sleep(1) parser_thread = threading.Thread(target=parse_runner, daemon=True) @@ -283,22 +281,22 @@ async def message_handler(message: Message): await message.answer("Вы не зарегистрированы, обратитесь к администратору") return - markup = ReplyKeyboardMarkup(keyboard=[[KeyboardButton(text="Запустить Бот")]]) + markup_start = ReplyKeyboardMarkup(keyboard=[[KeyboardButton(text="Запустить Бот")]]) + markup_shutdown = ReplyKeyboardMarkup(keyboard=[[KeyboardButton(text="Остановить Бот")]]) if message.text == "Запустить Бот": PARSER_ALIVE = True for chat_id in s.get_users(): await bot.send_message(chat_id, f"Пользователь {message.from_user.full_name} запускает бот", - reply_markup=markup) + reply_markup=markup_shutdown) parser_thread.start() return if message.text == "Остановить Бот": for chat_id in s.get_users(): await bot.send_message(chat_id, f"Пользователь {message.from_user.full_name} остановил бот", - reply_markup=markup) + reply_markup=markup_start) PARSER_ALIVE = False - await message.answer("Бот остановлен", reply_markup=markup) return await message.answer("Неизвестная команда") diff --git a/telegram_logs.py b/telegram_logs.py index 406e11d..58c6ce3 100644 --- a/telegram_logs.py +++ b/telegram_logs.py @@ -1,5 +1,6 @@ import json +import loguru import requests from loguru import logger from storage import Storage @@ -22,7 +23,7 @@ def _log(message): "chat_id": int(chat_id), "disable_notification": True, "text": icon + message, - "reply_markup": json.dumps({"keyboard": [[{"text": "Остановить Бот"}]]}) + # "reply_markup": json.dumps({"keyboard": [[{"text": "Остановить Бот"}]]}) }) if r.status_code != 200: print(r.json())