mirror of
https://github.com/langbot-app/LangBot.git
synced 2026-07-20 19:36:08 +00:00
feat: 支持 ctrl+c 退出
This commit is contained in:
+1
-3
@@ -65,8 +65,6 @@ class Application:
|
|||||||
async def initialize(self):
|
async def initialize(self):
|
||||||
pass
|
pass
|
||||||
|
|
||||||
# async def wait_loop(self):
|
|
||||||
|
|
||||||
async def run(self):
|
async def run(self):
|
||||||
await self.plugin_mgr.load_plugins()
|
await self.plugin_mgr.load_plugins()
|
||||||
await self.plugin_mgr.initialize_plugins()
|
await self.plugin_mgr.initialize_plugins()
|
||||||
@@ -83,7 +81,7 @@ class Application:
|
|||||||
|
|
||||||
async def interrupt(tasks):
|
async def interrupt(tasks):
|
||||||
await asyncio.sleep(1.5)
|
await asyncio.sleep(1.5)
|
||||||
while await aioconsole.ainput("使用 exit 退出程序 > ") != 'exit':
|
while await aioconsole.ainput("使用 ctrl+c 或 'exit' 退出程序 > ") != 'exit':
|
||||||
pass
|
pass
|
||||||
for task in tasks:
|
for task in tasks:
|
||||||
task.cancel()
|
task.cancel()
|
||||||
|
|||||||
@@ -207,6 +207,12 @@ class AiocqhttpAdapter(adapter.MessageSourceAdapter):
|
|||||||
|
|
||||||
def __init__(self, config: dict, ap: app.Application):
|
def __init__(self, config: dict, ap: app.Application):
|
||||||
self.config = config
|
self.config = config
|
||||||
|
|
||||||
|
async def shutdown_trigger_placeholder():
|
||||||
|
return None
|
||||||
|
|
||||||
|
self.config['shutdown_trigger'] = shutdown_trigger_placeholder
|
||||||
|
|
||||||
self.ap = ap
|
self.ap = ap
|
||||||
|
|
||||||
self.bot = aiocqhttp.CQHttp()
|
self.bot = aiocqhttp.CQHttp()
|
||||||
|
|||||||
Reference in New Issue
Block a user