bugfix p2

This commit is contained in:
codey 2025-02-16 14:12:49 -05:00
parent e3b66624ab
commit 035a52d9b2

View File

@ -2,7 +2,7 @@
import os
import random
from typing import Union, LiteralString
from typing import LiteralString, Optional, Union
import aiosqlite as sqlite3
from fastapi import FastAPI
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"])
async def randmsg_handler(self, data: RandMsgRequest) -> JSONResponse:
async def randmsg_handler(self, data: Optional[RandMsgRequest] = None) -> JSONResponse:
"""
Get a randomly generated message
- **short**: Optional, if True, will limit length of returned random messages to <=126 characters (Discord restriction related)
"""
random.seed()
short: bool = data.short if data.short else False
if not short:
db_rand_selected: int = random.choice([0, 1, 3])
else:
db_rand_selected = 9
short: Optional[bool] = False
if isinstance(data, RandMsgRequest):
short = data.short
db_rand_selected: int = 9
db_rand_selected = random.choice([0, 1, 3])
title_attr: str = "Unknown"
match db_rand_selected: