@@ -55,7 +55,8 @@ export function registerHandlers({
5555 shellManager,
5656 skills,
5757 skillRegistry,
58- scheduler
58+ scheduler,
59+ adminActions
5960} ) {
6061 bot . start ( async ( ctx ) => {
6162 await sendChunkedMarkdown (
@@ -94,6 +95,7 @@ export function registerHandlers({
9495 "/skill off <name> - 禁用 skill" ,
9596 "/sh <command> - 运行受限 Linux 命令 (默认关闭)" ,
9697 "/sh --confirm <command> - 确认执行高风险命令" ,
98+ "/restart - 重启 bot 进程" ,
9799 "/interrupt - 向 Codex CLI 发送 Ctrl+C" ,
98100 "/stop - 终止当前 chat 的 PTY 会话" ,
99101 "/cron_now - 立即触发一次日报推送" ,
@@ -265,17 +267,29 @@ export function registerHandlers({
265267 }
266268
267269 try {
270+ const actionResult = / ^ o n $ / i. test ( action )
271+ ? skillRegistry . enable ( ctx . chat . id , rawName )
272+ : skillRegistry . disable ( ctx . chat . id , rawName ) ;
268273 if ( / ^ o n $ / i. test ( action ) ) {
269- skillRegistry . enable ( ctx . chat . id , rawName ) ;
270- } else {
271- skillRegistry . disable ( ctx . chat . id , rawName ) ;
274+ await sendChunkedMarkdown (
275+ ctx ,
276+ [
277+ actionResult . changed
278+ ? `skill ${ rawName } 已启用。`
279+ : `skill ${ rawName } 已处于启用状态。` ,
280+ ...formatSkillLines ( actionResult . skills )
281+ ] . join ( "\n" )
282+ ) ;
283+ return ;
272284 }
273285
274286 await sendChunkedMarkdown (
275287 ctx ,
276288 [
277- `skill ${ rawName } 已${ / ^ o n $ / i. test ( action ) ? "启用" : "禁用" } 。` ,
278- ...formatSkillLines ( skillRegistry . list ( ctx . chat . id ) )
289+ actionResult . changed
290+ ? `skill ${ rawName } 已禁用。`
291+ : `skill ${ rawName } 已处于禁用状态。` ,
292+ ...formatSkillLines ( actionResult . skills )
279293 ] . join ( "\n" )
280294 ) ;
281295 } catch ( error ) {
@@ -293,6 +307,16 @@ export function registerHandlers({
293307 ) ;
294308 } ) ;
295309
310+ bot . command ( "restart" , async ( ctx ) => {
311+ if ( ! adminActions ?. restart ) {
312+ await sendChunkedMarkdown ( ctx , "当前环境未启用 bot 重启控制。" ) ;
313+ return ;
314+ }
315+
316+ await sendChunkedMarkdown ( ctx , "正在重启 bot 进程..." ) ;
317+ await adminActions . restart ( ) ;
318+ } ) ;
319+
296320 bot . command ( "exec" , async ( ctx ) => {
297321 const task = extractCommandPayload ( ctx . message . text , "exec" ) ;
298322 if ( ! task ) {
@@ -527,6 +551,10 @@ export function registerHandlers({
527551 bot . on ( "text" , async ( ctx ) => {
528552 const text = ctx . message . text ?. trim ( ) || "" ;
529553 if ( ! text ) return ;
554+ if ( / ^ ( 重 启 \s * b o t | 重 启 机 器 人 | r e s t a r t b o t ) $ / i. test ( text ) ) {
555+ await sendChunkedMarkdown ( ctx , "请使用 /restart,而不是把它当作普通消息发送。" ) ;
556+ return ;
557+ }
530558 if ( / ^ \/ \s + \S + / . test ( text ) ) {
531559 await sendChunkedMarkdown (
532560 ctx ,
0 commit comments