minor fixes and PEP8'ification
All checks were successful
continuous-integration/drone/push Build is passing

This commit is contained in:
hopelessjames 2023-06-19 19:24:40 +10:00
parent 6169e6e32a
commit da06b5ad23

View File

@ -25,6 +25,13 @@ def top_dick_message(delimiter, top_list):
f'🌶 {delimiter.join(map(str, top_list[7]))}\n' f'🌶 {delimiter.join(map(str, top_list[7]))}\n'
f'👌 {delimiter.join(map(str, top_list[8]))}\n' f'👌 {delimiter.join(map(str, top_list[8]))}\n'
f'💩 {delimiter.join(map(str, top_list[9]))}\n' f'💩 {delimiter.join(map(str, top_list[9]))}\n'
return message
@dp.message_handler(commands=["maintainance"])
async def stop_for_maintenance(message: types.Message): # остановить бота
if message.from_user.id == 226765676:
close_all_sessions() # TODO Вспомнить, как это, блять, делается.
@dp.message_handler(commands=["dick"]) @dp.message_handler(commands=["dick"])
@ -134,7 +141,8 @@ async def send_topchat(message: types.Message):
session.close() session.close()
else: else:
session.close() 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() users = session.query(user.user_fullname, user.dick_size).order_by(user.dick_size.desc())
top = users.filter(user.chat_id == chats).limit(10).all()
# проверка на длину списка, если меньше limit, то: # проверка на длину списка, если меньше limit, то:
@ -149,14 +157,13 @@ async def send_topchat(message: types.Message):
else: else:
await bot.send_message(message.chat.id, top_dick_message(delimiter, top)) await bot.send_message(message.chat.id, top_dick_message(delimiter, top))
except: except Exception as e:
session.rollback() session.rollback()
print('ошибка в /topdick') print('ошибка в /topdick. Трейсбэк:\n' + '\n'.join(traceback.format_tb(e.__traceback__)))
finally: finally:
session.close_all() session.close_all()
@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):
try: try:
@ -165,9 +172,9 @@ async def send_global_top(message: types.Message):
delimiter = ': ' delimiter = ': '
await bot.send_message(message.chat.id, top_dick_message(delimiter, top_chat)) await bot.send_message(message.chat.id, top_dick_message(delimiter, top_chat))
except: except Exception as e:
session.rollback() session.rollback()
print('ошибка в /globaldick') print('ошибка в /globaldick, трейсбэк:\n' + '\n'.join(traceback.format_tb(e.__traceback__)))
finally: finally:
session.close_all() session.close_all()
@ -176,4 +183,3 @@ async def send_global_top(message: types.Message):
# dp.register_message_handler(up_dick) # dp.register_message_handler(up_dick)
# dp.register_message_handler(send_topchat) # dp.register_message_handler(send_topchat)
# dp.register_message_handler(send_global_top) # dp.register_message_handler(send_global_top)