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/pyroclient.py

28 lines
826 B
Python
Raw Normal View History

2023-08-03 22:29:47 +03:00
from typing import Union
2023-08-17 16:21:08 +03:00
from libbot.pyrogram.classes import PyroClient as LibPyroClient
2023-08-03 22:29:47 +03:00
from pyrogram.types import User
2023-08-23 16:45:15 +03:00
# PyroClient uses MongoDB implementation of PyroUser
# but you can also select SQLite one below
# from classes.pyrouser_sqlite import PyroUser
from classes.pyrouser_mongo import PyroUser
2023-08-03 22:29:47 +03:00
2023-08-17 16:21:08 +03:00
class PyroClient(LibPyroClient):
2023-08-03 22:29:47 +03:00
async def find_user(self, user: Union[int, User]) -> PyroUser:
2024-01-04 00:21:43 +02:00
"""Find User by its ID or User object.
2023-08-17 16:15:53 +03:00
2023-08-03 22:29:47 +03:00
### Args:
2023-08-18 00:04:38 +03:00
* user (`Union[int, User]`): ID or User object to extract ID from.
2023-08-03 22:29:47 +03:00
### Returns:
2023-08-18 00:04:38 +03:00
* `PyroUser`: User in database representation.
2023-08-03 22:29:47 +03:00
"""
2023-08-17 16:21:08 +03:00
return (
await PyroUser.find(user)
if isinstance(user, int)
else await PyroUser.find(user.id, locale=user.language_code)
2023-08-03 22:29:47 +03:00
)