非TTY环境禁用console_input_loop

This commit is contained in:
Cookie987
2025-07-01 12:50:10 +08:00
parent 6dee5a6333
commit 2d2f6ecd8d

8
bot.py
View File

@@ -314,10 +314,16 @@ if __name__ == "__main__":
# Schedule tasks returns a future that runs forever.
# We can run console_input_loop concurrently.
main_tasks = loop.create_task(main_system.schedule_tasks())
# 仅在 TTY 中启用 console_input_loop
if sys.stdin.isatty():
logger.info("检测到终端环境,启用控制台输入循环")
console_task = loop.create_task(console_input_loop(main_system))
# Wait for all tasks to complete (which they won't, normally)
loop.run_until_complete(asyncio.gather(main_tasks, console_task))
else:
logger.info("非终端环境,跳过控制台输入循环")
# Wait for all tasks to complete (which they won't, normally)
loop.run_until_complete(main_tasks)
except KeyboardInterrupt:
# loop.run_until_complete(get_global_api().stop())