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

我想监听群聊中其他人进入群聊的事件,是否有提供呢 #2700

Open
aqpmzngldh opened this issue May 15, 2024 · 5 comments
Open

Comments

@aqpmzngldh
Copy link

我想监听群聊中其他人进入群聊的事件,是否有提供呢

Copy link

dosubot bot commented May 15, 2024

嘿,@aqpmzngldh!真高兴再次遇到你。👋😄 让我来看看你的问题,很快就会回复你的!

@aqpmzngldh
Copy link
Author

注意不是加入群聊,是进入群聊

Copy link

dosubot bot commented May 15, 2024

要监听群聊中其他人进入群聊的事件,可以使用Wechaty的room-join事件。这个事件允许你检测到有人加入群聊时的情况。这里有一个示例代码展示如何设置监听器:

const { Wechaty } = require('wechaty')

const bot = new Wechaty()
bot.on('start', async () => {
  console.log('Bot started.')
})

bot.on('room-join', (room, inviteeList, inviter, date) => {
  const nameList = inviteeList.map(c => c.name()).join(',')
  console.log(`Room ${room.topic()} got new member ${nameList}, invited by ${inviter.name()} at ${date}`)
})

bot.start()

这段代码会在有新成员加入群聊时触发,打印出新成员的名字、邀请人的名字以及加入的时间。请注意,room-join事件仅在有人新加入群聊时触发,如果是成员离开后再次进入而没有新的加入过程,这个事件是不会触发的。

Details

Sources


About Dosu
This response is meant to be useful and save you time. It is not meant to be a precise solution, but rather a starting point for your own research.

Help me be more useful! Please leave a 👍 if this is helpful and 👎 if it is irrelevant.

To continue the conversation, mention @dosu.

@aqpmzngldh
Copy link
Author

要监听群聊中其他人进入群聊的事件,可以使用Wechaty的room-join事件。这个事件允许你检测到有人加入群聊时的情况。这里有一个示例代码展示如何设置监听器:

const { Wechaty } = require('wechaty')

const bot = new Wechaty()
bot.on('start', async () => {
  console.log('Bot started.')
})

bot.on('room-join', (room, inviteeList, inviter, date) => {
  const nameList = inviteeList.map(c => c.name()).join(',')
  console.log(`Room ${room.topic()} got new member ${nameList}, invited by ${inviter.name()} at ${date}`)
})

bot.start()

这段代码会在有新成员加入群聊时触发,打印出新成员的名字、邀请人的名字以及加入的时间。请注意,room-join事件仅在有人新加入群聊时触发,如果是成员离开后再次进入而没有新的加入过程,这个事件是不会触发的。

Details

To continue the conversation, mention @dosu.

我说的是进入群聊,而不是加入群聊,就是用户进去群聊这个界面后触发,因为我发现机器本身会触发这的,但是其他人进来后不会进行触发@dosu.

Copy link

dosubot bot commented May 16, 2024

Wechaty currently does not support an event that triggers specifically when a user enters the chat interface of a group without performing any actions. The available events focus on actions such as joining or leaving a group, sending messages, and other interaction-based activities. Directly detecting when a user opens a chat interface is not a standard feature provided by the WeChat API or Wechaty, as most bot interactions are based on message events or status changes rather than UI actions within the WeChat client.

Creating a new event for detecting when a user enters the chat interface would depend on the features supported by the specific Puppet being used with Wechaty and the Wechaty API itself. However, this functionality is not documented as part of Wechaty's current capabilities.

While Wechaty supports the integration of third-party libraries or tools to extend its functionalities, there is no specific plugin mentioned in the documentation for detecting when a user enters the chat interface. The framework for creating or integrating such a plugin is supported, but it would require custom development outside of the documented features of Wechaty.

If you're looking to extend Wechaty's functionality in this way, you might consider exploring custom solutions or reaching out to the community for suggestions on how to implement this specific feature.

Details

Sources


About Dosu
This response is meant to be useful and save you time. It is not meant to be a precise solution, but rather a starting point for your own research.

Help me be more useful! Please leave a 👍 if this is helpful and 👎 if it is irrelevant.

To continue the conversation, mention @dosu.

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

No branches or pull requests

1 participant