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

25 lines
678 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
from classes.pyrouser import PyroUser
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:
2023-08-17 16:15:53 +03:00
"""Find User by it's ID or User object.
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
)