diff --git a/dashboard/baserpc.py b/dashboard/baserpc.py index 90874c52..bf3c4e97 100644 --- a/dashboard/baserpc.py +++ b/dashboard/baserpc.py @@ -17,6 +17,7 @@ from .rpc.permissions import DashboardRPC_Permissions from .rpc.utils import rpccheck from .rpc.webhooks import DashboardRPC_Webhooks +from .rpc.oauth import DashboardRPC_OAuth HUMANIZED_PERMISSIONS = { "view": "View server on dashboard", @@ -50,6 +51,7 @@ def __init__(self, cog: commands.Cog): self.extensions.append(DashboardRPC_Permissions(self.cog)) self.extensions.append(DashboardRPC_AliasCC(self.cog)) self.extensions.append(DashboardRPC_Webhooks(self.cog)) + self.extensions.append(DashboardRPC_OAuth(self.cog)) # To make sure that both RPC server and client are on the same "version" self.version = random.randint(1, 10000) diff --git a/dashboard/rpc/oauth.py b/dashboard/rpc/oauth.py new file mode 100644 index 00000000..f35ffb9c --- /dev/null +++ b/dashboard/rpc/oauth.py @@ -0,0 +1,20 @@ +from redbot.core.bot import Red +from redbot.core.commands import commands + +from .utils import rpccheck + + +class DashboardRPC_OAuth: + def __init__(self, cog: commands.Cog): + self.bot: Red = cog.bot + self.cog: commands.Cog = cog + + self.bot.register_rpc_handler(self.oauth_receive) + + def unload(self): + self.bot.unregister_rpc_handler(self.oauth_receive) + + @rpccheck() + async def oauth_receive(self, user_id: int, payload: dict) -> dict: + self.bot.dispatch("oauth_receive", user_id, payload) + return {"status": 1}