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

使用自动拉人入群功能 #1697

Closed
icepy opened this issue Jan 23, 2019 · 4 comments
Closed

使用自动拉人入群功能 #1697

icepy opened this issue Jan 23, 2019 · 4 comments

Comments

@icepy
Copy link

icepy commented Jan 23, 2019

1. Expected behavior

Question: What behavior do you expect?

Answer: 给联系人发送一个入群邀请

2. Actual behavior

Question: What actual behavior did you experience?

Answer: 直接报错,日志如下

(node:9351) UnhandledPromiseRejectionWarning: Error: topicFilter not found
    at Function.<anonymous> (/Users/xiangwenwen/entropage/wechaty-getting-started/node_modules/wechaty/dist/src/user/room.js:125:23)
    at Generator.next (<anonymous>)
    at /Users/xiangwenwen/entropage/wechaty-getting-started/node_modules/wechaty/dist/src/user/room.js:7:71
    at new Promise (<anonymous>)
    at __awaiter (/Users/xiangwenwen/entropage/wechaty-getting-started/node_modules/wechaty/dist/src/user/room.js:3:12)
    at Function.findAll (/Users/xiangwenwen/entropage/wechaty-getting-started/node_modules/wechaty/dist/src/user/room.js:122:16)
    at Function.<anonymous> (/Users/xiangwenwen/entropage/wechaty-getting-started/node_modules/wechaty/dist/src/user/room.js:164:41)
    at Generator.next (<anonymous>)
    at /Users/xiangwenwen/entropage/wechaty-getting-started/node_modules/wechaty/dist/src/user/room.js:7:71
    at new Promise (<anonymous>)
    at __awaiter (/Users/xiangwenwen/entropage/wechaty-getting-started/node_modules/wechaty/dist/src/user/room.js:3:12)
    at Function.find (/Users/xiangwenwen/entropage/wechaty-getting-started/node_modules/wechaty/dist/src/user/room.js:159:16)
    at autoAddContact (/Users/xiangwenwen/entropage/wechaty-getting-started/examples/starter-bot.js:44:31)
    at EventEmitter.eventEmitter.once (/Users/xiangwenwen/entropage/wechaty-getting-started/examples/starter-bot.js:56:3)
    at Object.onceWrapper (events.js:273:13)
    at EventEmitter.emit (events.js:182:13)
    at EventEmitter.emit (domain.js:442:20)
    at Wechaty.onMessage (/Users/xiangwenwen/entropage/wechaty-getting-started/examples/starter-bot.js:38:20)
    at process._tickCallback (internal/process/next_tick.js:68:7)
(node:9351) UnhandledPromiseRejectionWarning: Unhandled promise rejection. This error originated either by throwing inside of an async function without a catch block, or by rejecting a promise which was not handled with .catch(). (rejection id: 2)
(node:9351) [DEP0018] DeprecationWarning: Unhandled promise rejections are deprecated. In the future, promise rejections that are not handled will terminate the Node.js process with a non-zero exit code.

代码如下:

在message callback 里查询到群的topic,然后使用:

async function onMessage (msg) {
  console.log(msg.toString())
  const room = msg.room();
  if (room) {
    const topic = await room.topic();
    if (topic === 'Flutter 学习小组') {
      eventEmitter.emit('find-entropage', topic);
    }
  }
}

async function autoAddContact(topic){
  const room = await bot.Room.find({name: topic});
  const contact = await bot.Contact.find({name: '山野'});
  if (room) {
    try {
      room.add(contact);
    } catch(e) {
      console.log(JSON.stringify(e));
    }
  }
}

eventEmitter.once('find-entropage', (topic) => {
  autoAddContact(topic);
});

3. Steps to reproduce your problem (and fixes, if any)

This part is very important: if you can not provide any reproduce steps, then the problem will be very hard to be recognized.

Question: What're the reproducible steps for us to see your problem?

Answer:

4. Full Output Logs

Show Logs
@icepy
Copy link
Author

icepy commented Jan 23, 2019

然后我在文档 https://docs.chatie.io/v/zh/ 里看见:

image

请问现在 wechaty 已经不能自动拉人入群了,对么?

@icepy
Copy link
Author

icepy commented Jan 23, 2019

按照官网的了解,如果要实现自动拉人入群,是要用 https://docs.chatie.io/v/zh/#multi-protocal 其他puppet 的吧?然后购买 https://github.com/lijiarui/wechaty-puppet-padchat/wiki/%E8%B4%AD%E4%B9%B0token token 来跑客户端么?

@lijiarui
Copy link
Member

@icepy you are right.

@icepy
Copy link
Author

icepy commented Jan 24, 2019

@lijiarui thx

@icepy icepy closed this as completed Jan 24, 2019
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

2 participants