feat(onebot): built-in #sl status command (toggleable, non-plugin)
A hardcoded `#sl` status command — deliberately NOT a plugin system. Matched at the instance dispatch choke point: a pure-text message equal to `#sl` (exact, trimmed, case-insensitive — no startsWith) replies with SnowLuma version / platform / uptime in the same conversation. - Anyone can trigger; the per-UIN `statusCommand.enabled` toggle is the only gate (default on). Per-conversation cooldown (default 5s, configurable) prevents flood/风控 from repeated triggers. - `swallow` (default false / pass-through): when set, a matched `#sl` is not forwarded to downstream adapters — still cached, logged, replied. - Config on OneBotConfig.statusCommand (per-UIN): defaulted + clamped in config.ts, mirrored/normalized in the WebUI; edits hot-reload via the shared instance context. - WebUI: a "内置命令" section in the 通用设置 tab (enable / swallow / cooldown). Node enable toggle extracted into a shared ui/ToggleSwitch. Pure matcher / cooldown / uptime / text helpers live in modules/status-command with unit tests; config defaults + clamp covered.
This commit is contained in:
11 files changed
+434
-32
No files matched your search
@@ -0,0 +1,35 @@
|
||||
import { motion } from 'motion/react';
|
||||
import { cn } from '@/lib/utils';
|
||||
|
||||
interface ToggleSwitchProps {
|
||||
value: boolean;
|
||||
onChange: (v: boolean) => void;
|
||||
ariaLabel: string;
|
||||
disabled?: boolean;
|
||||
}
|
||||
|
||||
/** Small animated on/off switch (`role="switch"`). Shared across the config
|
||||
* surfaces — node enable toggle, built-in command toggles, etc. */
|
||||
export function ToggleSwitch({ value, onChange, ariaLabel, disabled }: ToggleSwitchProps) {
|
||||
return (
|
||||
<button
|
||||
type="button"
|
||||
role="switch"
|
||||
aria-checked={value ? 'true' : 'false'}
|
||||
aria-label={ariaLabel}
|
||||
disabled={disabled}
|
||||
onClick={() => onChange(!value)}
|
||||
className={cn(
|
||||
'relative inline-flex h-6 w-11 shrink-0 items-center rounded-full border transition-colors',
|
||||
disabled ? 'cursor-not-allowed opacity-50' : 'cursor-pointer',
|
||||
value ? 'border-primary bg-primary' : 'border-input bg-muted',
|
||||
)}
|
||||
>
|
||||
<motion.span
|
||||
className="inline-block size-4 rounded-full bg-background shadow-sm"
|
||||
animate={{ x: value ? 22 : 4 }}
|
||||
transition={{ type: 'spring', stiffness: 500, damping: 30 }}
|
||||
/>
|
||||
</button>
|
||||
);
|
||||
}
|
||||
Reference in new issue
Block a user