mirror of
https://github.com/zhayujie/chatgpt-on-wechat.git
synced 2026-03-02 16:29:20 +08:00
fix: merge plugins to dev
This commit is contained in:
@@ -31,7 +31,7 @@
|
||||
context.kwargs = {'isgroup': False, 'msg': msg, 'receiver': other_user_id, 'session_id': other_user_id}
|
||||
```
|
||||
2. 产生回复
|
||||
本过程用于处理消息。目前默认处理逻辑是根据`Context`的类型交付给对应的bot:
|
||||
本过程用于处理消息。目前默认处理逻辑如下,它根据`Context`的类型交付给对应的bot。如果本过程未产生任何回复,则会跳过之后的处理阶段。
|
||||
```python
|
||||
if context.type == ContextType.TEXT or context.type == ContextType.IMAGE_CREATE:
|
||||
reply = super().build_reply_content(context.content, context) #文字跟画图交付给chatgpt
|
||||
@@ -133,9 +133,9 @@ class Hello(Plugin):
|
||||
- `EventAction.BREAK`: 事件结束,不再给下个插件处理,交付给默认的处理逻辑。
|
||||
- `EventAction.BREAK_PASS`: 事件结束,不再给下个插件处理,跳过默认的处理逻辑。
|
||||
|
||||
以`Hello`插件为例,它处理`Context`类型为`TEXT`的消息。
|
||||
以`Hello`插件为例,它处理`Context`类型为`TEXT`的消息:
|
||||
- 如果内容是`Hello`,直接将回复设置为`Hello+用户昵称`,并跳过之后的插件和默认逻辑。
|
||||
- 如果内容是`End`,它会将`Context`的类型更改为`IMAGE_CREATE`,并让事件继续,如果最终交付到默认逻辑,会调用默认的画图Bot。
|
||||
- 如果内容是`End`,它会将`Context`的类型更改为`IMAGE_CREATE`,并让事件继续,如果最终交付到默认逻辑,会调用默认的画图Bot来画画。
|
||||
```python
|
||||
def on_handle_context(self, e_context: EventContext):
|
||||
if e_context['context'].type != ContextType.TEXT:
|
||||
|
||||
@@ -8,6 +8,7 @@ from config import conf
|
||||
import plugins
|
||||
from plugins import *
|
||||
from common.log import logger
|
||||
from common import const
|
||||
|
||||
# https://github.com/bupticybee/ChineseAiDungeonChatGPT
|
||||
class StoryTeller():
|
||||
@@ -51,7 +52,7 @@ class Dungeon(Plugin):
|
||||
if e_context['context'].type != ContextType.TEXT:
|
||||
return
|
||||
bottype = Bridge().get_bot_type("chat")
|
||||
if bottype != "chatGPT":
|
||||
if bottype != const.CHATGPT:
|
||||
return
|
||||
bot = Bridge().get_bot("chat")
|
||||
content = e_context['context'].content[:]
|
||||
|
||||
@@ -10,6 +10,7 @@ from bridge.reply import Reply, ReplyType
|
||||
from config import load_config
|
||||
import plugins
|
||||
from plugins import *
|
||||
from common import const
|
||||
from common.log import logger
|
||||
|
||||
# 定义指令集
|
||||
@@ -163,7 +164,7 @@ class Godcmd(Plugin):
|
||||
elif cmd == "id":
|
||||
ok, result = True, f"用户id=\n{user}"
|
||||
elif cmd == "reset":
|
||||
if bottype == "chatGPT":
|
||||
if bottype == const.CHATGPT:
|
||||
bot.sessions.clear_session(session_id)
|
||||
ok, result = True, "会话已重置"
|
||||
else:
|
||||
@@ -185,7 +186,7 @@ class Godcmd(Plugin):
|
||||
load_config()
|
||||
ok, result = True, "配置已重载"
|
||||
elif cmd == "resetall":
|
||||
if bottype == "chatGPT":
|
||||
if bottype == const.CHATGPT:
|
||||
bot.sessions.clear_all_session()
|
||||
ok, result = True, "重置所有会话成功"
|
||||
else:
|
||||
|
||||
@@ -5,6 +5,7 @@ import os
|
||||
from bridge.bridge import Bridge
|
||||
from bridge.context import ContextType
|
||||
from bridge.reply import Reply, ReplyType
|
||||
from common import const
|
||||
import plugins
|
||||
from plugins import *
|
||||
from common.log import logger
|
||||
@@ -73,7 +74,7 @@ class Role(Plugin):
|
||||
if e_context['context'].type != ContextType.TEXT:
|
||||
return
|
||||
bottype = Bridge().get_bot_type("chat")
|
||||
if bottype != "chatGPT":
|
||||
if bottype != const.CHATGPT:
|
||||
return
|
||||
bot = Bridge().get_bot("chat")
|
||||
content = e_context['context'].content[:]
|
||||
@@ -119,7 +120,7 @@ class Role(Plugin):
|
||||
e_context.action = EventAction.CONTINUE
|
||||
|
||||
def get_help_text(self):
|
||||
help_text = "输入\"$角色 (角色名)\"或\"$role (角色名)\"为我设定角色吧,#reset 可以清除设定的角色。\n\n目前可用角色列表:\n"
|
||||
help_text = "输入\"$角色 (角色名)\"或\"$role (角色名)\"为我设定角色吧,\"$停止扮演 \" 可以清除设定的角色。\n\n目前可用角色列表:\n"
|
||||
for role in self.roles:
|
||||
help_text += f"[{role}]: {self.roles[role]['remark']}\n"
|
||||
return help_text
|
||||
|
||||
Reference in New Issue
Block a user