меньше кода - лучше!

This commit is contained in:
Simple_Not
2024-01-23 13:29:31 +10:00
parent 9d6d8791fd
commit 14c238ec2f
2 changed files with 12 additions and 15 deletions

View File

@@ -4,7 +4,7 @@ from db_logic import collections
import datetime
def store_new_user(dicks_collection, message, result ):
def store_new_user(message, result ):
try:
novenkiy = {
@@ -15,7 +15,7 @@ def store_new_user(dicks_collection, message, result ):
'attempts': 1,
'chat_id': message.chat.id
}
metadata = dicks_collection.insert(novenkiy, overwrite_mode='update')
metadata = collections.get_dicks_collection().insert(novenkiy, overwrite_mode='update')
print(f'Успешно добавлен нового пользователь @{message.from_user.username}')
except Exception as e2:
@@ -23,9 +23,9 @@ def store_new_user(dicks_collection, message, result ):
print(e2)
def update_attempts(dicks_collection, message, user ):
def update_attempts(message, user ):
try:
metadata = dicks_collection.insert(
metadata = collections.get_dicks_collection().insert(
{
'_key': user['_key'], ### этот нужен чтобы апдейт прилетал тому же юзеру
'user_id': user['user_id'] ,
@@ -43,10 +43,10 @@ def update_attempts(dicks_collection, message, user ):
print(e2)
def update_dick_size(dicks_collection, message, user, updatedDick ):
def update_dick_size(message, user, updatedDick ):
try:
metadata = dicks_collection.insert(
metadata = collections.get_dicks_collection().insert(
{
'_key': user['_key'], ### этот нужен чтобы апдейт прилетал тому же юзеру
'user_id': user['user_id'],
@@ -64,10 +64,10 @@ def update_dick_size(dicks_collection, message, user, updatedDick ):
print(e2)
def get_user(dicks_collection, message):
def get_user(message):
try:
#### Чекнуть есть ли юзер в базе
candidate_cursor = dicks_collection.find(
candidate_cursor = collections.get_dicks_collection().find(
{
'user_id': message.from_user.id,
'chat_id': message.chat.id