This repository has been archived on 2024-10-15. You can view files and clone it, but cannot push or open issues or pull requests.
PyrogramBotBase/classes/pyrouser.py

26 lines
576 B
Python
Raw Normal View History

2023-08-14 16:16:30 +03:00
from dataclasses import dataclass
2023-08-03 22:29:47 +03:00
from typing import Union
from bson import ObjectId
from modules.database import col_users
2023-08-14 16:16:30 +03:00
@dataclass
2023-08-03 22:29:47 +03:00
class PyroUser:
"""Dataclass of DB entry of a user"""
2023-08-14 16:16:30 +03:00
__slots__ = ("_id", "id", "locale")
2023-08-03 22:29:47 +03:00
_id: ObjectId
id: int
locale: Union[str, None]
async def update_locale(self, locale: str) -> None:
"""Change user's locale stored in the database
### Args:
* locale (`str`): New locale to be set
"""
2023-08-14 16:16:30 +03:00
await col_users.update_one({"_id": self._id}, {"$set": {"locale": locale}})