mirror of
https://github.com/RYGhub/royalnet.git
synced 2024-11-27 13:34:28 +00:00
Cambia ancora la signature di linker.create
This commit is contained in:
parent
f777f008c5
commit
19a062e482
5 changed files with 16 additions and 8 deletions
|
@ -40,11 +40,11 @@ class LinkerCommand(rc.Command, metaclass=abc.ABCMeta):
|
||||||
await data.session_commit()
|
await data.session_commit()
|
||||||
await data.reply("\n".join(message))
|
await data.reply("\n".join(message))
|
||||||
else:
|
else:
|
||||||
message = ["🔗 Account collegato!\n"]
|
|
||||||
created = await self.create(session=data.session, user=author, args=args, data=data)
|
created = await self.create(session=data.session, user=author, args=args, data=data)
|
||||||
message.append(self.describe(created))
|
|
||||||
await data.session_commit()
|
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:
|
def describe(self, obj: Updatable) -> str:
|
||||||
"""The text that should be appended to the report message for a given Updatable."""
|
"""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,
|
session,
|
||||||
user: rbt.User,
|
user: rbt.User,
|
||||||
args: rc.CommandArgs,
|
args: rc.CommandArgs,
|
||||||
data: Optional[rc.CommandData] = None) -> Updatable:
|
data: Optional[rc.CommandData] = None) -> Optional[Updatable]:
|
||||||
"""Create a new updatable object for a user.
|
"""Create a new updatable object for a user.
|
||||||
|
|
||||||
This function is responsible for adding the object to the session."""
|
This function is responsible for adding the object to the session."""
|
||||||
|
|
|
@ -38,7 +38,7 @@ class BrawlhallaCommand(LinkerCommand):
|
||||||
session,
|
session,
|
||||||
user: rbt.User,
|
user: rbt.User,
|
||||||
args: rc.CommandArgs,
|
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.")
|
raise rc.InvalidInputError("Brawlhalla accounts are automatically linked from Steam.")
|
||||||
|
|
||||||
async def update(self, session, obj, change: Callable[[str, Any], Awaitable[None]]):
|
async def update(self, session, obj, change: Callable[[str, Any], Awaitable[None]]):
|
||||||
|
|
|
@ -37,7 +37,11 @@ class DotaCommand(LinkerCommand):
|
||||||
async def get_updatables(self, session) -> List[Dota]:
|
async def get_updatables(self, session) -> List[Dota]:
|
||||||
return await ru.asyncify(session.query(self.alchemy.get(Steam)).all)
|
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.")
|
raise rc.InvalidInputError("Dota accounts are automatically linked from Steam.")
|
||||||
|
|
||||||
async def update(self, session, obj: Steam, change: Callable[[str, Any], Awaitable[None]]):
|
async def update(self, session, obj: Steam, change: Callable[[str, Any], Awaitable[None]]):
|
||||||
|
|
|
@ -60,7 +60,11 @@ class LeagueoflegendsCommand(LinkerCommand):
|
||||||
async def get_updatables(self, session) -> List[LeagueOfLegends]:
|
async def get_updatables(self, session) -> List[LeagueOfLegends]:
|
||||||
return await ru.asyncify(session.query(self.alchemy.get(LeagueOfLegends)).all)
|
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()
|
name = args.joined()
|
||||||
|
|
||||||
# Connect a new League of Legends account to Royalnet
|
# Connect a new League of Legends account to Royalnet
|
||||||
|
|
|
@ -39,7 +39,7 @@ class SteampoweredCommand(LinkerCommand):
|
||||||
session,
|
session,
|
||||||
user: rbt.User,
|
user: rbt.User,
|
||||||
args: rc.CommandArgs,
|
args: rc.CommandArgs,
|
||||||
data: Optional[rc.CommandData] = None) -> Steam:
|
data: Optional[rc.CommandData] = None) -> Optional[Steam]:
|
||||||
url = args.joined()
|
url = args.joined()
|
||||||
steamid64 = await self._call(steam.steamid.steam64_from_url, url)
|
steamid64 = await self._call(steam.steamid.steam64_from_url, url)
|
||||||
if steamid64 is None:
|
if steamid64 is None:
|
||||||
|
|
Loading…
Reference in a new issue