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

Bug: middleware处理时不应武断selfId === userId时返回 #1403

Open
garveen opened this issue May 24, 2024 · 6 comments
Open

Bug: middleware处理时不应武断selfId === userId时返回 #1403

garveen opened this issue May 24, 2024 · 6 comments
Labels
bug BUG expected 预期的行为

Comments

@garveen
Copy link

garveen commented May 24, 2024

Describe the bug

在别的客户端发送消息时,该消息无法被koishi插件处理,这是不应该的

Steps to reproduce

if (session.selfId === session.userId) return

Expected behavior

这个判断删了,或者加个开关

Screenshots

No response

Versions

平台无关

Additional context

No response

@ilharp
Copy link
Member

ilharp commented May 24, 2024

人机一体会造成严重的递归问题,Koishi v3 时代有不少使用者因为此问题导致机器人无限发送消息并最终被平台限流。Koishi 目前暂不支持人机一体。

@garveen
Copy link
Author

garveen commented May 24, 2024

问题不是人机一体,而是同一个账号在别的客户端发送的信息无法被koishi处理。即使会产生递归问题,加一个可选择开关也比直接return强,现在的实现导致一些功能从根本上无法实现。

@ilharp
Copy link
Member

ilharp commented May 24, 2024

同一个账号在别的客户端发送的信息无法被koishi处理

「人机一体」的定义就是「同一个账号在别的客户端发送的信息被 Bot 处理」啊。

加开关我觉得是可以的,等等看其他人的意见。不过除了递归问题以外,人机一体还会遇到其他许多问题,例如权限判断和消息统计等等问题。允许人机一体会导致现有的不少插件行为出现变化。

@shigma
Copy link
Member

shigma commented May 25, 2024

现在的实现导致一些功能从根本上无法实现

可以说说你的需求。如果合理的话可以加开关。

@garveen
Copy link
Author

garveen commented May 27, 2024

可以说说你的需求。如果合理的话可以加开关。

需要做消息日志,包括机器人发送的消息也需要存起来,并且日志和实际业务不在同一台机器,不使用同一套代码

@shigma
Copy link
Member

shigma commented May 27, 2024

那你应当使用 message 事件而非 middleware。

middleware 会被截断,就算不考虑是否是自身消息也不应该使用。

  • 我要接收所有消息:on('message')
  • 我要对 部分 消息做处理:middleware

@shigma shigma added the expected 预期的行为 label May 31, 2024
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
bug BUG expected 预期的行为
Projects
None yet
Development

No branches or pull requests

3 participants