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