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

This commit is contained in:
Pavel_Duron 2022-12-06 17:05:09 +10:00
parent 8682555bcb
commit 502dca273d
2 changed files with 23 additions and 24 deletions

1
bot.py
View File

@ -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)

View File

@ -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()
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>{b.dick_size}</b> см! ')
await close_all_sessions()
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\
Теперь он равен <b>{a.dick_size}</b> см! ')
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(),\
chat_id = message.chat.id)
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\
Теперь он равен <b>{int_table.dick_size}</b> см!')
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()
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):