-
Notifications
You must be signed in to change notification settings - Fork 326
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
[Bug]: 群聊发送的指令插件不响应 #835
Comments
发发你的插件代码 |
from pkg.plugin.context import register, handler, llm_func, BasePlugin, APIHost, EventContext
from pkg.plugin.events import * # 导入事件类
"""
在收到私聊或群聊消息"hello"时,回复"hello, <发送者id>!"或"hello, everyone!"
"""
# 注册插件
@register(name="Hello", description="hello world", version="0.1", author="RockChinQ")
class HelloPlugin(BasePlugin):
# 插件加载时触发
def __init__(self, host: APIHost):
pass
# 异步初始化
async def initialize(self):
pass
# 当收到个人消息时触发
@handler(PersonNormalMessageReceived)
async def person_normal_message_received(self, ctx: EventContext):
msg = ctx.event.text_message # 这里的 event 即为 PersonNormalMessageReceived 的对象
if msg == "hello": # 如果消息为hello
# 输出调试信息
self.ap.logger.debug("hello, {}".format(ctx.event.sender_id))
# 回复消息 "hello, <发送者id>!"
ctx.add_return("reply", ["hello, {}!".format(ctx.event.sender_id)])
# 阻止该事件默认行为(向接口获取回复)
ctx.prevent_default()
# 当收到群消息时触发
@handler(GroupNormalMessageReceived)
async def group_normal_message_received(self, ctx: EventContext):
msg = ctx.event.text_message # 这里的 event 即为 GroupNormalMessageReceived 的对象
if msg == "hello": # 如果消息为hello
# 输出调试信息
self.ap.logger.debug("hello, {}".format(ctx.event.sender_id))
# 回复消息 "hello, everyone!"
ctx.add_return("reply", ["hello, everyone!"])
# 阻止该事件默认行为(向接口获取回复)
ctx.prevent_default()
# 插件卸载时触发
def __del__(self):
pass 我用的就是文档里的示例,然后这个bug好像只在3.2.3出现,3.2.2就好了 |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
部署方式
手动部署
消息平台适配器
aiocqhttp(使用 OneBot 协议接入的)
系统环境
windows server 2019 江苏
Python环境
py 3.10.9
QChatGPT版本
v3.2.3
异常情况
刚从2.x升级到3.x,然后按照文档部署完后把文档里的开发模板(hello插件)放到plugin然后启动机器人,但是私聊发送指令hello就能响应,群聊发送就不会响应,后台是可以看到显示处理group的消息:hello的
日志信息
No response
启用的插件
bot] 所有插件(1):
#1 Hello
hello world
v0.1
作者: RockChinQ
The text was updated successfully, but these errors were encountered: