diff --git a/handlers/pipisa.py b/handlers/pipisa.py
index 0ed1cad..5caf789 100644
--- a/handlers/pipisa.py
+++ b/handlers/pipisa.py
@@ -1,4 +1,5 @@
from aiogram import types, Dispatcher
+from sqlalchemy.orm.session import close_all_sessions
from create_bot import bot, dp
from sqdb import user, session
from random import randint
@@ -31,7 +32,7 @@ async def up_dick(message: types.Message):
if abs(diff) <= 0:
with session:
await bot.send_message(message.chat.id, f'@{message.from_user.username},π« Π²Ρ ΡΠΆΠ΅ ΠΊΡΡΡΠΈΠ»ΠΈ ΠΏΠΈΠΏΠΈΡΡ, Π΅Π΅ ΡΠ°Π·ΠΌΠ΅Ρ {b.dick_size} ΡΠΌ! ')
- session.close()
+ await close_all_sessions()
print(diff)
print(type(diff))
else:
@@ -42,7 +43,7 @@ async def up_dick(message: types.Message):
session.commit() #ΠΎΠ±Π½ΠΎΠ²Π»ΡΠ΅Ρ Π·Π°ΠΏΠΈΡΡ
await bot.send_message(message.chat.id, f'@{message.from_user.username}, Π²Π°Ρ ΠΏΠΈΡΡΠ½ {size_change}\n\
Π’Π΅ΠΏΠ΅ΡΡ ΠΎΠ½ ΡΠ°Π²Π΅Π½ {a.dick_size} ΡΠΌ! ')
- session.close()
+ close_all_sessions()
else:
with session:
@@ -53,19 +54,18 @@ async def up_dick(message: types.Message):
session.close()
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):
- with session:
- changechat_id = session.query(user).filter(user.user_id == message.from_user.id).first()
- chats = message.chat.id
- if changechat_id.chat_id != chats:
- changechat_id.chat_id = chats
- session.close()
- with session:
- top = session.query(user.user_fullname, user.dick_size).order_by(user.dick_size.desc()).filter(user.chat_id == chats).limit(10).all()
+ changechat_id = session.query(user).filter(user.user_id == message.from_user.id).first()
+ chats = message.chat.id
+ if changechat_id.chat_id != chats:
+ changechat_id.chat_id = chats
session.close()
+ top = session.query(user.user_fullname, user.dick_size).order_by(user.dick_size.desc()).filter(user.chat_id == chats).limit(10).all()
+ session.close()
delimiter = ': '
# ΠΏΡΠΎΠ²Π΅ΡΠΊΠ° Π½Π° Π΄Π»ΠΈΠ½Ρ ΡΠΏΠΈΡΠΊΠ°, Π΅ΡΠ»ΠΈ ΠΌΠ΅Π½ΡΡΠ΅ limit, ΡΠΎ:
@@ -85,7 +85,7 @@ 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()
+ close_all_sessions()
# Π΅ΡΠ»ΠΈ Π²ΡΠ΅ Π½ΠΎΡΠΌΠ°Π»ΡΠ½ΠΎ ΠΈ ΡΡΠ°ΡΡΠ½ΠΈΠΊΠΎΠ² ΠΌΠΈΠ½ΠΈΠΌΡΠΌ 10
else:
@@ -123,7 +123,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')
- session.close()
+ close_all_sessions()
def register_handlers_pipisa(dp: Dispatcher):