From 45d4aa8c9a904a411adee48a1523b978e065ca23 Mon Sep 17 00:00:00 2001 From: Pavel_Duron Date: Tue, 6 Dec 2022 20:25:52 +1000 Subject: [PATCH] add alarm of job --- bot.py | 5 ++--- handlers/__init__.py | 3 ++- handlers/coding.py | 12 ++++++++++++ handlers/pipisa.py | 2 +- handlers/start_help.py | 3 --- 5 files changed, 17 insertions(+), 8 deletions(-) create mode 100644 handlers/coding.py diff --git a/bot.py b/bot.py index 604e724..feb4cba 100644 --- a/bot.py +++ b/bot.py @@ -1,11 +1,9 @@ from create_bot import dp import logging from aiogram import executor -from handlers import pipisa, time_new_year, start_help +from handlers import pipisa, time_new_year, start_help, coding -print('Бот начал работу') - logging.basicConfig(level=logging.DEBUG) @@ -13,6 +11,7 @@ logging.basicConfig(level=logging.DEBUG) pipisa.register_handlers_pipisa(dp) time_new_year.register_handlers_time(dp) start_help.register_handlers_StartHelp(dp) +coding.register_handlers_alarm(dp) diff --git a/handlers/__init__.py b/handlers/__init__.py index 153685f..1453e09 100644 --- a/handlers/__init__.py +++ b/handlers/__init__.py @@ -1,3 +1,4 @@ from handlers import pipisa from handlers import time_new_year -from handlers import start_help \ No newline at end of file +from handlers import start_help +from handlers import coding \ No newline at end of file diff --git a/handlers/coding.py b/handlers/coding.py new file mode 100644 index 0000000..879150b --- /dev/null +++ b/handlers/coding.py @@ -0,0 +1,12 @@ +from aiogram import types, Dispatcher +from create_bot import bot, dp +from sqdb import user, session + +@dp.message_handler(commands=['alarm']) +async def notify_chats(message: types.Message): + for chats in session.query(user.chat_id).distinct(): + session.close() + await bot.send_message(chats,'Ведутся пажилые работы,\n Ожидайте...') + +def register_handlers_alarm(dp: Dispatcher): + dp.register_message_handler(notify_chats) \ No newline at end of file diff --git a/handlers/pipisa.py b/handlers/pipisa.py index 7079917..338d759 100644 --- a/handlers/pipisa.py +++ b/handlers/pipisa.py @@ -44,7 +44,7 @@ async def up_dick(message: types.Message): else: - + session.close() int_table = user(user_id = message.from_user.id, user_fullname = message.from_user.full_name, dick_size = numb, datetimes = datetime.datetime.now(),\ chat_id = message.chat.id) session.add(int_table) diff --git a/handlers/start_help.py b/handlers/start_help.py index 161987d..ce8ff6e 100644 --- a/handlers/start_help.py +++ b/handlers/start_help.py @@ -3,9 +3,6 @@ from create_bot import dp, bot @dp.message_handler(commands=['start']) async def start_func(message: types.Message): - # user_id = message.from_user.id - # user_full_name = message.from_user.full_name - # logging.INFO(f'{user_id=} {user_full_name=}', {time.asctime()}) await message.reply('похуй') @dp.message_handler(commands=['photo'])