Browse Source

Merge pull request #576 from lanvent/dev

plugins: add helpp command for godcmd
master
zhayujie GitHub 1 year ago
parent
commit
61c6d01af2
No known key found for this signature in database GPG Key ID: 4AEE18F83AFDEB23
7 changed files with 36 additions and 6 deletions
  1. +4
    -1
      plugins/banwords/banwords.py
  2. +4
    -1
      plugins/dungeon/dungeon.py
  3. +17
    -0
      plugins/godcmd/godcmd.py
  4. +4
    -0
      plugins/hello/hello.py
  5. +3
    -0
      plugins/plugin.py
  6. +3
    -3
      plugins/role/role.py
  7. +1
    -1
      plugins/sdwebui/sdwebui.py

+ 4
- 1
plugins/banwords/banwords.py View File

@@ -60,4 +60,7 @@ class Banwords(Plugin):
reply = Reply(ReplyType.INFO, "发言中包含敏感词,请重试: \n"+self.searchr.Replace(content)) reply = Reply(ReplyType.INFO, "发言中包含敏感词,请重试: \n"+self.searchr.Replace(content))
e_context['reply'] = reply e_context['reply'] = reply
e_context.action = EventAction.BREAK_PASS e_context.action = EventAction.BREAK_PASS
return
return
def get_help_text(self, **kwargs):
return Banwords.desc

+ 4
- 1
plugins/dungeon/dungeon.py View File

@@ -80,4 +80,7 @@ class Dungeon(Plugin):
prompt = self.games[sessionid].action(content) prompt = self.games[sessionid].action(content)
e_context['context'].type = ContextType.TEXT e_context['context'].type = ContextType.TEXT
e_context['context'].content = prompt 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
- 0
plugins/godcmd/godcmd.py View File

@@ -19,6 +19,11 @@ COMMANDS = {
"alias": ["help", "帮助"], "alias": ["help", "帮助"],
"desc": "打印指令集合", "desc": "打印指令集合",
}, },
"helpp": {
"alias": ["helpp", "插件帮助"],
"args": ["插件名"],
"desc": "打印插件的帮助信息",
},
"auth": { "auth": {
"alias": ["auth", "认证"], "alias": ["auth", "认证"],
"args": ["口令"], "args": ["口令"],
@@ -161,6 +166,16 @@ class Godcmd(Plugin):
ok, result = self.authenticate(user, args, isadmin, isgroup) ok, result = self.authenticate(user, args, isadmin, isgroup)
elif cmd == "help": elif cmd == "help":
ok, result = True, get_help_text(isadmin, isgroup) 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": elif cmd == "id":
ok, result = True, f"用户id=\n{user}" ok, result = True, f"用户id=\n{user}"
elif cmd == "reset": elif cmd == "reset":
@@ -288,3 +303,5 @@ class Godcmd(Plugin):
else: else:
return False,"认证失败" return False,"认证失败"


def get_help_text(self, isadmin = False, isgroup = False, **kwargs):
return get_help_text(isadmin, isgroup)

+ 4
- 0
plugins/hello/hello.py View File

@@ -44,3 +44,7 @@ class Hello(Plugin):
e_context['context'].type = ContextType.IMAGE_CREATE e_context['context'].type = ContextType.IMAGE_CREATE
content = "The World" content = "The World"
e_context.action = EventAction.CONTINUE # 事件继续,交付给下个插件或默认逻辑 e_context.action = EventAction.CONTINUE # 事件继续,交付给下个插件或默认逻辑

def get_help_text(self, **kwargs):
help_text = "输入Hello,我会回复你的名字\n输入End,我会回复你世界的图片\n"
return help_text

+ 3
- 0
plugins/plugin.py View File

@@ -1,3 +1,6 @@
class Plugin: class Plugin:
def __init__(self): def __init__(self):
self.handlers = {} self.handlers = {}

def get_help_text(self, **kwargs):
return "暂无帮助信息"

+ 3
- 3
plugins/role/role.py View File

@@ -117,10 +117,10 @@ class Role(Plugin):
prompt = self.roleplays[sessionid].action(content) prompt = self.roleplays[sessionid].action(content)
e_context['context'].type = ContextType.TEXT e_context['context'].type = ContextType.TEXT
e_context['context'].content = prompt 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: for role in self.roles:
help_text += f"[{role}]: {self.roles[role]['remark']}\n" help_text += f"[{role}]: {self.roles[role]['remark']}\n"
return help_text return help_text

+ 1
- 1
plugins/sdwebui/sdwebui.py View File

@@ -97,7 +97,7 @@ class SDWebUI(Plugin):
finally: finally:
e_context['reply'] = reply e_context['reply'] = reply


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


Loading…
Cancel
Save