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: 钉钉发送的信息被重复接收 #1429

Open
gltjk opened this issue Jul 18, 2024 · 3 comments
Open

Bug: 钉钉发送的信息被重复接收 #1429

gltjk opened this issue Jul 18, 2024 · 3 comments

Comments

@gltjk
Copy link

gltjk commented Jul 18, 2024

Describe the bug

自己开发插件时,钉钉发出的信息,会被接收两次。

Steps to reproduce

  1. koishi 的钉钉适配器选择 ws 协议,输入 secret 和 appKey,其他选项保持不变。

  2. 自己开发测试插件, index.ts 如下:

import { Context, Schema } from "koishi";

export const name = "test-plugin";

export interface Config {}

export const Config: Schema<Config> = Schema.object({});

export function apply(ctx: Context) {
  // write your plugin here
  ctx.on("message", (session) => {
    console.log(new Date());
    console.log('User:', session.content);
  });
}
  1. 钉钉里进入与对应机器人的私聊,发送信息「hello」。

  2. 控制台打印如下:(可见同一条信息过了一分钟后又被接收了一次)

2024-07-18T08:26:30.276Z
User: hello
2024-07-18T08:27:30.244Z
User: hello

Expected behavior

信息只接受一次,不要重复。

Screenshots

No response

Versions

  • OS: macOS 14.5
  • Platform: DingTalk
  • Node version: 22.5.0
  • Koishi version: 4.17.9

Additional context

No response

@gltjk gltjk added the bug BUG label Jul 18, 2024
@ilharp
Copy link
Member

ilharp commented Jul 19, 2024

有点奇怪,消息的重复投递看起来像是钉钉侧的行为,Koishi 并没有内置任何类似功能。

看看钉钉文档上是否说明具有此类行为?另外能否打印下 messageId,看看是否相同?

@gltjk
Copy link
Author

gltjk commented Jul 23, 2024

有点奇怪,消息的重复投递看起来像是钉钉侧的行为,Koishi 并没有内置任何类似功能。

看看钉钉文档上是否说明具有此类行为?另外能否打印下 messageId,看看是否相同?

我刚刚试了直接打印 session.event 转成的 JSON,都是完全相同的。另外,我发现这个问题不光出现在我的插件里,我装了商城里其他可以自动回复的插件,通过钉钉访问时也都回复了两遍。

@MaikoTan
Copy link
Member

Looks like Dingtalk requires a response from clients to confirm that such a message was successfully delivered and processed, otherwise, the Dingtalk server will re-deliver it.
Should check whether the response mechanism was correctly implemented on our side.

Ref: https://open.dingtalk.com/document/direction/stream-mode-protocol-access-description#f88942502bbie

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

No branches or pull requests

4 participants