This commit is contained in:
Administrator 2023-01-20 19:08:34 +03:00
parent 5eed097dfa
commit 0535f5e963

View File

@ -30,7 +30,10 @@ class Mongo:
return self["counter"]
def inc(self, username, chat_id):
self.counter_collection.update_one({"chat_id": chat_id, "username": username}, {"$inc": {"count": 1}})
if self.counter_collection.find_one({"chat_id": chat_id, "username": username}):
self.counter_collection.update_one({"chat_id": chat_id, "username": username}, {"$inc": {"count": 1}})
else:
self.counter_collection.insert_one({"chat_id": chat_id, "username": username, "count": 1})
mongo = Mongo()