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

Add api_discord_play endpoint

This commit is contained in:
Steffo 2020-01-10 19:03:14 +01:00
parent a80e94bb83
commit 6514d56519
2 changed files with 20 additions and 0 deletions

View file

@ -6,6 +6,7 @@ from .api_diario_get import ApiDiarioGetStar
from .api_discord_cv import ApiDiscordCvStar from .api_discord_cv import ApiDiscordCvStar
from .api_wiki_get import ApiWikiGetStar from .api_wiki_get import ApiWikiGetStar
from .api_wiki_list import ApiUserListStar from .api_wiki_list import ApiUserListStar
from .api_discord_play import ApiDiscordPlayStar
# Enter the PageStars of your Pack here! # Enter the PageStars of your Pack here!
available_page_stars = [ available_page_stars = [
@ -16,6 +17,7 @@ available_page_stars = [
ApiDiscordCvStar, ApiDiscordCvStar,
ApiWikiGetStar, ApiWikiGetStar,
ApiUserListStar, ApiUserListStar,
ApiDiscordPlayStar,
] ]
# Enter the ExceptionStars of your Pack here! # Enter the ExceptionStars of your Pack here!

View file

@ -0,0 +1,18 @@
from typing import *
from starlette.requests import Request
from starlette.responses import *
from royalnet.constellation import *
from royalnet.utils import *
class ApiDiscordPlayStar(PageStar):
path = "/api/discord/play"
async def page(self, request: Request) -> JSONResponse:
url = request.query_params.get("url", "")
try:
guild_id: Optional[int] = int(request.path_params.get("guild_id", None))
except (ValueError, TypeError):
guild_id = None
response = await self.interface.call_herald_event("discord", "discord_play", url=url, guild_id=guild_id)
return JSONResponse(response)