python_bot/db_logic/tops.py

65 lines
2.3 KiB
Python
Raw Normal View History

2024-01-23 12:45:44 +10:00
from global_conf import CONFIG
from db_logic import collections
import logging
2024-01-23 12:45:44 +10:00
def get_tops(top_ = False, glob_ = False, chat_id = None):
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)
2024-01-23 12:45:44 +10:00
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)
2024-01-23 12:45:44 +10:00
else:
logging.error('вызывают хз что!')
2024-01-23 12:45:44 +10:00
top_dicks = sorted(dicks, key=lambda dick: dick['dick_size'], reverse=True)
top_dicks = top_dicks[:( min(len(top_dicks), 10) )]
dickos = ''
emo = ['🏆','🚀','🍆','🍌','🐍','🐎','🌭','🌶','👌','💩']
if len(top_dicks) > 0:
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
return dickos
2024-06-29 01:36:59 +10:00
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 = ''
2024-06-29 01:47:23 +10:00
emo = ['💩', '😞', '🤕', '😣', '🙁', '😐', '😑', '😶', '😒', '😕']
2024-06-29 01:36:59 +10:00
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