mirror of
https://github.com/hansjone/dsh-im-ops.git
synced 2026-10-20 20:43:21 +08:00
feat: add plugin version command
This commit is contained in:
parent
10ca7eec2c
commit
c5becbe379
24 changed files with 240 additions and 172 deletions
|
|
@ -1,8 +1,11 @@
|
|||
import { t } from './i18n.mjs';
|
||||
import manifest from '../../../package.json' with { type: 'json' };
|
||||
|
||||
const CONTROL_COMMAND = /^\/(?:stop|steer)(?=$|\s)/iu;
|
||||
const CONTROL_COMMAND = /^\/(?:stop|steer|version)(?=$|\s)/iu;
|
||||
const STOP_COMMAND = /^\/stop(?=$|\s)/iu;
|
||||
const VERSION_COMMAND = /^\/version(?=$|\s)/iu;
|
||||
const STOP_USAGE = '用法:/stop(不带参数)';
|
||||
const VERSION_USAGE = '用法:/version(不带参数)';
|
||||
const STEER_USAGE = '用法:/steer <补充指令>';
|
||||
const TEXT_ONLY = '控制命令仅支持纯文字,请移除图片后重试。';
|
||||
|
||||
|
|
@ -41,9 +44,16 @@ export async function runControlCommand(text, harness, state, key, {
|
|||
if (!isControlCommand(text)) return null;
|
||||
const command = text.trim();
|
||||
const stop = STOP_COMMAND.test(command);
|
||||
const version = VERSION_COMMAND.test(command);
|
||||
|
||||
if (hasImages) return commandResult(t(TEXT_ONLY));
|
||||
|
||||
if (version) {
|
||||
return /^\/version$/iu.test(command)
|
||||
? commandResult(`dsh-im v${manifest.version}`)
|
||||
: commandResult(t(VERSION_USAGE));
|
||||
}
|
||||
|
||||
if (stop) {
|
||||
if (!/^\/stop$/iu.test(command)) return commandResult(t(STOP_USAGE));
|
||||
const session = boundSession(harness, state, key);
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue