1
Fork 0
mirror of https://github.com/RYGhub/royalnet.git synced 2024-11-23 11:34:18 +00:00

Fix find_user bug

This commit is contained in:
Steffo 2020-08-23 23:20:45 +02:00
parent b2988d9c2e
commit dbc58f7ff1
2 changed files with 11 additions and 10 deletions

View file

@ -5,7 +5,7 @@
[tool.poetry] [tool.poetry]
name = "royalnet" name = "royalnet"
version = "5.11.2" version = "5.11.3"
description = "A multipurpose bot and web framework" description = "A multipurpose bot and web framework"
authors = ["Stefano Pigozzi <ste.pigozzi@gmail.com>"] authors = ["Stefano Pigozzi <ste.pigozzi@gmail.com>"]
license = "AGPL-3.0+" license = "AGPL-3.0+"

View file

@ -8,17 +8,18 @@ from .errors import UnsupportedError
if TYPE_CHECKING: if TYPE_CHECKING:
from .keyboardkey import KeyboardKey from .keyboardkey import KeyboardKey
from .command import Command
log = logging.getLogger(__name__) log = logging.getLogger(__name__)
class CommandData: class CommandData:
def __init__(self, command): def __init__(self, command: "Command"):
self.command = command self.command: "Command" = command
@property @property
def loop(self): def loop(self):
return self.command.serf.loop return self.command.loop
@property @property
def alchemy(self): def alchemy(self):
@ -53,7 +54,7 @@ class CommandData:
error_if_none: Raise an exception if this is True and the call has no author.""" error_if_none: Raise an exception if this is True and the call has no author."""
raise UnsupportedError(f"'{self.get_author.__name__}' is not supported") raise UnsupportedError(f"'{self.get_author.__name__}' is not supported")
async def delete_invoking(self, error_if_unavailable=False) -> None: async def delete_invoking(self, error_if_unavailable: bool = False) -> None:
"""Delete the invoking message, if supported by the interface. """Delete the invoking message, if supported by the interface.
The invoking message is the message send by the user that contains the command. The invoking message is the message send by the user that contains the command.
@ -63,13 +64,13 @@ class CommandData:
if error_if_unavailable: if error_if_unavailable:
raise UnsupportedError(f"'{self.delete_invoking.__name__}' is not supported") raise UnsupportedError(f"'{self.delete_invoking.__name__}' is not supported")
async def find_user(self, alias: str) -> Optional["User"]: async def find_user(self, identifier: Union[str, int], *, session) -> Optional["User"]:
"""Find the User having a specific Alias. """Find the User having a specific identifier.
Parameters: Parameters:
alias: the Alias to search for.""" identifier: the identifier to search for.
async with self.command.alchemy.session_acm() as session: session: the session that the user should be returned from"""
return await User.find(self.command.serf.alchemy, session, alias) return await User.find(alchemy=self.alchemy, session=session, identifier=identifier)
@contextlib.asynccontextmanager @contextlib.asynccontextmanager
async def keyboard(self, text, keys: List["KeyboardKey"]): async def keyboard(self, text, keys: List["KeyboardKey"]):