inc
This commit is contained in:
parent
5eed097dfa
commit
0535f5e963
5
mongo.py
5
mongo.py
@ -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()
|
||||
|
Loading…
Reference in New Issue
Block a user