fix session
All checks were successful
continuous-integration/drone/push Build is passing

This commit is contained in:
Pavel_Duron 2022-12-04 17:11:30 +10:00
parent cc4549d598
commit e748ee3913

51
bot.py
View File

@ -66,35 +66,41 @@ async def ident(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()
session.close()
last_time = b.datetimes
diff = now_time.day - last_time.day
if abs(diff) <= 0:
await bot.send_message(message.chat.id, f'@{message.from_user.username},🚫 вы уже крутили пипису, ее размер <b>{b.dick_size}</b> см! ')
session.close_all()
print(diff)
print(type(diff))
with session:
await bot.send_message(message.chat.id, f'@{message.from_user.username},🚫 вы уже крутили пипису, ее размер <b>{b.dick_size}</b> см! ')
session.close()
print(diff)
print(type(diff))
else:
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() #обновляет запись
await bot.send_message(message.chat.id, f'@{message.from_user.username}, ваш писюн {size_change}\n\
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() #обновляет запись
await bot.send_message(message.chat.id, f'@{message.from_user.username}, ваш писюн {size_change}\n\
Теперь он равен <b>{a.dick_size}</b> см! ')
session.close()
session.close()
else:
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()
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(),\
chat_id = message.chat.id)
session.add(int_table)
session.commit()
session.close()
await bot.send_message(message.chat.id, f'@{message.from_user.username}, ваш писюн {size_change}\n\
Теперь он равен <b>{int_table.dick_size}</b> см!')
session.close()
# int_table = user(user_id = message.from_user.id, user_fullname = message.from_user.full_name, dick_size = numb) #импортирую юзер из sqdb
@ -112,14 +118,15 @@ chat_id = message.chat.id)
@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()
chats = message.chat.id
if changechat_id.chat_id != chats:
changechat_id.chat_id = chats
session.commit()
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()
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, то:'''