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[8]))}\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"])
@ -32,10 +39,10 @@ async def up_dick(message: types.Message): # рандомайзер
numb = randint(-6, 10)
global size_change, dick_plus, dick_minus
dick_plus = ('<b>вырос</b>', '<b>подрос</b>', '<b>привстал</b>')
dick_plus = ('<b>вырос</b>', '<b>подрос</b>', '<b>привстал</b>')
dick_minus = ('<b>уменьшился</b>', '<b>откусила злая гадюка</b>', '<b>продали евреи, он стал дешевле</b>')
if numb > 0:
size_change = random.choice(dick_plus) + '🚀'
size_change = random.choice(dick_plus) + '🚀'
# if numb = 0 size_change = random.choice(const) TODO
else:
size_change = random.choice(dick_minus) + ''
@ -134,7 +141,8 @@ async def send_topchat(message: types.Message):
session.close()
else:
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, то:
@ -149,14 +157,13 @@ async def send_topchat(message: types.Message):
else:
await bot.send_message(message.chat.id, top_dick_message(delimiter, top))
except:
except Exception as e:
session.rollback()
print('ошибка в /topdick')
print('ошибка в /topdick. Трейсбэк:\n' + '\n'.join(traceback.format_tb(e.__traceback__)))
finally:
session.close_all()
@dp.message_handler(commands=["globaldick"])
async def send_global_top(message: types.Message):
try:
@ -165,9 +172,9 @@ async def send_global_top(message: types.Message):
delimiter = ': '
await bot.send_message(message.chat.id, top_dick_message(delimiter, top_chat))
except:
except Exception as e:
session.rollback()
print('ошибка в /globaldick')
print('ошибка в /globaldick, трейсбэк:\n' + '\n'.join(traceback.format_tb(e.__traceback__)))
finally:
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(send_topchat)
# dp.register_message_handler(send_global_top)