From 19a062e482dd7146e5cf1f08b34a84fd914eaa51 Mon Sep 17 00:00:00 2001 From: Stefano Pigozzi Date: Tue, 21 Jul 2020 23:15:22 +0200 Subject: [PATCH] Cambia ancora la signature di linker.create --- royalpack/commands/abstract/linker.py | 8 ++++---- royalpack/commands/brawlhalla.py | 2 +- royalpack/commands/dota.py | 6 +++++- royalpack/commands/leagueoflegends.py | 6 +++++- royalpack/commands/steampowered.py | 2 +- 5 files changed, 16 insertions(+), 8 deletions(-) diff --git a/royalpack/commands/abstract/linker.py b/royalpack/commands/abstract/linker.py index ce3537ae..198df1f8 100644 --- a/royalpack/commands/abstract/linker.py +++ b/royalpack/commands/abstract/linker.py @@ -40,11 +40,11 @@ class LinkerCommand(rc.Command, metaclass=abc.ABCMeta): await data.session_commit() await data.reply("\n".join(message)) else: - message = ["🔗 Account collegato!\n"] created = await self.create(session=data.session, user=author, args=args, data=data) - message.append(self.describe(created)) await data.session_commit() - await data.reply("\n".join(message)) + if created is not None: + message = ["🔗 Account collegato!", "", self.describe(created)] + await data.reply("\n".join(message)) def describe(self, obj: Updatable) -> str: """The text that should be appended to the report message for a given Updatable.""" @@ -65,7 +65,7 @@ class LinkerCommand(rc.Command, metaclass=abc.ABCMeta): session, user: rbt.User, args: rc.CommandArgs, - data: Optional[rc.CommandData] = None) -> Updatable: + data: Optional[rc.CommandData] = None) -> Optional[Updatable]: """Create a new updatable object for a user. This function is responsible for adding the object to the session.""" diff --git a/royalpack/commands/brawlhalla.py b/royalpack/commands/brawlhalla.py index f7dfcb95..a4d2939b 100644 --- a/royalpack/commands/brawlhalla.py +++ b/royalpack/commands/brawlhalla.py @@ -38,7 +38,7 @@ class BrawlhallaCommand(LinkerCommand): session, user: rbt.User, args: rc.CommandArgs, - data: Optional[rc.CommandData] = None) -> Brawlhalla: + data: Optional[rc.CommandData] = None) -> Optional[Brawlhalla]: raise rc.InvalidInputError("Brawlhalla accounts are automatically linked from Steam.") async def update(self, session, obj, change: Callable[[str, Any], Awaitable[None]]): diff --git a/royalpack/commands/dota.py b/royalpack/commands/dota.py index e394ecbb..917285e6 100644 --- a/royalpack/commands/dota.py +++ b/royalpack/commands/dota.py @@ -37,7 +37,11 @@ class DotaCommand(LinkerCommand): async def get_updatables(self, session) -> List[Dota]: return await ru.asyncify(session.query(self.alchemy.get(Steam)).all) - async def create(self, session, user: rbt.User, args: rc.CommandArgs, data: Optional[rc.CommandData] = None): + async def create(self, + session, + user: rbt.User, + args: rc.CommandArgs, + data: Optional[rc.CommandData] = None) -> Optional[Dota]: raise rc.InvalidInputError("Dota accounts are automatically linked from Steam.") async def update(self, session, obj: Steam, change: Callable[[str, Any], Awaitable[None]]): diff --git a/royalpack/commands/leagueoflegends.py b/royalpack/commands/leagueoflegends.py index 40844eff..0925a9fb 100644 --- a/royalpack/commands/leagueoflegends.py +++ b/royalpack/commands/leagueoflegends.py @@ -60,7 +60,11 @@ class LeagueoflegendsCommand(LinkerCommand): async def get_updatables(self, session) -> List[LeagueOfLegends]: return await ru.asyncify(session.query(self.alchemy.get(LeagueOfLegends)).all) - async def create(self, session, user: rbt.User, args: rc.CommandArgs, data: Optional[rc.CommandData] = None) -> LeagueOfLegends: + async def create(self, + session, + user: rbt.User, + args: rc.CommandArgs, + data: Optional[rc.CommandData] = None) -> Optional[LeagueOfLegends]: name = args.joined() # Connect a new League of Legends account to Royalnet diff --git a/royalpack/commands/steampowered.py b/royalpack/commands/steampowered.py index eb44b7c0..662c61c7 100644 --- a/royalpack/commands/steampowered.py +++ b/royalpack/commands/steampowered.py @@ -39,7 +39,7 @@ class SteampoweredCommand(LinkerCommand): session, user: rbt.User, args: rc.CommandArgs, - data: Optional[rc.CommandData] = None) -> Steam: + data: Optional[rc.CommandData] = None) -> Optional[Steam]: url = args.joined() steamid64 = await self._call(steam.steamid.steam64_from_url, url) if steamid64 is None: