This commit is contained in:
emmatveev 2024-03-31 10:03:04 +03:00
parent 765727f112
commit 426a523a47
2 changed files with 15 additions and 0 deletions

View File

@ -62,6 +62,15 @@ def show_rating(message: Message):
bot.send_message(message.chat.id, text)
@bot.message_handler(commands=['point'])
def show_rating(message: Message):
if not message.reply_to_message:
bot.reply_to(message, 'Чтобы начислить Ебаллы, нужно прописать команду ответом на чье-то сообщение')
username = message.reply_to_message.from_user.username
mongo.inc_points(username, message.chat.id)
bot.reply_to(message.reply_to_message, 'Тебе начислили Ебалл!')
@bot.message_handler()
def do_action(message: Message):
if message.reply_to_message:

View File

@ -35,5 +35,11 @@ class Mongo:
else:
self.counter_collection.insert_one({"chat_id": chat_id, "username": username, "count": 1})
def inc_points(self, username, chat_id):
if self.counter_collection.find_one({"chat_id": chat_id, "username": username}):
self.counter_collection.update_one({"chat_id": chat_id, "username": username}, {"$inc": {"points": 1}})
else:
self.counter_collection.insert_one({"chat_id": chat_id, "username": username, "points": 1})
mongo = Mongo()