from global_conf import CONFIG from db_logic import collections 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: print('ошибка DB в /topdick') print(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: print('ошибка DB в /globaldick') print(e) else: print('вызывают хз что!') 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