mirror of
https://github.com/xuthus83/LittlePaimon.git
synced 2024-10-21 16:27:15 +08:00
🐛 修复安装了某些nb插件时重启
命令报错问题#390
This commit is contained in:
parent
437048cfed
commit
c59b0fad67
@ -1,5 +1,6 @@
|
|||||||
import os
|
import os
|
||||||
import asyncio
|
import asyncio
|
||||||
|
import contextlib
|
||||||
import random
|
import random
|
||||||
import sys
|
import sys
|
||||||
from pathlib import Path
|
from pathlib import Path
|
||||||
@ -138,10 +139,14 @@ async def _(bot: Bot, event: MessageEvent):
|
|||||||
)
|
)
|
||||||
await asyncio.sleep(0.25)
|
await asyncio.sleep(0.25)
|
||||||
save_json(reboot_data, Path() / 'rebooting.json')
|
save_json(reboot_data, Path() / 'rebooting.json')
|
||||||
await get_app().router.shutdown()
|
with contextlib.suppress(Exception):
|
||||||
if sys.argv[0].endswith('nb'):
|
await get_app().router.shutdown()
|
||||||
sys.argv[0] = 'bot.py'
|
reboot_arg = (
|
||||||
os.execv(sys.executable, [sys.executable] + sys.argv)
|
[sys.executable] + sys.argv
|
||||||
|
if sys.argv[0].endswith('.py')
|
||||||
|
else [sys.executable, 'bot.py']
|
||||||
|
)
|
||||||
|
os.execv(sys.executable, reboot_arg)
|
||||||
|
|
||||||
|
|
||||||
@run_cmd.handle()
|
@run_cmd.handle()
|
||||||
|
@ -1,4 +1,5 @@
|
|||||||
import asyncio
|
import asyncio
|
||||||
|
import contextlib
|
||||||
import datetime
|
import datetime
|
||||||
import os
|
import os
|
||||||
import sys
|
import sys
|
||||||
@ -136,7 +137,11 @@ async def bot_restart():
|
|||||||
{'session_type': 'private', 'session_id': SUPERUSERS[0]},
|
{'session_type': 'private', 'session_id': SUPERUSERS[0]},
|
||||||
Path() / 'rebooting.json',
|
Path() / 'rebooting.json',
|
||||||
)
|
)
|
||||||
await get_app().router.shutdown()
|
with contextlib.suppress(Exception):
|
||||||
if sys.argv[0].endswith('nb'):
|
await get_app().router.shutdown()
|
||||||
sys.argv[0] = 'bot.py'
|
reboot_arg = (
|
||||||
os.execv(sys.executable, [sys.executable] + sys.argv)
|
[sys.executable] + sys.argv
|
||||||
|
if sys.argv[0].endswith('.py')
|
||||||
|
else [sys.executable, 'bot.py']
|
||||||
|
)
|
||||||
|
os.execv(sys.executable, reboot_arg)
|
||||||
|
Loading…
Reference in New Issue
Block a user