From 93933fd8f54748809592ba3c5445ce39ffe09a91 Mon Sep 17 00:00:00 2001 From: Luna Mendes Date: Fri, 6 Jul 2018 16:07:42 -0300 Subject: [PATCH] add empty webhooks blueprint --- litecord/blueprints/__init__.py | 1 + litecord/blueprints/webhooks.py | 66 +++++++++++++++++++++++++++++++++ litecord/gateway/websocket.py | 2 + run.py | 3 +- 4 files changed, 71 insertions(+), 1 deletion(-) create mode 100644 litecord/blueprints/webhooks.py diff --git a/litecord/blueprints/__init__.py b/litecord/blueprints/__init__.py index 5847c66..dd9488e 100644 --- a/litecord/blueprints/__init__.py +++ b/litecord/blueprints/__init__.py @@ -3,3 +3,4 @@ from .auth import bp as auth from .users import bp as users from .guilds import bp as guilds from .channels import bp as channels +from .webhooks import bp as webhooks diff --git a/litecord/blueprints/webhooks.py b/litecord/blueprints/webhooks.py new file mode 100644 index 0000000..64a13f9 --- /dev/null +++ b/litecord/blueprints/webhooks.py @@ -0,0 +1,66 @@ +from quart import Blueprint + +bp = Blueprint('webhooks', __name__) + + +@bp.route('/channels//webhooks', methods=['POST']) +async def create_webhook(channel_id): + pass + + +@bp.route('/channels//webhooks', methods=['GET']) +async def get_channel_webhook(channel_id): + pass + + +@bp.route('/guilds//webhooks', methods=['GET']) +async def get_guild_webhook(guild_id): + pass + + +@bp.route('/webhooks/', methods=['GET']) +async def get_single_webhook(webhook_id): + pass + + +@bp.route('/webhooks//', methods=['GET']) +async def get_tokened_webhook(webhook_id, webhook_token): + pass + + +@bp.route('/webhooks/', methods=['PATCH']) +async def modify_webhook(webhook_id): + pass + + +@bp.route('/webhooks//', methods=['PATCH']) +async def modify_webhook_tokened(webhook_id, webhook_token): + pass + + +@bp.route('/webhooks/', methods=['DELETE']) +async def del_webhook(webhook_id): + pass + + +@bp.route('/webhooks//', methods=['DELETE']) +async def del_webhook_tokened(webhook_id, webhook_token): + pass + + +@bp.route('/webhooks//', methods=['POST']) +async def execute_webhook(webhook_id, webhook_token): + pass + + +@bp.route('/webhooks///slack', + methods=['POST']) +async def execute_slack_webhook(webhook_id, webhook_token): + pass + + +@bp.route('/webhooks///github', + methods=['POST']) +async def execute_github_webhook(webhook_id, webhook_token): + pass + diff --git a/litecord/gateway/websocket.py b/litecord/gateway/websocket.py index c849c54..b758968 100644 --- a/litecord/gateway/websocket.py +++ b/litecord/gateway/websocket.py @@ -401,5 +401,7 @@ class GatewayWebsocket: log.exception('An exception has occoured. state={}', self.state) await self.ws.close(code=4000, reason=repr(err)) finally: + self.ext.state_manager.remove(self) + if self.state: self.state.ws = None diff --git a/run.py b/run.py index 10c3c52..a9d081f 100644 --- a/run.py +++ b/run.py @@ -10,7 +10,7 @@ from logbook import StreamHandler, Logger from logbook.compat import redirect_logging import config -from litecord.blueprints import gateway, auth, users, guilds, channels +from litecord.blueprints import gateway, auth, users, guilds, channels, webhooks from litecord.gateway import websocket_handler from litecord.errors import LitecordError from litecord.gateway.state_manager import StateManager @@ -43,6 +43,7 @@ app.register_blueprint(auth, url_prefix='/api/v6') app.register_blueprint(users, url_prefix='/api/v6/users') app.register_blueprint(guilds, url_prefix='/api/v6/guilds') app.register_blueprint(channels, url_prefix='/api/v6/channels') +app.register_blueprint(webhooks, url_prefix='/api/v6') @app.before_serving