Skip to content

Plugin support for HA #10

@huan

Description

@huan

When we are using plugin with HAWechaty, we will register the plugin to all the underlying Wechaty instances:

https://github.com/wechaty/ha-wechaty/blob/eb47c40bd59802beac388e4f288b3a7ab0222b8e/src/ha-wechaty.ts#L338-L344

Which means that, all the available plugin will react to the messages, lead to the below issue

The above issue is because the Wechaty Chatopera Plugin will use the message.say() to send back the message, and when we have two Wechaty instances in HA, the message will be processed twice.

await message.say(answer)

We need to figure out a way to deal with this situation and make it the best practice.

Deduplication

One message will be received by more than one bot with HA Wechaty, which means it will be emitted many times. However, we only want HA Wechaty to emit one message for one message, not many.

陈明雨: 我应该可以,一会我修改下文档~            (2021-10-14 15:10:44)
陈明雨: 我应该可以,一会我修改下文档~            (2021-10-14 15:10:44)
陈明雨: 我应该可以,一会我修改下文档~            (2021-10-14 15:10:44)
Huan (李卓桓): [Fireworks] 大家晚上见!            (2021-10-14 15:24:12)
Huan (李卓桓): [烟花] 大家晚上见!            (2021-10-14 15:24:13)
Huan (李卓桓): [烟花] 大家晚上见!            (2021-10-14 15:24:13)

Even the text message will not match each other when the bot is using different puppet protocols:

Huan (李卓桓): [Fireworks] 大家晚上见!            (2021-10-14 15:24:12)
Huan (李卓桓): [烟花] 大家晚上见!            (2021-10-14 15:24:13)

The above message comes from PadLocal and Paimon.

See: kaiyuanshe/osschat#178

Metadata

Metadata

Assignees

No one assigned

    Labels

    enhancementNew feature or request

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions