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

关于如何将ding-dong-bot.ts文件改成满足企业微信的demo #2697

Open
JohnLi94 opened this issue May 14, 2024 · 7 comments
Open

关于如何将ding-dong-bot.ts文件改成满足企业微信的demo #2697

JohnLi94 opened this issue May 14, 2024 · 7 comments

Comments

@JohnLi94
Copy link

可以具体给个例子吗,只有微信可以顺利使用。

Copy link

dosubot bot commented May 14, 2024

To adapt the ding-dong-bot.ts file for WeCom, follow these steps:

  1. Change the Puppet to WeCom: Use wechaty-puppet-wxwork for WeCom integration. This requires specifying the puppet in the options object of your ding-dong-bot.ts file:
const options = {
  name: 'ding-dong-bot',
  puppet: 'wechaty-puppet-wxwork', // WeCom puppet
  puppetOptions: {
    // corpId: 'YOUR_CORP_ID',
    // secret: 'YOUR_SECRET',
  }
}
  1. Install the WeCom Puppet: Run npm install wechaty-puppet-wxwork or yarn add wechaty-puppet-wxwork to add the puppet to your project.

  2. Adjust Your Bot's Code: Depending on WeCom's features you plan to use, you might need to tweak your bot's code to accommodate WeCom's specific functionalities.

Ensure you have the latest versions of WeChaty and wechaty-puppet-wxwork, and refer to their documentation for the most accurate guidance. This approach will help you integrate WeCom into your ding-dong-bot.ts effectively.

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.

@JohnLi94
Copy link
Author

JohnLi94 commented May 14, 2024

wechaty-puppet-wxwork

我看原始工程Deome是
// puppet: 'wechaty-puppet-service'
// puppetOptions: {
// token: 'xxx',
// }

企业微信所用到的参数corpId是什么,secret是填写购买的token吗。

然后我没有找到yarn add wechaty-puppet-wxwork,wechaty-puppet-service可以找到对应的依赖。

最后,微信成功把我账号变成机器人,但企业微信不行,还遇到如下问题:
wechaty\wechaty\node_modules@grpc\grpc-js\src\subchannel-address.ts:40
return 'port' in address;
^
TypeError: Cannot use 'in' operator to search for 'port' in undefined
at isTcpSubchannelAddress (D:\VS CODE\wechaty\wechaty\node_modules@grpc\grpc-js\src\subchannel-address.ts:40:16)
at interleaveAddressFamilies (D:\VS CODE\wechaty\wechaty\node_modules@grpc\grpc-js\src\load-balancer-pick-first.ts:145:27)
at PickFirstLoadBalancer.updateAddressList (D:\VS CODE\wechaty\wechaty\node_modules@grpc\grpc-js\src\load-balancer-pick-first.ts:533:25)
at ChildLoadBalancerHandler.updateAddressList (D:\VS CODE\wechaty\wechaty\node_modules@grpc\grpc-js\src\load-balancer-child-handler.ts:137:19)
at onSuccessfulResolution (D:\VS CODE\wechaty\wechaty\node_modules@grpc\grpc-js\src\resolving-load-balancer.ts:302:34)
at processTicksAndRejections (node:internal/process/task_queues:85:22)

Copy link

dosubot bot commented May 14, 2024

For integrating WeCom with the ding-dong-bot.ts using wechaty-puppet-wxwork, the corpId and secret are specific to WeCom's API authentication, distinct from the token used with wechaty-puppet-service. The corpId is your company's unique identifier in WeCom, and the secret is a key used for API access, both provided by WeCom when you set up an application on their platform.

To configure your bot for WeCom, ensure you're using wechaty-puppet-wxwork. Here's a simplified example to guide you:

import {
  WechatyBuilder,
} from 'wechaty';

const options = {
  name: 'ding-dong-bot',
  puppet: 'wechaty-puppet-wxwork', // Use WeCom puppet
  puppetOptions: {
    corpId: 'YOUR_CORP_ID', // Your WeCom corpId
    secret: 'YOUR_SECRET', // Your WeCom secret
  }
};

const bot = WechatyBuilder.build(options);

// Add your bot logic here

Replace 'YOUR_CORP_ID' and 'YOUR_SECRET' with your actual WeCom corpId and secret. This setup is crucial for authenticating and connecting your bot with WeCom. For more detailed instructions or if you need to obtain these credentials, refer to WeCom's documentation or their developer portal.

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.

@JohnLi94
Copy link
Author

For integrating WeCom with the ding-dong-bot.ts using wechaty-puppet-wxwork, the corpId and secret are specific to WeCom's API authentication, distinct from the token used with wechaty-puppet-service. The corpId is your company's unique identifier in WeCom, and the secret is a key used for API access, both provided by WeCom when you set up an application on their platform.

To configure your bot for WeCom, ensure you're using wechaty-puppet-wxwork. Here's a simplified example to guide you:

import {
  WechatyBuilder,
} from 'wechaty';

const options = {
  name: 'ding-dong-bot',
  puppet: 'wechaty-puppet-wxwork', // Use WeCom puppet
  puppetOptions: {
    corpId: 'YOUR_CORP_ID', // Your WeCom corpId
    secret: 'YOUR_SECRET', // Your WeCom secret
  }
};

const bot = WechatyBuilder.build(options);

// Add your bot logic here

Replace 'YOUR_CORP_ID' and 'YOUR_SECRET' with your actual WeCom corpId and secret. This setup is crucial for authenticating and connecting your bot with WeCom. For more detailed instructions or if you need to obtain these credentials, refer to WeCom's documentation or their developer portal.

Details

To continue the conversation, mention @dosu.

感谢您的指导,想问下这样的方案是可以把我自己的企业微信账号变成智能回复机器人吗?

Copy link

dosubot bot commented May 14, 2024

Yes, using wechaty-puppet-wxwork with your WeCom corpId and secret will enable you to transform your WeCom account into an intelligent reply bot. This setup allows your bot to listen for messages and respond, making your WeCom account capable of automated replies.

To achieve this, ensure your bot's configuration in the options object uses wechaty-puppet-wxwork and includes the necessary corpId and secret for WeCom authentication. This is crucial for connecting your bot with WeCom and enabling it to function as intended.

For implementing specific bot logic, such as listening and responding to messages, you can refer to the ding-dong-bot.ts example from Wechaty. While this example might not directly use wechaty-puppet-wxwork, the approach to setting up the bot and programming its behavior is similar. Just ensure you adjust the puppet and puppetOptions to suit WeCom's requirements.

This setup is key to making your WeCom account operate as an intelligent reply bot, leveraging WeChaty's framework and the wechaty-puppet-wxwork for WeCom integration.

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.

@JohnLi94
Copy link
Author

Yes, using wechaty-puppet-wxwork with your WeCom corpId and secret will enable you to transform your WeCom account into an intelligent reply bot. This setup allows your bot to listen for messages and respond, making your WeCom account capable of automated replies.

To achieve this, ensure your bot's configuration in the options object uses wechaty-puppet-wxwork and includes the necessary corpId and secret for WeCom authentication. This is crucial for connecting your bot with WeCom and enabling it to function as intended.

For implementing specific bot logic, such as listening and responding to messages, you can refer to the ding-dong-bot.ts example from Wechaty. While this example might not directly use wechaty-puppet-wxwork, the approach to setting up the bot and programming its behavior is similar. Just ensure you adjust the puppet and puppetOptions to suit WeCom's requirements.

This setup is key to making your WeCom account operate as an intelligent reply bot, leveraging WeChaty's framework and the wechaty-puppet-wxwork for WeCom integration.

Details

To continue the conversation, mention @dosu.

想再请教下,为何我一直找不到wechaty-puppet-wxwork,npm install wechaty-puppet-wxwork会提示如下
npm ERR! 404 Not Found - GET https://registry.npmjs.org/wechaty-puppet-wxwork - Not found

Copy link

dosubot bot commented May 14, 2024

The "404 Not Found" error you're encountering when trying to install wechaty-puppet-wxwork via npm suggests that the package might not be publicly available on npm. This is likely because @juzibot/wechaty-puppet-wxwork is listed as a private package, which means it may require special access permissions for installation.

To address this issue, consider the following steps:

  1. Check for Official Guidance: Look for any official documentation or announcements from Wechaty or Juzibot regarding how to access private packages like wechaty-puppet-wxwork.

  2. Alternative Installation Methods: Investigate if there's a way to install the package directly from a Git repository or another source as sometimes private packages are made available through these means.

  3. Reach Out to Maintainers: Contacting the maintainers of Wechaty or the specific puppet package directly can provide you with the most accurate and up-to-date information on how to proceed.

  4. Explore Alternatives: If accessing wechaty-puppet-wxwork remains challenging, you might need to look for alternative solutions or puppets for integrating WeCom with your bot. The Wechaty community could offer alternatives that meet your requirements.

Remember, the situation regarding package availability can change, so it's crucial to rely on the latest information from official sources or directly from the package maintainers.

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