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 17:33:06 +10:00
parent 61075491ec
commit 6169e6e32a

View File

@ -13,6 +13,20 @@ dick_plus = None
dick_minus = None dick_minus = None
def top_dick_message(delimiter, top_list):
message = f'🏆Топ 10 бубылд чата🏆\n\n'
f'🚀 {delimiter.join(map(str, top_list[0]))}\n'
f'💫 {delimiter.join(map(str, top_list[1]))}\n'
f'🍆 {delimiter.join(map(str, top_list[2]))}\n'
f'🍌 {delimiter.join(map(str, top_list[3]))}\n'
f'🐍 {delimiter.join(map(str, top_list[4]))}\n'
f'🐎 {delimiter.join(map(str, top_list[5]))}\n'
f'🌭 {delimiter.join(map(str, top_list[6]))}\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[9]))}\n'
@dp.message_handler(commands=["dick"]) @dp.message_handler(commands=["dick"])
async def up_dick(message: types.Message): # рандомайзер async def up_dick(message: types.Message): # рандомайзер
@ -101,9 +115,9 @@ async def up_dick(message: types.Message): # рандомайзер
session.close_all() session.close_all()
print('Успешно добавлен пользователь') print('Успешно добавлен пользователь')
except: except Exception as e:
session.rollback() session.rollback()
print('ошибка в основном коде') print('ошибка в основном коде, трейсбек:' + '\n'.join(traceback.format_tb(e.__traceback__)))
finally: finally:
session.close_all() session.close_all()
@ -120,41 +134,21 @@ 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() top = session.query(user.user_fullname, user.dick_size).order_by(user.dick_size.desc()).filter(user.chat_id == chats).limit(10).all()
# проверка на длину списка, если меньше limit, то: # проверка на длину списка, если меньше limit, то:
sizelen = len(top) size_len = len(top)
if sizelen < 10: if size_len < 10:
lenminus = 10 - sizelen len_minus = 10 - size_len
top.extend(('-'*lenminus)) top.extend(('-'*len_minus))
await bot.send_message(message.chat.id, f'🏆Топ 10 бубылд чата🏆\n\n\ await bot.send_message(message.chat.id, top_dick_message(delimiter, top))
🚀 {delimiter.join(map(str, top[0]))}\n\
💫 {delimiter.join(map(str, top[1]))}\n\
🍆 {delimiter.join(map(str, top[2]))}\n\
🍌 {delimiter.join(map(str, top[3]))}\n\
🐍 {delimiter.join(map(str, top[4]))}\n\
🐎 {delimiter.join(map(str, top[5]))}\n\
🌭 {delimiter.join(map(str, top[6]))}\n\
🌶 {delimiter.join(map(str, top[7]))}\n\
👌 {delimiter.join(map(str, top[8]))}\n\
💩 {delimiter.join(map(str, top[9]))}\n')
session.close() session.close()
# если все нормально и участников минимум 10 # если все нормально и участников минимум 10
else: else:
await bot.send_message(message.chat.id, f'🏆Топ 10 бубылд чата🏆\n\n\ await bot.send_message(message.chat.id, top_dick_message(delimiter, top))
🚀 {delimiter.join(map(str, top[0]))}\n\
💫 {delimiter.join(map(str, top[1]))}\n\
🍆 {delimiter.join(map(str, top[2]))}\n\
🍌 {delimiter.join(map(str, top[3]))}\n\
🐍 {delimiter.join(map(str, top[4]))}\n\
🐎 {delimiter.join(map(str, top[5]))}\n\
🌭 {delimiter.join(map(str, top[6]))}\n\
🌶 {delimiter.join(map(str, top[7]))}\n\
👌 {delimiter.join(map(str, top[8]))}\n\
💩 {delimiter.join(map(str, top[9]))}\n')
except: except:
session.rollback() session.rollback()
print('ошибка в /topdick') print('ошибка в /topdick')
@ -169,22 +163,11 @@ async def send_global_top(message: types.Message):
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()
delimiter = ': ' delimiter = ': '
await bot.send_message(message.chat.id, top_dick_message(delimiter, top_chat))
await bot.send_message(message.chat.id, f'🏆Топ 10 пипис в мире🏆\n\n\
1. {delimiter.join(map(str, top_chat[0]))}\n\
2. {delimiter.join(map(str, top_chat[1]))}\n\
3. {delimiter.join(map(str, top_chat[2]))}\n\
4. {delimiter.join(map(str, top_chat[3]))}\n\
5. {delimiter.join(map(str, top_chat[4]))}\n\
6. {delimiter.join(map(str, top_chat[5]))}\n\
7. {delimiter.join(map(str, top_chat[6]))}\n\
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')
except: except:
session.rollback() session.rollback()
print('ошибка в /glovaldick') print('ошибка в /globaldick')
finally: finally:
session.close_all() session.close_all()