fix: improve simadmin autman trigger compatibility

This commit is contained in:
2026-05-16 13:12:28 +08:00
parent c7a76ac2cd
commit 78c64d4f88
2 changed files with 37 additions and 25 deletions
+10 -6
View File
@@ -26,16 +26,20 @@ plugin/scripts/simadmin_multi.py
插件头注已设置: 插件头注已设置:
```text ```text
# [admin: true] #[admin: true]
# [rule: ^sim帮助$] #[rule: ^sim帮助$]
# [rule: ^sim配置$] #[rule: ^sim配置$]
# [rule: ^sim管理$] #[rule: ^sim管理$]
# [rule: ^sim状态(?:\s+\S+)?$] #[rule: ^sim状态(?:\s+\S+)?$]
# [rule: ^sim短信\s+\S+\s+\S+\s+[\s\S]+$] #[rule: ^sim短信\s+\S+\s+\S+\s+[\s\S]+$]
#[priority: 900]
#[platform: qq,qb,wx,wb,tg,tb,fs,we,web,wxmp]
``` ```
即:仅管理员可用。代码内也会再次判断 `sender.isAdmin()` 即:仅管理员可用。代码内也会再次判断 `sender.isAdmin()`
> 实机排查修复:头注采用 Autman 官方常见的 `#[key: value]` 无空格格式,并扩展平台到 `qq,qb,wx,wb,tg,tb,fs,we,web,wxmp`。如果部署到外置微信/内置微信/频道等不同适配器,旧版只写 `qq,wx,tg,tb,fs` 可能导致规则未注册或平台不匹配,从而没有任何交互回应。
## 配置存储 ## 配置存储
插件配置存入 Autman 数据桶: 插件配置存入 Autman 数据桶:
+27 -19
View File
@@ -1,19 +1,20 @@
# [title: SimAdmin多实例管理] #[title: SimAdmin多实例管理]
# [language: python] #[language: python]
# [service: BOSS] #[service: BOSS]
# [disable: false] #[disable: false]
# [admin: true] #[admin: true]
# [rule: ^sim帮助$] #[rule: ^sim帮助$]
# [rule: ^sim配置$] #[rule: ^sim配置$]
# [rule: ^sim管理$] #[rule: ^sim管理$]
# [rule: ^sim状态(?:\s+\S+)?$] #[rule: ^sim状态(?:\s+\S+)?$]
# [rule: ^sim短信\s+\S+\s+\S+\s+[\s\S]+$] #[rule: ^sim短信\s+\S+\s+\S+\s+[\s\S]+$]
# [platform: qq,wx,tg,tb,fs] #[priority: 900]
# [open_source: true] #[platform: qq,qb,wx,wb,tg,tb,fs,we,web,wxmp]
# [version: 1.2.0] #[open_source: true]
# [public: false] #[version: 1.2.1]
# [price: 0] #[public: false]
# [description: 管理员专用:兼容多个 SimAdmin 实例,支持多级菜单配置管理、状态查询和短信发送。配置桶 otto/simadmin_instances。] #[price: 0]
#[description: 管理员专用:兼容多个 SimAdmin 实例,支持多级菜单配置管理、状态查询和短信发送。配置桶 otto/simadmin_instances。]
""" """
Autman Python 插件:SimAdmin 多实例状态查询、短信发送、多级菜单配置管理。 Autman Python 插件:SimAdmin 多实例状态查询、短信发送、多级菜单配置管理。
@@ -62,12 +63,16 @@ def listen_text(sender, prompt, allow_empty=False, default=None):
if value is None: if value is None:
raise SimAdminError("等待输入超时,已退出") raise SimAdminError("等待输入超时,已退出")
value = str(value).strip().strip('"') value = str(value).strip().strip('"')
if value.lower() in ("q", "quit", "exit", "退出", "取消"): # Autman listen 超时/无效输入在不少实机环境返回字符串 error,而不是 None。
raise SimAdminError("已取消") if value.lower() == "error":
raise SimAdminError("等待输入超时或监听失败,已退出")
# allow_empty=True 的场景允许直接回车/空消息走默认值。
if value == "" and default is not None: if value == "" and default is not None:
return default return default
if value == "" and not allow_empty: if value == "" and not allow_empty:
raise SimAdminError("输入不能为空,已退出") raise SimAdminError("输入不能为空,已退出")
if value.lower() in ("q", "quit", "exit", "退出", "取消"):
raise SimAdminError("已取消")
return value return value
@@ -649,7 +654,10 @@ def main():
reply(sender, "SimAdmin插件提示:" + str(e)) reply(sender, "SimAdmin插件提示:" + str(e))
except Exception as e: except Exception as e:
traceback.print_exc(file=sys.stderr) traceback.print_exc(file=sys.stderr)
reply(sender, "SimAdmin插件异常:" + str(e)) try:
reply(sender, "SimAdmin插件异常:" + str(e))
except Exception:
pass
if __name__ == "__main__": if __name__ == "__main__":