paring
This commit is contained in:
13
main.py
13
main.py
@@ -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()
|
||||
|
||||
Reference in New Issue
Block a user