Replaced logger
This commit is contained in:
parent
32c7ec7d44
commit
6015592df5
@ -1,4 +1,5 @@
|
|||||||
from datetime import datetime, timezone
|
from datetime import datetime, timezone
|
||||||
|
import logging
|
||||||
from random import randint
|
from random import randint
|
||||||
from typing import Union, Any
|
from typing import Union, Any
|
||||||
import discord
|
import discord
|
||||||
@ -11,6 +12,8 @@ try:
|
|||||||
except ImportError:
|
except ImportError:
|
||||||
from typing_extensions import Literal
|
from typing_extensions import Literal
|
||||||
|
|
||||||
|
logger = logging.getLogger(__name__)
|
||||||
|
|
||||||
|
|
||||||
class NotEnoughMoneyError(Exception):
|
class NotEnoughMoneyError(Exception):
|
||||||
"""User does not have enough money to do that"""
|
"""User does not have enough money to do that"""
|
||||||
@ -182,7 +185,7 @@ class HoloUser:
|
|||||||
)
|
)
|
||||||
else:
|
else:
|
||||||
col_warnings.insert_one(document={"user": self.id, "warns": count})
|
col_warnings.insert_one(document={"user": self.id, "warns": count})
|
||||||
logWrite(f"User {self.id} was warned {count} times due to: {reason}")
|
logger.info(f"User {self.id} was warned {count} times due to: {reason}")
|
||||||
|
|
||||||
# def cooldown_go(self, kind: Literal["work", "daily", "weekly", "monthly", "steal"]) -> None:
|
# def cooldown_go(self, kind: Literal["work", "daily", "weekly", "monthly", "steal"]) -> None:
|
||||||
# """Set cooldown start of kind now
|
# """Set cooldown start of kind now
|
||||||
@ -206,16 +209,16 @@ class HoloUser:
|
|||||||
col_users.update_one(
|
col_users.update_one(
|
||||||
filter={"_id": self.db_id}, update={"$set": {key: value}}, upsert=True
|
filter={"_id": self.db_id}, update={"$set": {key: value}}, upsert=True
|
||||||
)
|
)
|
||||||
logWrite(f"Set attribute {key} of user {self.id} to {value}")
|
logger.info(f"Set attribute {key} of user {self.id} to {value}")
|
||||||
|
|
||||||
def purge(self) -> None:
|
# def purge(self) -> None:
|
||||||
"""Completely remove data from database. Will not remove transactions logs and warnings."""
|
# """Completely remove data from database. Will not remove transactions logs and warnings."""
|
||||||
col_users.delete_one(filter={"_id": self.db_id})
|
# col_users.delete_one(filter={"_id": self.db_id})
|
||||||
self.unauthorize()
|
# self.unauthorize()
|
||||||
|
|
||||||
def unauthorize(self) -> None:
|
# def unauthorize(self) -> None:
|
||||||
"""Cancel Oauth2 authorization"""
|
# """Cancel Oauth2 authorization"""
|
||||||
col_authorized.find_one_and_delete({"user": self.id})
|
# col_authorized.find_one_and_delete({"user": self.id})
|
||||||
|
|
||||||
# def is_authorized(self) -> bool:
|
# def is_authorized(self) -> bool:
|
||||||
# """Check if user provided Oauth2 authorization
|
# """Check if user provided Oauth2 authorization
|
||||||
|
Loading…
Reference in New Issue
Block a user