forked from Pavel_Durov/python_bot
fix sesions
This commit is contained in:
parent
8682555bcb
commit
502dca273d
1
bot.py
1
bot.py
@ -12,7 +12,6 @@ logging.basicConfig(level=logging.DEBUG)
|
|||||||
|
|
||||||
pipisa.register_handlers_pipisa(dp)
|
pipisa.register_handlers_pipisa(dp)
|
||||||
time_new_year.register_handlers_time(dp)
|
time_new_year.register_handlers_time(dp)
|
||||||
|
|
||||||
start_help.register_handlers_StartHelp(dp)
|
start_help.register_handlers_StartHelp(dp)
|
||||||
|
|
||||||
|
|
||||||
|
@ -20,46 +20,46 @@ async def up_dick(message: types.Message):
|
|||||||
|
|
||||||
|
|
||||||
# работа с таблицей
|
# работа с таблицей
|
||||||
|
b = session.query(user).filter(user.user_id == message.from_user.id).first()
|
||||||
if session.query(user).filter(user.user_id == message.from_user.id).first():
|
if b:
|
||||||
b = session.query(user).filter(user.user_id == message.from_user.id).first()
|
|
||||||
now_time = datetime.datetime.now()
|
|
||||||
session.close()
|
session.close()
|
||||||
last_time = b.datetimes
|
last_time = b.datetimes
|
||||||
|
now_time = datetime.datetime.now()
|
||||||
diff = now_time.day - last_time.day
|
diff = now_time.day - last_time.day
|
||||||
|
|
||||||
|
|
||||||
if abs(diff) <= 0:
|
if abs(diff) <= 0:
|
||||||
with session:
|
await bot.send_message(message.chat.id, f'@{message.from_user.username},🚫 вы уже крутили пипису, ее размер <b>{b.dick_size}</b> см! ')
|
||||||
await bot.send_message(message.chat.id, f'@{message.from_user.username},🚫 вы уже крутили пипису, ее размер <b>{b.dick_size}</b> см! ')
|
print(diff)
|
||||||
await close_all_sessions()
|
print(type(diff))
|
||||||
print(diff)
|
|
||||||
print(type(diff))
|
|
||||||
else:
|
else:
|
||||||
with session:
|
|
||||||
a = session.query(user).filter(user.user_id == message.from_user.id).first() # запрос на поиск в таблице
|
a = session.query(user).filter(user.user_id == message.from_user.id).first() # запрос на поиск в таблице
|
||||||
a.dick_size = (a.dick_size + numb)
|
a.dick_size = (a.dick_size + numb)
|
||||||
a.datetimes = datetime.datetime.now()
|
a.datetimes = datetime.datetime.now()
|
||||||
session.commit() #обновляет запись
|
session.commit() #обновляет запись
|
||||||
|
session.close()
|
||||||
|
close_all_sessions()
|
||||||
await bot.send_message(message.chat.id, f'@{message.from_user.username}, ваш писюн {size_change}\n\
|
await bot.send_message(message.chat.id, f'@{message.from_user.username}, ваш писюн {size_change}\n\
|
||||||
Теперь он равен <b>{a.dick_size}</b> см! ')
|
Теперь он равен <b>{a.dick_size}</b> см! ')
|
||||||
close_all_sessions()
|
|
||||||
|
|
||||||
else:
|
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)
|
chat_id = message.chat.id)
|
||||||
session.add(int_table)
|
session.add(int_table)
|
||||||
session.commit()
|
session.commit()
|
||||||
session.close()
|
session.close()
|
||||||
|
close_all_sessions()
|
||||||
await bot.send_message(message.chat.id, f'@{message.from_user.username}, ваш писюн {size_change}\n\
|
await bot.send_message(message.chat.id, f'@{message.from_user.username}, ваш писюн {size_change}\n\
|
||||||
Теперь он равен <b>{int_table.dick_size}</b> см!')
|
Теперь он равен <b>{int_table.dick_size}</b> см!')
|
||||||
close_all_sessions()
|
|
||||||
|
|
||||||
|
|
||||||
@dp.message_handler(commands=["topdick"])
|
@dp.message_handler(commands=["topdick"])
|
||||||
async def send_topchat(message: types.Message):
|
async def send_topchat(message: types.Message):
|
||||||
changechat_id = session.query(user).filter(user.user_id == message.from_user.id).first()
|
changechat_id = session.query(user).filter(user.user_id == message.from_user.id).first()
|
||||||
|
session.close()
|
||||||
chats = message.chat.id
|
chats = message.chat.id
|
||||||
if changechat_id.chat_id != chats:
|
if changechat_id.chat_id != chats:
|
||||||
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[7]))}\n\
|
||||||
👌 {delimiter.join(map(str, top[8]))}\n\
|
👌 {delimiter.join(map(str, top[8]))}\n\
|
||||||
💩 {delimiter.join(map(str, top[9]))}\n')
|
💩 {delimiter.join(map(str, top[9]))}\n')
|
||||||
close_all_sessions()
|
|
||||||
# если все нормально и участников минимум 10
|
# если все нормально и участников минимум 10
|
||||||
|
|
||||||
else:
|
else:
|
||||||
|
session.close()
|
||||||
await bot.send_message(message.chat.id, f'🏆Топ 10 бубылд чата🏆\n\n\
|
await bot.send_message(message.chat.id, f'🏆Топ 10 бубылд чата🏆\n\n\
|
||||||
🚀 {delimiter.join(map(str, top[0]))}\n\
|
🚀 {delimiter.join(map(str, top[0]))}\n\
|
||||||
💫 {delimiter.join(map(str, top[1]))}\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[7]))}\n\
|
||||||
👌 {delimiter.join(map(str, top[8]))}\n\
|
👌 {delimiter.join(map(str, top[8]))}\n\
|
||||||
💩 {delimiter.join(map(str, top[9]))}\n')
|
💩 {delimiter.join(map(str, top[9]))}\n')
|
||||||
session.close()
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
@dp.message_handler(commands=["globaldick"])
|
@dp.message_handler(commands=["globaldick"])
|
||||||
async def send_global_top(message: types.Message):
|
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 = ': '
|
delimiter = ': '
|
||||||
|
|
||||||
|
|
||||||
@ -124,7 +124,7 @@ async def send_global_top(message: types.Message):
|
|||||||
8. {delimiter.join(map(str, top_chat[7]))}\n\
|
8. {delimiter.join(map(str, top_chat[7]))}\n\
|
||||||
9. {delimiter.join(map(str, top_chat[8]))}\n\
|
9. {delimiter.join(map(str, top_chat[8]))}\n\
|
||||||
10. {delimiter.join(map(str, top_chat[9]))}\n')
|
10. {delimiter.join(map(str, top_chat[9]))}\n')
|
||||||
close_all_sessions()
|
|
||||||
|
|
||||||
|
|
||||||
def register_handlers_pipisa(dp: Dispatcher):
|
def register_handlers_pipisa(dp: Dispatcher):
|
||||||
|
Loading…
Reference in New Issue
Block a user