feat: add support for PATPAT context

This commit is contained in:
lanvent
2023-04-18 23:34:08 +08:00
parent 0be56e5b25
commit de33911460
4 changed files with 32 additions and 8 deletions

View File

@@ -23,7 +23,11 @@ class Hello(Plugin):
logger.info("[Hello] inited")
def on_handle_context(self, e_context: EventContext):
if e_context["context"].type not in [ContextType.TEXT, ContextType.JOIN_GROUP]:
if e_context["context"].type not in [
ContextType.TEXT,
ContextType.JOIN_GROUP,
ContextType.PATPAT,
]:
return
if e_context["context"].type == ContextType.JOIN_GROUP:
@@ -35,6 +39,13 @@ class Hello(Plugin):
e_context.action = EventAction.CONTINUE # 事件继续,交付给下个插件或默认逻辑
return
if e_context["context"].type == ContextType.PATPAT:
e_context["context"].type = ContextType.TEXT
msg: ChatMessage = e_context["context"]["msg"]
e_context["context"].content = f"请你随机使用一种风格介绍你自己,并告诉用户输入#help可以查看帮助信息。"
e_context.action = EventAction.CONTINUE # 事件继续,交付给下个插件或默认逻辑
return
content = e_context["context"].content
logger.debug("[Hello] on_handle_context. content: %s" % content)
if content == "Hello":