This commit is contained in:
Administrator
2023-01-20 18:53:07 +03:00
parent 59d670db82
commit 5eed097dfa
2 changed files with 24 additions and 0 deletions

13
main.py
View File

@@ -64,6 +64,18 @@ def set_probability(message: Message):
set_values(message.chat.id, state="set_probability")
@bot.message_handler(commands=['rating'])
def set_probability(message: Message):
rating = list(mongo.counter_collection.find({"chat_id": message.chat.id}).sort("count", -1))
if not rating:
bot.send_message(message.chat.id, "В этом чате я пока никому не парировал")
return
text = "Вот кому я парировал:\n"
for index, value in enumerate(rating):
text += f"{index + 1}. @{value['username']} - {value['count']}\n"
bot.send_message(message.chat.id, text)
@bot.message_handler()
def do_action(message: Message):
info = get_chat_info(message.chat.id)
@@ -102,6 +114,7 @@ def do_action(message: Message):
ans = "Хуй на!"
if ans is not None and randrange(1, 101) <= info["probability"]:
bot.reply_to(message, ans)
mongo.inc(message.from_user.username, message.chat.id)
bot.polling()