From 6709eebb880131493e3b6a76efeaf47487a087d5 Mon Sep 17 00:00:00 2001 From: hogweed1 Date: Sat, 29 Jun 2024 01:36:59 +1000 Subject: [PATCH] trying artifitial antitop --- db_logic/tops.py | 31 +++++++++++++++++++++++++++++++ handlers/pipisa.py | 30 ++++++++++++++++++++++++++++++ requairements.txt | 2 +- 3 files changed, 62 insertions(+), 1 deletion(-) diff --git a/db_logic/tops.py b/db_logic/tops.py index 4d5e3a6..56be180 100644 --- a/db_logic/tops.py +++ b/db_logic/tops.py @@ -32,3 +32,34 @@ def get_tops(top_ = False, glob_ = False, chat_id = None): i += 1 return dickos + + +def get_antitops(top_ = False, glob_ = False, chat_id = None): + dicks = [] + if top_: + try: + dicks = [d for d in collections.get_dicks_collection().find({'chat_id': chat_id}, skip=0, limit=1100)] + except Exception as e: + logging.error('ошибка DB в /topdick') + logging.error(e) + elif glob_: + try: + dicks = [d for d in collections.get_dicks_collection().all() if d['user_id'] != d['chat_id']] + except Exception as e: + logging.error('ошибка DB в /globaldick') + logging.error(e) + else: + logging.error('вызывают хз что!') + + antitop_dicks = sorted(dicks, key=lambda dick: dick['dick_size'], reverse=False) + antitop_dicks = antitop_dicks[:( min(len(antitop_dicks), 10) )] + + dickos = '' + emo = ['🏆','🚀','🍆','🍌','🐍','🐎','🌭','🌶','👌','💩'] + + if len(antitop_dicks) > 0: + for i in range(len(antitop_dicks)): + dickos += f' {emo[i]} {i+1}. {antitop_dicks[i]["user_fullname"]}: {antitop_dicks[i]["dick_size"]}см\n' + i += 1 + + return dickos \ No newline at end of file diff --git a/handlers/pipisa.py b/handlers/pipisa.py index f5d50e2..229d91b 100644 --- a/handlers/pipisa.py +++ b/handlers/pipisa.py @@ -99,6 +99,36 @@ async def send_topchat(message: types.Message): 'Вы можете посмотреть топ по миру /globaldick') +@dp.message_handler(commands = ['antitopdick', 'antiglobaldick']) +async def send_antitopchat(message: types.Message): + if message.from_user.id in admins or message.chat.type != 'private': + antitop_ = message['text'].startswith('/antitopdick') + antiglob_ = message['text'].startswith('/antiglobaldick') + + if antitop_: + dickos = tops.get_antitops(top_=True, chat_id=message.chat.id) + postcleaner.append_post_to_cleaning_sequence(message=message, type=f'COMMAND_CALL__ANTITOPDICK') + await clean_posts(chat_id=message.chat.id, type='COMMAND_CALL__ANTITOPDICK', max_id=message.message_id) + elif antiglob_: + dickos = tops.get_antitops(glob_=True) + postcleaner.append_post_to_cleaning_sequence(message=message, type=f'COMMAND_CALL__ANTIGLOBALDICK') + await clean_posts(chat_id=message.chat.id, type='COMMAND_CALL__ANTIGLOBALDICK', max_id=message.message_id) + else: + logging.error('вызывают хз что!') + + if not dickos: + await bot.send_message(message.chat.id, '🍌 У всех пользователей бубылда растёт! 🍆') + else: + if antitop_: + await bot.send_message(message.chat.id, '🚫Антитоп 10 бубылд чата🚫\n\n' + dickos) + elif antiglob_: + await bot.send_message(message.chat.id, '🚫Антитоп 10 пипис в мире🚫\n\n' + dickos) + else: + await message.reply('Работает только в общих чатах!\n'\ + 'Вы можете посмотреть антитоп по миру /antiglobaldick') + + + async def clean_posts(chat_id, type=None, max_id=None): psts = postcleaner.get_posts_to_be_removed(chat_id, type, max_id) diff --git a/requairements.txt b/requairements.txt index eb4a969..5fbc629 100644 --- a/requairements.txt +++ b/requairements.txt @@ -1,3 +1,3 @@ -aiogram +aiogram==2.15 python-arango pyyaml \ No newline at end of file