bugfix p2
This commit is contained in:
parent
e3b66624ab
commit
035a52d9b2
@ -2,7 +2,7 @@
|
|||||||
|
|
||||||
import os
|
import os
|
||||||
import random
|
import random
|
||||||
from typing import Union, LiteralString
|
from typing import LiteralString, Optional, Union
|
||||||
import aiosqlite as sqlite3
|
import aiosqlite as sqlite3
|
||||||
from fastapi import FastAPI
|
from fastapi import FastAPI
|
||||||
from fastapi.responses import JSONResponse
|
from fastapi.responses import JSONResponse
|
||||||
@ -21,18 +21,17 @@ class RandMsg(FastAPI):
|
|||||||
|
|
||||||
app.add_api_route(f"/{self.endpoint_name}", self.randmsg_handler, methods=["POST"])
|
app.add_api_route(f"/{self.endpoint_name}", self.randmsg_handler, methods=["POST"])
|
||||||
|
|
||||||
async def randmsg_handler(self, data: RandMsgRequest) -> JSONResponse:
|
async def randmsg_handler(self, data: Optional[RandMsgRequest] = None) -> JSONResponse:
|
||||||
"""
|
"""
|
||||||
Get a randomly generated message
|
Get a randomly generated message
|
||||||
- **short**: Optional, if True, will limit length of returned random messages to <=126 characters (Discord restriction related)
|
- **short**: Optional, if True, will limit length of returned random messages to <=126 characters (Discord restriction related)
|
||||||
"""
|
"""
|
||||||
random.seed()
|
random.seed()
|
||||||
short: bool = data.short if data.short else False
|
short: Optional[bool] = False
|
||||||
|
if isinstance(data, RandMsgRequest):
|
||||||
if not short:
|
short = data.short
|
||||||
db_rand_selected: int = random.choice([0, 1, 3])
|
db_rand_selected: int = 9
|
||||||
else:
|
db_rand_selected = random.choice([0, 1, 3])
|
||||||
db_rand_selected = 9
|
|
||||||
title_attr: str = "Unknown"
|
title_attr: str = "Unknown"
|
||||||
|
|
||||||
match db_rand_selected:
|
match db_rand_selected:
|
||||||
|
Loading…
x
Reference in New Issue
Block a user