Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

plugins: add helpp command for godcmd #576

Merged
merged 1 commit into from
Mar 24, 2023
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
5 changes: 4 additions & 1 deletion plugins/banwords/banwords.py
Original file line number Diff line number Diff line change
Expand Up @@ -60,4 +60,7 @@ def on_handle_context(self, e_context: EventContext):
reply = Reply(ReplyType.INFO, "发言中包含敏感词,请重试: \n"+self.searchr.Replace(content))
e_context['reply'] = reply
e_context.action = EventAction.BREAK_PASS
return
return

def get_help_text(self, **kwargs):
return Banwords.desc
5 changes: 4 additions & 1 deletion plugins/dungeon/dungeon.py
Original file line number Diff line number Diff line change
Expand Up @@ -80,4 +80,7 @@ def on_handle_context(self, e_context: EventContext):
prompt = self.games[sessionid].action(content)
e_context['context'].type = ContextType.TEXT
e_context['context'].content = prompt
e_context.action = EventAction.CONTINUE
e_context.action = EventAction.BREAK # 事件结束,不跳过处理context的默认逻辑
def get_help_text(self, **kwargs):
help_text = "输入\"$开始冒险 {背景故事}\"来以{背景故事}开始一个地牢游戏,之后你的所有消息会帮助我来完善这个故事。输入\"$停止冒险 \"可以结束游戏。"
return help_text
17 changes: 17 additions & 0 deletions plugins/godcmd/godcmd.py
Original file line number Diff line number Diff line change
Expand Up @@ -19,6 +19,11 @@
"alias": ["help", "帮助"],
"desc": "打印指令集合",
},
"helpp": {
"alias": ["helpp", "插件帮助"],
"args": ["插件名"],
"desc": "打印插件的帮助信息",
},
"auth": {
"alias": ["auth", "认证"],
"args": ["口令"],
Expand Down Expand Up @@ -161,6 +166,16 @@ def on_handle_context(self, e_context: EventContext):
ok, result = self.authenticate(user, args, isadmin, isgroup)
elif cmd == "help":
ok, result = True, get_help_text(isadmin, isgroup)
elif cmd == "helpp":
if len(args) != 1:
ok, result = False, "请提供插件名"
else:
plugins = PluginManager().list_plugins()
name = args[0].upper()
if name in plugins and plugins[name].enabled:
ok, result = True, PluginManager().instances[name].get_help_text(isgroup=isgroup, isadmin=isadmin)
else:
ok, result= False, "插件不存在或未启用"
elif cmd == "id":
ok, result = True, f"用户id=\n{user}"
elif cmd == "reset":
Expand Down Expand Up @@ -288,3 +303,5 @@ def authenticate(self, userid, args, isadmin, isgroup) -> Tuple[bool,str] :
else:
return False,"认证失败"

def get_help_text(self, isadmin = False, isgroup = False, **kwargs):
return get_help_text(isadmin, isgroup)
4 changes: 4 additions & 0 deletions plugins/hello/hello.py
Original file line number Diff line number Diff line change
Expand Up @@ -44,3 +44,7 @@ def on_handle_context(self, e_context: EventContext):
e_context['context'].type = ContextType.IMAGE_CREATE
content = "The World"
e_context.action = EventAction.CONTINUE # 事件继续,交付给下个插件或默认逻辑

def get_help_text(self, **kwargs):
help_text = "输入Hello,我会回复你的名字\n输入End,我会回复你世界的图片\n"
return help_text
3 changes: 3 additions & 0 deletions plugins/plugin.py
Original file line number Diff line number Diff line change
@@ -1,3 +1,6 @@
class Plugin:
def __init__(self):
self.handlers = {}

def get_help_text(self, **kwargs):
return "暂无帮助信息"
6 changes: 3 additions & 3 deletions plugins/role/role.py
Original file line number Diff line number Diff line change
Expand Up @@ -117,10 +117,10 @@ def on_handle_context(self, e_context: EventContext):
prompt = self.roleplays[sessionid].action(content)
e_context['context'].type = ContextType.TEXT
e_context['context'].content = prompt
e_context.action = EventAction.CONTINUE
e_context.action = EventAction.BREAK

def get_help_text(self):
help_text = "输入\"$角色 (角色名)\"或\"$role (角色名)\"为我设定角色吧,\"$停止扮演 \" 可以清除设定的角色。\n\n目前可用角色列表:\n"
def get_help_text(self, **kwargs):
help_text = "输入\"$角色 {角色名}\"或\"$role {角色名}\"为我设定角色吧,\"$停止扮演 \" 可以清除设定的角色。\n\n目前可用角色列表:\n"
for role in self.roles:
help_text += f"[{role}]: {self.roles[role]['remark']}\n"
return help_text
2 changes: 1 addition & 1 deletion plugins/sdwebui/sdwebui.py
Original file line number Diff line number Diff line change
Expand Up @@ -97,7 +97,7 @@ def on_handle_context(self, e_context: EventContext):
finally:
e_context['reply'] = reply

def get_help_text(self):
def get_help_text(self, **kwargs):
if not conf().get('image_create_prefix'):
return "画图功能未启用"
else:
Expand Down