Skip to content

Commit 496e69a

Browse files
committed
git push Merge remote-tracking branch 'template/dev' into dev
2 parents 7b274fa + 5c464a8 commit 496e69a

File tree

2 files changed

+17
-6
lines changed

2 files changed

+17
-6
lines changed

src/config/models.py

Lines changed: 11 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -40,13 +40,23 @@ def __bool__(self) -> bool:
4040
return self.enabled
4141

4242

43+
class RestConfig(BaseModel):
44+
enabled: bool = False
45+
health: bool = False
46+
host: str = "0.0.0.0" # noqa: S104
47+
port: int = 6000
48+
49+
def __bool__(self) -> bool:
50+
return self.enabled
51+
52+
4353
class BotConfig(BaseModel):
4454
token: str
4555
public_key: str | None = None
4656
prefix: PrefixConfig | str = PrefixConfig(prefix="!", enabled=False)
4757
slash: SlashConfig = SlashConfig(enabled=False)
4858
cache: CacheConfig = CacheConfig()
49-
rest: bool = False
59+
rest: RestConfig = RestConfig()
5060

5161

5262
class LoggingConfig(BaseModel):

src/start.py

Lines changed: 6 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -16,7 +16,7 @@
1616

1717
from src import custom, i18n
1818
from src.config import config
19-
from src.config.models import BotConfig, Extension
19+
from src.config.models import BotConfig, Extension, RestConfig
2020
from src.i18n.classes import ExtensionTranslation
2121
from src.log import logger, patch
2222
from src.utils import setup_func, unzip_extensions, validate_module
@@ -28,17 +28,18 @@
2828
FunctionlistType = list[tuple[Callable[..., Any], Extension]]
2929

3030

31-
async def start_bot(bot: custom.Bot, token: str, public_key: str | None = None) -> None:
31+
async def start_bot(bot: custom.Bot, token: str, rest_config: RestConfig, public_key: str | None = None) -> None:
3232
try:
3333
if isinstance(bot, custom.CustomRestBot):
3434
if not public_key:
3535
raise TypeError("CustomRestBot requires a public key to start.") # noqa: TRY301
3636
await bot.start(
3737
token=token,
3838
public_key=public_key,
39+
health=rest_config.health,
3940
uvicorn_options={
40-
"host": "0.0.0.0", # noqa: S104
41-
"port": 6000,
41+
"host": rest_config.host,
42+
"port": rest_config.port,
4243
},
4344
)
4445
else:
@@ -172,7 +173,7 @@ async def setup_and_start_bot(
172173
bot.prefixed_commands = {}
173174
if not config.slash:
174175
bot._pending_application_commands = [] # pyright: ignore[reportPrivateUsage]
175-
await start_bot(bot, config.token, config.public_key)
176+
await start_bot(bot, config.token, config.rest, config.public_key)
176177

177178

178179
async def setup_and_start_backend(

0 commit comments

Comments
 (0)