Add files via upload

This commit is contained in:
公明
2026-03-02 00:49:21 +08:00
committed by GitHub
parent 74738ee555
commit 39b47a86fb
2 changed files with 54 additions and 40 deletions
+42 -28
View File
@@ -138,43 +138,56 @@ func (h *RobotHandler) clearConversation(platform, userID string) (newConvID str
func (h *RobotHandler) HandleMessage(platform, userID, text string) (reply string) { func (h *RobotHandler) HandleMessage(platform, userID, text string) (reply string) {
text = strings.TrimSpace(text) text = strings.TrimSpace(text)
if text == "" { if text == "" {
return "请输入内容或发送「帮助」查看命令。" return "请输入内容或发送「帮助」/ help 查看命令。"
} }
// 命令分发 // 命令分发(支持中英文)
switch { switch {
case text == robotCmdHelp || text == "help" || text == "" || text == "?": case text == robotCmdHelp || text == "help" || text == "" || text == "?":
return h.cmdHelp() return h.cmdHelp()
case text == robotCmdList || text == robotCmdListAlt: case text == robotCmdList || text == robotCmdListAlt || text == "list":
return h.cmdList() return h.cmdList()
case strings.HasPrefix(text, robotCmdSwitch+" ") || strings.HasPrefix(text, robotCmdContinue+" "): case strings.HasPrefix(text, robotCmdSwitch+" ") || strings.HasPrefix(text, robotCmdContinue+" ") || strings.HasPrefix(text, "switch ") || strings.HasPrefix(text, "continue "):
var id string var id string
if strings.HasPrefix(text, robotCmdSwitch+" ") { switch {
case strings.HasPrefix(text, robotCmdSwitch+" "):
id = strings.TrimSpace(text[len(robotCmdSwitch)+1:]) id = strings.TrimSpace(text[len(robotCmdSwitch)+1:])
} else { case strings.HasPrefix(text, robotCmdContinue+" "):
id = strings.TrimSpace(text[len(robotCmdContinue)+1:]) id = strings.TrimSpace(text[len(robotCmdContinue)+1:])
case strings.HasPrefix(text, "switch "):
id = strings.TrimSpace(text[7:])
default:
id = strings.TrimSpace(text[9:])
} }
return h.cmdSwitch(platform, userID, id) return h.cmdSwitch(platform, userID, id)
case text == robotCmdNew: case text == robotCmdNew || text == "new":
return h.cmdNew(platform, userID) return h.cmdNew(platform, userID)
case text == robotCmdClear: case text == robotCmdClear || text == "clear":
return h.cmdClear(platform, userID) return h.cmdClear(platform, userID)
case text == robotCmdCurrent: case text == robotCmdCurrent || text == "current":
return h.cmdCurrent(platform, userID) return h.cmdCurrent(platform, userID)
case text == robotCmdStop || text == "stop": case text == robotCmdStop || text == "stop":
return h.cmdStop(platform, userID) return h.cmdStop(platform, userID)
case text == robotCmdRoles || text == robotCmdRolesList: case text == robotCmdRoles || text == robotCmdRolesList || text == "roles":
return h.cmdRoles() return h.cmdRoles()
case strings.HasPrefix(text, robotCmdRoles+" ") || strings.HasPrefix(text, robotCmdSwitchRole+" "): case strings.HasPrefix(text, robotCmdRoles+" ") || strings.HasPrefix(text, robotCmdSwitchRole+" ") || strings.HasPrefix(text, "role "):
var roleName string var roleName string
if strings.HasPrefix(text, robotCmdRoles+" ") { switch {
case strings.HasPrefix(text, robotCmdRoles+" "):
roleName = strings.TrimSpace(text[len(robotCmdRoles)+1:]) roleName = strings.TrimSpace(text[len(robotCmdRoles)+1:])
} else { case strings.HasPrefix(text, robotCmdSwitchRole+" "):
roleName = strings.TrimSpace(text[len(robotCmdSwitchRole)+1:]) roleName = strings.TrimSpace(text[len(robotCmdSwitchRole)+1:])
default:
roleName = strings.TrimSpace(text[5:])
} }
return h.cmdSwitchRole(platform, userID, roleName) return h.cmdSwitchRole(platform, userID, roleName)
case strings.HasPrefix(text, robotCmdDelete+" "): case strings.HasPrefix(text, robotCmdDelete+" ") || strings.HasPrefix(text, "delete "):
convID := strings.TrimSpace(text[len(robotCmdDelete)+1:]) var convID string
if strings.HasPrefix(text, robotCmdDelete+" ") {
convID = strings.TrimSpace(text[len(robotCmdDelete)+1:])
} else {
convID = strings.TrimSpace(text[7:])
}
return h.cmdDelete(platform, userID, convID) return h.cmdDelete(platform, userID, convID)
case text == robotCmdVersion || text == "version": case text == robotCmdVersion || text == "version":
return h.cmdVersion() return h.cmdVersion()
@@ -219,19 +232,20 @@ func (h *RobotHandler) HandleMessage(platform, userID, text string) (reply strin
} }
func (h *RobotHandler) cmdHelp() string { func (h *RobotHandler) cmdHelp() string {
return `【CyberStrikeAI 机器人命令】 return `【CyberStrikeAI 机器人命令 / Bot Commands
· 帮助 — 显示本帮助 · 帮助 / help — 显示本帮助 / Show this help
· 列表 / 对话列表 — 列出所有对话标题与 ID · 列表 / 对话列表 / list — 列出所有对话标题与 ID / List conversations
· 切换 <对话ID> / 继续 <对话ID> — 指定对话继续 · 切换 <ID> / 继续 <ID> / switch <ID> — 指定对话继续 / Switch to conversation
· 新对话 — 开启新对话 · 新对话 / new — 开启新对话 / Start new conversation
· 清空 — 清空当前上下文(等同于新对话) · 清空 / clear — 清空当前上下文 / Clear context (same as new)
· 当前 — 显示当前对话 ID 与标题 · 当前 / current — 显示当前对话 ID 与标题 / Show current conversation
· 停止 — 中断当前正在执行的任务 · 停止 / stop — 中断当前任务 / Stop running task
· 角色 / 角色列表 — 列出所有可用角色 · 角色 / 角色列表 / roles — 列出所有可用角色 / List roles
· 角色 <角色名> / 切换角色 <角色名> — 切换当前角色 · 角色 <名> / 切换角色 <名> / role <name> — 切换当前角色 / Switch role
· 删除 <对话ID> — 删除指定对话 · 删除 <ID> / delete <ID> — 删除指定对话 / Delete conversation
· 版本 — 显示当前版本号 · 版本 / version — 显示当前版本号 / Show version
除以上命令外,直接输入内容将发送给 AI 进行渗透测试/安全分析。` 除以上命令外,直接输入内容将发送给 AI 进行渗透测试/安全分析。
Otherwise, send any text for AI penetration testing / security analysis.`
} }
func (h *RobotHandler) cmdList() string { func (h *RobotHandler) cmdList() string {
+12 -12
View File
@@ -1289,19 +1289,19 @@
<div class="settings-subsection"> <div class="settings-subsection">
<h4>机器人命令说明</h4> <h4>机器人命令说明</h4>
<p class="settings-description">在对话中可发送以下命令:</p> <p class="settings-description">在对话中可发送以下命令(支持中英文)</p>
<ul style="color: var(--text-muted); font-size: 13px; line-height: 1.8; margin: 8px 0 0 16px;"> <ul style="color: var(--text-muted); font-size: 13px; line-height: 1.8; margin: 8px 0 0 16px;">
<li><strong>帮助</strong> — 显示命令帮助</li> <li><strong>帮助</strong> / help — 显示命令帮助</li>
<li><strong>列表</strong> <strong>对话列表</strong> — 列出所有对话标题与 ID</li> <li><strong>列表</strong> / <strong>对话列表</strong> / list — 列出所有对话标题与 ID</li>
<li><strong>切换 &lt;对话ID&gt;</strong> <strong>继续 &lt;对话ID&gt;</strong> — 指定对话 ID 继续对话</li> <li><strong>切换 &lt;ID&gt;</strong> / <strong>继续 &lt;ID&gt;</strong> / switch &lt;ID&gt; — 指定对话继续</li>
<li><strong>新对话</strong> — 开启新对话</li> <li><strong>新对话</strong> / new — 开启新对话</li>
<li><strong>清空</strong> — 清空当前对话上下文(不删除历史</li> <li><strong>清空</strong> / clear — 清空当前上下文(等同于新对话</li>
<li><strong>当前</strong> — 显示当前对话 ID 与标题</li> <li><strong>当前</strong> / current — 显示当前对话 ID 与标题</li>
<li><strong>停止</strong> — 中断当前正在执行的任务</li> <li><strong>停止</strong> / stop — 中断当前正在执行的任务</li>
<li><strong>角色</strong> <strong>角色列表</strong> — 列出所有可用角色</li> <li><strong>角色</strong> / <strong>角色列表</strong> / roles — 列出所有可用角色</li>
<li><strong>角色 &lt;角色&gt;</strong> <strong>切换角色 &lt;角色&gt;</strong> — 切换当前角色</li> <li><strong>角色 &lt;&gt;</strong> / <strong>切换角色 &lt;&gt;</strong> / role &lt;name&gt; — 切换当前角色</li>
<li><strong>删除 &lt;对话ID&gt;</strong> — 删除指定对话</li> <li><strong>删除 &lt;ID&gt;</strong> / delete &lt;ID&gt; — 删除指定对话</li>
<li><strong>版本</strong> — 显示当前版本号</li> <li><strong>版本</strong> / version — 显示当前版本号</li>
</ul> </ul>
</div> </div>