(isadmin, isgroup)
| 136 | |
| 137 | # 定义帮助函数 |
| 138 | def get_help_text(isadmin, isgroup): |
| 139 | help_text = "通用指令\n" |
| 140 | for cmd, info in COMMANDS.items(): |
| 141 | if cmd in ["auth", "set_openai_api_key", "reset_openai_api_key", "set_gpt_model", "reset_gpt_model", "gpt_model"]: # 不显示帮助指令 |
| 142 | continue |
| 143 | raw_ct = conf().get("channel_type", "web") |
| 144 | active_channels = raw_ct if isinstance(raw_ct, list) else [c.strip() for c in str(raw_ct).split(",")] |
| 145 | if cmd == "id" and not any(c in ["wxy", "wechatmp"] for c in active_channels): |
| 146 | continue |
| 147 | alias = ["#" + a for a in info["alias"][:1]] |
| 148 | help_text += f"{','.join(alias)} " |
| 149 | if "args" in info: |
| 150 | args = [a for a in info["args"]] |
| 151 | help_text += f"{' '.join(args)}" |
| 152 | help_text += f": {info['desc']}\n" |
| 153 | |
| 154 | # 插件指令 |
| 155 | plugins = PluginManager().list_plugins() |
| 156 | help_text += "\n可用插件" |
| 157 | for plugin in plugins: |
| 158 | if plugins[plugin].enabled and not plugins[plugin].hidden: |
| 159 | namecn = plugins[plugin].namecn |
| 160 | help_text += "\n%s: " % namecn |
| 161 | help_text += PluginManager().instances[plugin].get_help_text(verbose=False).strip() |
| 162 | |
| 163 | if ADMIN_COMMANDS and isadmin: |
| 164 | help_text += "\n\n管理员指令:\n" |
| 165 | for cmd, info in ADMIN_COMMANDS.items(): |
| 166 | alias = ["#" + a for a in info["alias"][:1]] |
| 167 | help_text += f"{','.join(alias)} " |
| 168 | if "args" in info: |
| 169 | args = [a for a in info["args"]] |
| 170 | help_text += f"{' '.join(args)}" |
| 171 | help_text += f": {info['desc']}\n" |
| 172 | return help_text |
| 173 | |
| 174 | |
| 175 | @plugins.register( |
no test coverage detected