From 502dca273db36b8c6fbcc4e9122a3e2ec011e4a1 Mon Sep 17 00:00:00 2001 From: Pavel_Duron Date: Tue, 6 Dec 2022 17:05:09 +1000 Subject: [PATCH] fix sesions --- bot.py | 1 - handlers/pipisa.py | 46 +++++++++++++++++++++++----------------------- 2 files changed, 23 insertions(+), 24 deletions(-) diff --git a/bot.py b/bot.py index b823556..604e724 100644 --- a/bot.py +++ b/bot.py @@ -12,7 +12,6 @@ logging.basicConfig(level=logging.DEBUG) pipisa.register_handlers_pipisa(dp) time_new_year.register_handlers_time(dp) - start_help.register_handlers_StartHelp(dp) diff --git a/handlers/pipisa.py b/handlers/pipisa.py index be77c22..7079917 100644 --- a/handlers/pipisa.py +++ b/handlers/pipisa.py @@ -20,46 +20,46 @@ async def up_dick(message: types.Message): # работа с таблицей - - if session.query(user).filter(user.user_id == message.from_user.id).first(): - b = session.query(user).filter(user.user_id == message.from_user.id).first() - now_time = datetime.datetime.now() + b = session.query(user).filter(user.user_id == message.from_user.id).first() + if b: session.close() last_time = b.datetimes + now_time = datetime.datetime.now() diff = now_time.day - last_time.day if abs(diff) <= 0: - with session: - await bot.send_message(message.chat.id, f'@{message.from_user.username},🚫 вы уже крутили пипису, ее размер {b.dick_size} см! ') - await close_all_sessions() - print(diff) - print(type(diff)) + await bot.send_message(message.chat.id, f'@{message.from_user.username},🚫 вы уже крутили пипису, ее размер {b.dick_size} см! ') + print(diff) + print(type(diff)) else: - with session: a = session.query(user).filter(user.user_id == message.from_user.id).first() # запрос на поиск в таблице a.dick_size = (a.dick_size + numb) a.datetimes = datetime.datetime.now() session.commit() #обновляет запись + session.close() + close_all_sessions() await bot.send_message(message.chat.id, f'@{message.from_user.username}, ваш писюн {size_change}\n\ Теперь он равен {a.dick_size} см! ') - close_all_sessions() + else: - with session: - int_table = user(user_id = message.from_user.id, user_fullname = message.from_user.full_name, dick_size = numb, datetimes = datetime.datetime.now(),\ + + 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) - session.commit() - session.close() + session.add(int_table) + session.commit() + session.close() + close_all_sessions() await bot.send_message(message.chat.id, f'@{message.from_user.username}, ваш писюн {size_change}\n\ Теперь он равен {int_table.dick_size} см!') - close_all_sessions() + @dp.message_handler(commands=["topdick"]) async def send_topchat(message: types.Message): changechat_id = session.query(user).filter(user.user_id == message.from_user.id).first() + session.close() chats = message.chat.id if changechat_id.chat_id != chats: changechat_id.chat_id = chats @@ -86,10 +86,11 @@ async def send_topchat(message: types.Message): 🌶 {delimiter.join(map(str, top[7]))}\n\ 👌 {delimiter.join(map(str, top[8]))}\n\ 💩 {delimiter.join(map(str, top[9]))}\n') - close_all_sessions() + # если все нормально и участников минимум 10 else: + session.close() await bot.send_message(message.chat.id, f'🏆Топ 10 бубылд чата🏆\n\n\ 🚀 {delimiter.join(map(str, top[0]))}\n\ 💫 {delimiter.join(map(str, top[1]))}\n\ @@ -101,15 +102,14 @@ async def send_topchat(message: types.Message): 🌶 {delimiter.join(map(str, top[7]))}\n\ 👌 {delimiter.join(map(str, top[8]))}\n\ 💩 {delimiter.join(map(str, top[9]))}\n') - session.close() + @dp.message_handler(commands=["globaldick"]) async def send_global_top(message: types.Message): - with session: - top_chat = session.query(user.user_fullname, user.dick_size).order_by(user.dick_size.desc()).limit(10).all() - + top_chat = session.query(user.user_fullname, user.dick_size).order_by(user.dick_size.desc()).limit(10).all() + session.close() delimiter = ': ' @@ -124,7 +124,7 @@ async def send_global_top(message: types.Message): 8. {delimiter.join(map(str, top_chat[7]))}\n\ 9. {delimiter.join(map(str, top_chat[8]))}\n\ 10. {delimiter.join(map(str, top_chat[9]))}\n') - close_all_sessions() + def register_handlers_pipisa(dp: Dispatcher):