-
-
Notifications
You must be signed in to change notification settings - Fork 2.5k
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
通过手机号添加成功,通过微信号添加失败 #2690
Comments
To add a contact by WeChat ID using a bot, follow these steps:
const friend_weixin = await bot.Friendship.search({weixin: 'weixin_account'});
if (friend_weixin) {
await bot.Friendship.add(friend_weixin, 'Hello! I would like to add you as a friend.');
} Ensure your code handles cases where the contact might not be found ( Here's a combined example: async function addContactByWeChatID(bot, weixinId) {
const friend_weixin = await bot.Friendship.search({weixin: weixinId});
if (friend_weixin) {
await bot.Friendship.add(friend_weixin, 'Hello! I would like to add you as a friend.');
console.log('Friend request sent!');
} else {
console.log('Contact not found!');
}
} Replace
|
通过手机号添加的时候没问题,当我换成通过微信号添加的时候然后报错const contact2 = await wechaty.Friendship.search({ weixin: "CZ" }); |
It seems you're encountering issues with the The error message you're seeing indicates that the method expected for searching by handle isn't implemented or recognized by your version of Wechaty. This could be due to several reasons, such as using an outdated version of the library or a mismatch between the library's documentation and its current implementation. Here's a step you can take to troubleshoot and potentially resolve your issue:
Unfortunately, without direct access to the latest Wechaty API changes or internal implementation details, I can't provide a more specific solution. However, following these steps should help you move forward in resolving the issue.
|
已解决 |
const phone =12345678901
const targetContact = await bot.Friendship.search({ phone })
// console.log(phone, 'queryTaskUserXfj')
if (targetContact) {
// console.log(${targetContact} is ready)
await bot.Friendship.add(targetContact, {
hello: "您好"
})
}
The text was updated successfully, but these errors were encountered: