File tree Expand file tree Collapse file tree 3 files changed +20
-6
lines changed Expand file tree Collapse file tree 3 files changed +20
-6
lines changed Original file line number Diff line number Diff line change @@ -31,3 +31,7 @@ url = 'http://snekbox:8060/eval' # default url
31
31
32
32
[GITHUB ] # optional
33
33
bot_secret = " "
34
+
35
+ [WEBSERVER ] # optional
36
+ host = " 127.0.0.1"
37
+ port = 2332
Original file line number Diff line number Diff line change @@ -63,12 +63,16 @@ async def main() -> None:
63
63
extension .name ,
64
64
)
65
65
66
- app : Application = Application (bot = bot )
67
- config : uvicorn .Config = uvicorn .Config (app , port = 2332 )
68
- server : uvicorn .Server = uvicorn .Server (config )
69
-
70
- tasks .add (asyncio .create_task (bot .start (core .CONFIG ["TOKENS" ]["bot" ])))
71
- await server .serve ()
66
+ server_config = core .CONFIG .get ("WEBSERVER" )
67
+ if server_config :
68
+ app : Application = Application (bot = bot )
69
+ config : uvicorn .Config = uvicorn .Config (app , host = server_config ["host" ], port = server_config ["port" ])
70
+ server : uvicorn .Server = uvicorn .Server (config )
71
+
72
+ tasks .add (asyncio .create_task (bot .start (core .CONFIG ["TOKENS" ]["bot" ])))
73
+ await server .serve ()
74
+ else :
75
+ await bot .start (core .CONFIG ["TOKENS" ]["bot" ])
72
76
73
77
74
78
try :
Original file line number Diff line number Diff line change @@ -34,6 +34,11 @@ class Suggestions(TypedDict):
34
34
webhook_url : str
35
35
36
36
37
+ class Webserver (TypedDict ):
38
+ host : str
39
+ port : int
40
+
41
+
37
42
class Config (TypedDict ):
38
43
prefix : str
39
44
owner_ids : NotRequired [list [int ]]
@@ -43,3 +48,4 @@ class Config(TypedDict):
43
48
SNEKBOX : NotRequired [Snekbox ]
44
49
BADBIN : BadBin
45
50
SUGGESTIONS : NotRequired [Suggestions ]
51
+ WEBSERVER : NotRequired [Webserver ]
You can’t perform that action at this time.
0 commit comments