wechaty / puppet-wechat

Wechaty Puppet Provider for WeChat
https://www.npmjs.com/package/wechaty-puppet-wechat
Apache License 2.0
413 stars 69 forks source link

feature for configurable autoLogin and switchAccount #34

Open huan opened 6 years ago

huan commented 6 years ago

Moved from https://github.com/Chatie/wechaty/issues/1172 author: @alamusi

Provide Your Network Information

  1. Where is the location of your server? (i.e. City, or In/Out China) North America

  2. Which cloud platform(AliYun/Qcloud/DigitalOcean/etc) are you using? AWS

Run npm run doctor or wechaty run doctor(for docker user), paste output here

wechaty@0.14.0 doctor /wechaty npm run check-node-version && ts-node bin/doctor

wechaty@0.14.0 check-node-version /wechaty check-node-version --node ">= 8.5"

Wechaty Doctor

  1. Wechaty version: #git[32b624e]
  2. Linux x64 version 4.4.0-1054-aws memory 963/7478 MB
  3. Docker: true
  4. Node version: v9.11.1
  5. Tcp IPC TEST: PASS

Expected behavior

Add configurable element to Wechaty.instance({}) to control the default init behaviour:

  1. autoAogin (fires the login event and ask user to confirm login on his/her phone)
  2. switchAccount (fires scan event and ask user to scan the QR code)

Actual behavior

puppet always calls clickSwitchAccount() per implementation on issue #636

Steps to reproduce the behavior (and fixes, if any)


@zixia correct!

Similar to some other web-wechat based projects, make the init behaviour configuration with a default value. if we set "autoLogin", then the puppet init will try to find the "log in" button to click; otherwise, the puppet init will try to find the "switch account" button to click (current behaviour)

The reason is that our client would like to have the ability to re-login to his/her previous wechaty instance without having to scan the QR, under the circumstances that the instance was kicked out by other web/mac/pc login.

thanks!


use 0.14 as an example, there are two approaches to pass the autoLogin option over.

once the autoLogin is passed over to puppet-web, the rest is the same

@zixia let me know which approach you would like to take. thanks

huan commented 6 years ago

After thinking about it more, I feel maybe we should make autologin to true by default.

Your two approaches is good, I'd like to modify it a little:

  1. environment variable name: WECHATY_PUPPET_PUPPETEER_AUTOLOGIN, because we need a very clear namespace for all puppet implementations.
  2. WechatyOptions.autoLogin is good, however, it would affect three modules: wechaty, wechaty-puppet, and wechaty-puppet-puppeteer.

I'd like to suggest we use the environment variable name first.

And also I'll not disagree if you'd like to change the default behavior to autoLogin=true

Please feel free to let me know if you have any questions, thanks!

alamusi commented 6 years ago

@zixia got it. let me take a look at this new repo and code base. it has been a while since last time i dug into it :) no worries about the late response. i know you guys have been busy in other adapters and those have higher priorities.