reformat (black)
This commit is contained in:
14
api.py
14
api.py
@ -6,6 +6,7 @@ from fastapi import FastAPI, HTTPException
|
||||
from pydantic import BaseModel
|
||||
import util
|
||||
|
||||
|
||||
class ValidSendMsgRequest(BaseModel):
|
||||
"""
|
||||
- **guild**: optional, guild id in case multiple channels match (normally first result would be used)
|
||||
@ -17,18 +18,19 @@ class ValidSendMsgRequest(BaseModel):
|
||||
channel: str
|
||||
message: str
|
||||
|
||||
|
||||
class API:
|
||||
"""API [FastAPI Instance] for Havoc"""
|
||||
|
||||
def __init__(self, discord_bot):
|
||||
api_app = FastAPI(title="Havoc API")
|
||||
self.bot = discord_bot
|
||||
self.api_app = api_app
|
||||
|
||||
|
||||
@api_app.get("/{any:path}")
|
||||
def block_get():
|
||||
raise HTTPException(status_code=403, detail="Invalid request")
|
||||
|
||||
|
||||
@api_app.post("/send_msg")
|
||||
async def send_msg_handler(data: ValidSendMsgRequest):
|
||||
await util.discord_helpers.send_message(
|
||||
@ -38,12 +40,14 @@ class API:
|
||||
message=data.message,
|
||||
)
|
||||
return {
|
||||
'result': "presumed_success",
|
||||
"result": "presumed_success",
|
||||
}
|
||||
|
||||
|
||||
|
||||
def __init__():
|
||||
import util
|
||||
|
||||
importlib.reload(util)
|
||||
|
||||
__init__()
|
||||
|
||||
__init__()
|
||||
|
Reference in New Issue
Block a user