меньше кода - лучше!

This commit is contained in:
Simple_Not 2024-01-23 02:18:50 +10:00
parent e677591b97
commit a58f6c404f
3 changed files with 32 additions and 49 deletions

View File

@ -6,7 +6,7 @@ databaso:
base: pipisa base: pipisa
collection: dicks collection: dicks
telegram_token: 5724991559:AAEuLvpLsgP6LHRGMSyFtQLlR5qPQUO4b_w telegram_token: 6472915685:AAHPvgrQoqG7DxtfbnHWPe3Lfild-CGJ1j8 # 5724991559:AAEuLvpLsgP6LHRGMSyFtQLlR5qPQUO4b_w
telegram_admins_ids: telegram_admins_ids:
- 317051301 # hogweed1 - 317051301 # hogweed1
- 226765676 # blackjack - 226765676 # blackjack

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()
if message['text'] == '/topdick':
top_ = True
try: try:
dicks = dicks_collection.find({'chat_id': message.chat.id}, skip=0, limit=1100) dicks = dicks_collection.find({'chat_id': message.chat.id}, skip=0, limit=1100)
dicks = [d for d in dicks] dicks = [d for d in dicks]
except Exception as e: except Exception as e:
print('ошибка DB в /topdick') print('ошибка DB в /topdick')
print(e) 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
if top_:
await bot.send_message(message.chat.id, '🏆Топ 10 бубылд чата🏆\n\n' + dickos) 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)