[feature] 远程控制 / 接受外部命令
[Feature] Remote Control / Accept External Commands
Open an external interface to allow for programmatic control of the application. This could be an IPC protocol like Protobuf, or a REST/WebSocket API (a REST API would be the easiest to program against). The implementation doesn't need to be complex; it only needs to support simple commands such as:
- Gracefully stop or start the scheduler.
- Stop after the current task finishes.
- Run a specific task (potentially with custom configuration).
- Report the scheduler's current state.
Simply having the ability to request a specific task to run would allow users to write scripts of arbitrary logical complexity for scheduling.
This capability is also crucial for long, unattended sessions—spanning weeks or even months. For instance, some users configure their PC's motherboard to auto-power-on at a specific time to run tasks. With this remote control, scenarios like scheduled game restarts https://github.com/babalae/better-genshin-impact/issues/2295, launching the game launcher to check for updates https://github.com/babalae/better-genshin-impact/issues/2324#issuecomment-3393415443, or automatically updating script repositories can be managed by external helper scripts. This reduces the need to implement every possible maintenance feature directly within the application itself.
While it is technically possible to kill the application, modify the configuration files, and restart it, it is difficult to determine when it is safe to do so (i.e., when tasks are not running). This method is also slow due to the application's startup time.
Given the application's asynchronous architecture, it should not be overly difficult to implement a command queue that processes requests when the system is ready.
Current method of using JS scripts are way too limited for usage outside of automating in-game. I understand that this feature is only intended for power users and should have very low priority.
Chinese AI translation:
- Your feature requesting / 你的新功能请求: 远程控制 / 接受外部命令
[功能] 远程控制 / 接受外部命令
为应用程序开启一个外部接口,以实现程序化控制。这可以是基于 IPC 的协议(如 Protobuf),也可以是 REST 或 WebSocket API(其中 REST API 对于开发者来说最为简单)。该实现无需复杂,仅需支持一些简单的命令,例如:
- 优雅地停止或启动调度器。
- 在当前任务完成后停止。
- 运行特定任务(或许还能附带自定义配置)。
- 报告调度器的当前状态。
仅仅拥有请求运行特定任务的能力,就足以让用户编写逻辑任意复杂的脚本进行调度。
这一能力对于长时间的无人值守运行也至关重要——这种运行可能持续数周甚至数月。例如,有些用户会配置电脑主板的自动开机功能,在特定时间启动电脑来执行任务。通过这种远程控制,诸如定时重启游戏 https://github.com/babalae/better-genshin-impact/issues/2295 、启动游戏启动器以检查更新 https://github.com/babalae/better-genshin-impact/issues/2324#issuecomment-3393415443 ,或自动更新脚本仓库等场景,都可以通过外部的辅助脚本来管理。这减少了许多维护功能直接内置于应用程序本身的需求。
虽然从技术上讲,可以通过结束应用程序进程、修改配置文件再重启的方式来实现类似效果,但很难判断何时这样操作是安全的(即任务不在运行时)。同时,由于应用程序需要启动时间,这种方式也非常缓慢。
鉴于应用程序的异步架构,实现一个命令队列,在系统准备就绪时处理请求,应该不会过于困难。
目前使用 JS 脚本的方法在游戏内自动化之外的使用范围过于有限。我理解此功能仅面向高级用户,优先级应该很低。
Source: babalae/better-genshin-impact