Compare commits

..

2 Commits

Author SHA1 Message Date
Simple_Not
ecbe419abb меньше кода - лучше!
All checks were successful
continuous-integration/drone/push Build is passing
2024-01-23 02:19:06 +10:00
Simple_Not
a58f6c404f меньше кода - лучше! 2024-01-23 02:18:50 +10:00
2 changed files with 31 additions and 48 deletions

View File

@ -4,7 +4,7 @@ import random
def ChangeWord(result): #выбирает рандомное слово для изменения размера пиписы def ChangeWord(result): #выбирает рандомное слово для изменения размера пиписы
with open("dicktxt/dick_changes.yaml", 'r') as f: with open("dicktxt/dick_changes.yaml", 'r', encoding='utf-8') as f:
words = yaml.load(f, Loader=yaml.Loader) words = yaml.load(f, Loader=yaml.Loader)
dick_inc = [ f'<b>{w}</b>' for w in words['increment'] ] dick_inc = [ f'<b>{w}</b>' for w in words['increment'] ]

View File

@ -153,20 +153,34 @@ async def up_dick(message: types.Message):
@dp.message_handler(commands=["topdick"]) @dp.message_handler(commands=['topdick','globaldick'])
async def send_topchat(message: types.Message): async def send_topchat(message: types.Message):
if message.from_user.id in admins or message.chat.type != 'private': if message.from_user.id in admins or message.chat.type != 'private':
top_ = False
glob_ = False
dicks_collection = get_dicks_collection() dicks_collection = get_dicks_collection()
try:
dicks = dicks_collection.find({'chat_id': message.chat.id}, skip=0, limit=1100) if message['text'] == '/topdick':
dicks = [d for d in dicks] top_ = True
except Exception as e: try:
print('ошибка DB в /topdick') dicks = dicks_collection.find({'chat_id': message.chat.id}, skip=0, limit=1100)
print(e) dicks = [d for d in dicks]
except Exception as e:
print('ошибка DB в /topdick')
print(e)
elif message['text'] == '/globaldick':
glob_ = True
try:
dicks = dicks_collection.all( )
dicks = [d for d in dicks if d['user_id'] != d['chat_id']]
except Exception as e:
print('ошибка DB в /globaldick')
print(e)
else:
print('вызывают хз что!')
top_dicks = sorted(dicks, key=lambda dick: dick['dick_size'], reverse=True) top_dicks = sorted(dicks, key=lambda dick: dick['dick_size'], reverse=True)
dick_limit = min(len(top_dicks), 10) dick_limit = min(len(top_dicks), 10)
top_dicks = top_dicks[:dick_limit] top_dicks = top_dicks[:dick_limit]
@ -180,41 +194,10 @@ async def send_topchat(message: types.Message):
dickos += f' {emo[i]} {i+1}. {top_dicks[i]["user_fullname"]}: {top_dicks[i]["dick_size"]}см\n' dickos += f' {emo[i]} {i+1}. {top_dicks[i]["user_fullname"]}: {top_dicks[i]["dick_size"]}см\n'
i += 1 i += 1
await bot.send_message(message.chat.id, '🏆Топ 10 бубылд чата🏆\n\n' + dickos) if top_:
await bot.send_message(message.chat.id, '🏆Топ 10 бубылд чата🏆\n\n' + dickos)
elif glob_:
await bot.send_message(message.chat.id, '🏆Топ 10 пипис в мире🏆\n\n' + dickos)
else: else:
await message.reply('Работает только в общих чатах!\n'\ await message.reply('Работает только в общих чатах!\n'\
'Вы мсжете посмотреть топ по миру /globaldick') 'Вы можете посмотреть топ по миру /globaldick')
@dp.message_handler(commands=["globaldick"])
async def send_global_top(message: types.Message):
dicks_collection = get_dicks_collection()
try:
dicks = dicks_collection.all( )
dicks = [d for d in dicks if d['user_id'] != d['chat_id']]
except Exception as e:
print('ошибка DB в /glovaldick')
print(e)
top_dicks = sorted(dicks, key=lambda dick: dick['dick_size'], reverse=True)
dick_limit = min(len(top_dicks), 10)
top_dicks = top_dicks[:dick_limit]
dickos = ''
emo = ['🏆','🚀','💫','🍆','🍌','🐍','🐎','🌭','🌶','👌']
if len(top_dicks) == 0:
await bot.send_message(message.chat.id, '🍆 Никто ничего не нарастил! 🍌')
else:
for i in range(len(top_dicks)):
dickos += f' {emo[i]} {i+1}. {top_dicks[i]["user_fullname"]}: {top_dicks[i]["dick_size"]}см\n'
i += 1
await bot.send_message(message.chat.id, '🏆Топ 10 пипис в мире🏆\n\n' + dickos)