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

关于使用 wechaty-puppet-padlocal 无法在群聊中 ‘@所有人’ 的问题 #89

Open
mikoshu opened this issue Apr 4, 2024 · 0 comments

Comments

@mikoshu
Copy link

mikoshu commented Apr 4, 2024

在使用 @juzi/wechaty puppet 为 wechaty-puppet-padlocal 的时候为了能够 @all 查看了源码,发现 room.say() 的方法能接受参数 @all 来实现@所有人的功能,但是尝试之后发现并不能在微信群聊中触发提醒,反复研究后发现需要将源码中的文件

wechaty/dist/esm/src/user-modules/room.js (import 方式引入 wechaty 如果是require 引入应该是改 wechaty/dist/cjs/src/user-modules/room.js ) 中的代码做如下修改
将 435行修改为

const mentionAlias = await Promise.all(mentionList.map(async (contact) => '@' + (contact === '@all' ? 'all' : await this.alias(contact) || contact.name())));
改为
const mentionAlias = await Promise.all(mentionList.map(async (contact) => '@' + (contact === '@all' ? '所有人' : await this.alias(contact) || contact.name())));

同时将所有同时涉及到 messageSendText@all 关键字的地方

await this.wechaty.puppet.messageSendText(this.id, text, mentionList.map(c => c === '@all' ? '@all' : c.id))

修改为

await this.wechaty.puppet.messageSendText(this.id, text, mentionList.map(c => c === '@all' ? 'notify@all' : c.id))

也就是在提醒所有人的时候需要将messageSendText的第三个参数修改为固定文本 notify@all 而不是源码中的 @all
此时可以触发群聊@所有人的功能

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