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

How to tell which puppet is being used #89

Closed
suntong opened this issue Mar 25, 2020 · 6 comments
Closed

How to tell which puppet is being used #89

suntong opened this issue Mar 25, 2020 · 6 comments
Labels
enhancement New feature or request question Further information is requested

Comments

@suntong
Copy link

suntong commented Mar 25, 2020

Hi,

Of the different Puppet Providers, how can the wechaty script know which kind of puppet is being used?

The reason I'm asking is that, for all the Emoji cleaning functions in helper-functions/index.ts, they are actually puppet dependent. Knowing which puppet is being used can make the helper-functions generic.

Thanks

@huan
Copy link
Member

huan commented Mar 25, 2020

Thanks for asking this good question!

First, I agree with you that we need a way to get to know which puppet we are currently using with Wechaty.

This could be implemented by adding a new method to the puppet, let's say, named name(), so that it will return the puppet name:

const name = wechaty.puppet.name()
console.info(name)
// Output: wechaty-puppet-padplus

And when we are using the wechaty-puppet-hostie, it might be able to return the puppet provider behind it by returning wechaty-puppet-hostie(wechaty-puppet-padplus)?

Please feel free to let me know what you think about this design.

Secondly, I think all the puppet dependent API should not exist in Wechaty, which means the Wechaty should never care about what puppet it is using.

Can we get a way to remove all those emoji related methods from Wechaty to the puppet implementation? If we can do that, I believe that's the best way to solve your problem.

@huan huan added enhancement New feature or request question Further information is requested labels Mar 25, 2020
@suntong
Copy link
Author

suntong commented Mar 26, 2020

yeah, sure. good idea.

One little add-on/clarification, when remove all those emoji related methods from Wechaty to the individual puppets, please keep the abstract function at puppets level, so they will be behaving the same when puppet is switched.

@huan
Copy link
Member

huan commented Apr 1, 2020

Should be available after wechaty-puppet@0.23.4:

  1. puppet.name() should give the NPM name of the puppet provider we are currently using.
  2. puppet.version() is the NPM version of the puppet provider we are currently using.

@suntong
Copy link
Author

suntong commented Apr 2, 2020

Thanks a lot!

@suntong suntong closed this as completed Apr 2, 2020
@huan
Copy link
Member

huan commented Apr 2, 2020

You are welcome!

Todo: add an unit testing.

@huan
Copy link
Member

huan commented Apr 2, 2020

Unit Testing added.

@huan huan closed this as completed Apr 2, 2020
su-chang added a commit to su-chang/wechaty-puppet that referenced this issue Apr 23, 2020
* rename event `watchdog` to `heartbeat` (wechaty#88)

* 0.23.1

* clear log message

* 0.23.2

* reset for start

* 0.23.3

* add name() method for getting the provider npm name (wechaty#89)

* 0.23.4

* refactor PuppetTest to seprate module directory (wechaty#89)

* 0.23.5

* Upgrade state-switch to support Observable

* 0.23.6

* Upgrade StateSwitch to support RxJS fromEvent

* fix options

* 0.23.7

* --skipLibCheck

* 0.23.8

* public state for rxjs helper function visit

* 0.23.9

* 0.24.0 (wechaty#92)

* increase the cache size for RoomMemberPayload from 10K to 30K

* 0.23.10

* 0.25.1

Co-authored-by: Huan LI <zixia@zixia.net>
huan added a commit that referenced this issue Mar 5, 2021
* Merge master (#18)

* modify: create new latest version (#78)

* clean file-box

* 0.19.18

* 0.20.1

Co-authored-by: Huan (李卓桓) <zixia@zixia.net>

* Add receiverId to RoomInvitationPayload (#19)

* modify: create new latest version (#78)

* clean file-box

* 0.19.18

* 0.20.1

* Add receiver to Room Invitation Payload. (#79)

* Merge master (#18)

* modify: create new latest version (#78)

* clean file-box

* 0.19.18

* 0.20.1

Co-authored-by: Huan (李卓桓) <zixia@zixia.net>

* fix: add receiver to room-invitation payload.

* Update room-invitation.ts

Co-authored-by: Huan (李卓桓) <zixia@zixia.net>

Co-authored-by: Huan (李卓桓) <zixia@zixia.net>

* 0.21.11

* Merge master (#21)

* modify: create new latest version (#78)

* clean file-box

* 0.19.18

* 0.20.1

* Add receiver to Room Invitation Payload. (#79)

* Merge master (#18)

* modify: create new latest version (#78)

* clean file-box

* 0.19.18

* 0.20.1

Co-authored-by: Huan (李卓桓) <zixia@zixia.net>

* fix: add receiver to room-invitation payload.

* Update room-invitation.ts

Co-authored-by: Huan (李卓桓) <zixia@zixia.net>

* Bump wechaty-puppet version (#80)

* Merge master (#18)

* modify: create new latest version (#78)

* clean file-box

* 0.19.18

* 0.20.1

Co-authored-by: Huan (李卓桓) <zixia@zixia.net>

* Add receiverId to RoomInvitationPayload (#19)

* modify: create new latest version (#78)

* clean file-box

* 0.19.18

* 0.20.1

* Add receiver to Room Invitation Payload. (#79)

* Merge master (#18)

* modify: create new latest version (#78)

* clean file-box

* 0.19.18

* 0.20.1

Co-authored-by: Huan (李卓桓) <zixia@zixia.net>

* fix: add receiver to room-invitation payload.

* Update room-invitation.ts

Co-authored-by: Huan (李卓桓) <zixia@zixia.net>

Co-authored-by: Huan (李卓桓) <zixia@zixia.net>

* 0.20.2

Co-authored-by: Huan (李卓桓) <zixia@zixia.net>

* 0.21.0

* BREAKING CHANGE: selfId() might return `undefined` now

* 0.21.1

* 0.21.2

* add unknown to scene

* 0.21.3

* fix link

* rename chatie -> wechaty

* 0.21.4

* 0.21.5

* clean enum numbers

* `YOU` should only be used inside Puppet system, should not be passed to Wechaty

* code clean

* restore

* 0.21.6

* Event payload abstract (#86)

* Remove unused types in the abstract (#85)

* Use object for all events (on/listen) for better encapsulate (#81)

* use string for internal usage

* 0.21.7

* restore XXX_EVENT_DICT

* 0.21.8

* add payload for ready event

* 0.21.9

* Enable GitHub Actions

* 0.21.10

* code clean

* 0.21.11

* doc

Co-authored-by: Huan LI <zixia@zixia.net>

* 0.25.1

* rename event `watchdog` to `heartbeat` (#88)

* 0.23.1

* clear log message

* 0.23.2

* reset for start

* 0.23.3

* add name() method for getting the provider npm name (#89)

* 0.23.4

* refactor PuppetTest to seprate module directory (#89)

* 0.23.5

* Upgrade state-switch to support Observable

* 0.23.6

* Upgrade StateSwitch to support RxJS fromEvent

* fix options

* 0.23.7

* --skipLibCheck

* 0.23.8

* public state for rxjs helper function visit

* 0.23.9

* 0.24.0 (#92)

* increase the cache size for RoomMemberPayload from 10K to 30K

* 0.23.10

* 0.25.1

Co-authored-by: Huan LI <zixia@zixia.net>

* feat: modify friendshipAdd for support add room member be friends

* 0.34.2

* fix: conflict bug

Co-authored-by: Huan (李卓桓) <zixia@zixia.net>
su-chang added a commit to su-chang/wechaty-puppet that referenced this issue Mar 9, 2021
* Add room member (wechaty#129)

* Merge master (#18)

* modify: create new latest version (wechaty#78)

* clean file-box

* 0.19.18

* 0.20.1

Co-authored-by: Huan (李卓桓) <zixia@zixia.net>

* Add receiverId to RoomInvitationPayload (#19)

* modify: create new latest version (wechaty#78)

* clean file-box

* 0.19.18

* 0.20.1

* Add receiver to Room Invitation Payload. (wechaty#79)

* Merge master (#18)

* modify: create new latest version (wechaty#78)

* clean file-box

* 0.19.18

* 0.20.1

Co-authored-by: Huan (李卓桓) <zixia@zixia.net>

* fix: add receiver to room-invitation payload.

* Update room-invitation.ts

Co-authored-by: Huan (李卓桓) <zixia@zixia.net>

Co-authored-by: Huan (李卓桓) <zixia@zixia.net>

* 0.21.11

* Merge master (#21)

* modify: create new latest version (wechaty#78)

* clean file-box

* 0.19.18

* 0.20.1

* Add receiver to Room Invitation Payload. (wechaty#79)

* Merge master (#18)

* modify: create new latest version (wechaty#78)

* clean file-box

* 0.19.18

* 0.20.1

Co-authored-by: Huan (李卓桓) <zixia@zixia.net>

* fix: add receiver to room-invitation payload.

* Update room-invitation.ts

Co-authored-by: Huan (李卓桓) <zixia@zixia.net>

* Bump wechaty-puppet version (wechaty#80)

* Merge master (#18)

* modify: create new latest version (wechaty#78)

* clean file-box

* 0.19.18

* 0.20.1

Co-authored-by: Huan (李卓桓) <zixia@zixia.net>

* Add receiverId to RoomInvitationPayload (#19)

* modify: create new latest version (wechaty#78)

* clean file-box

* 0.19.18

* 0.20.1

* Add receiver to Room Invitation Payload. (wechaty#79)

* Merge master (#18)

* modify: create new latest version (wechaty#78)

* clean file-box

* 0.19.18

* 0.20.1

Co-authored-by: Huan (李卓桓) <zixia@zixia.net>

* fix: add receiver to room-invitation payload.

* Update room-invitation.ts

Co-authored-by: Huan (李卓桓) <zixia@zixia.net>

Co-authored-by: Huan (李卓桓) <zixia@zixia.net>

* 0.20.2

Co-authored-by: Huan (李卓桓) <zixia@zixia.net>

* 0.21.0

* BREAKING CHANGE: selfId() might return `undefined` now

* 0.21.1

* 0.21.2

* add unknown to scene

* 0.21.3

* fix link

* rename chatie -> wechaty

* 0.21.4

* 0.21.5

* clean enum numbers

* `YOU` should only be used inside Puppet system, should not be passed to Wechaty

* code clean

* restore

* 0.21.6

* Event payload abstract (wechaty#86)

* Remove unused types in the abstract (wechaty#85)

* Use object for all events (on/listen) for better encapsulate (wechaty#81)

* use string for internal usage

* 0.21.7

* restore XXX_EVENT_DICT

* 0.21.8

* add payload for ready event

* 0.21.9

* Enable GitHub Actions

* 0.21.10

* code clean

* 0.21.11

* doc

Co-authored-by: Huan LI <zixia@zixia.net>

* 0.25.1

* rename event `watchdog` to `heartbeat` (wechaty#88)

* 0.23.1

* clear log message

* 0.23.2

* reset for start

* 0.23.3

* add name() method for getting the provider npm name (wechaty#89)

* 0.23.4

* refactor PuppetTest to seprate module directory (wechaty#89)

* 0.23.5

* Upgrade state-switch to support Observable

* 0.23.6

* Upgrade StateSwitch to support RxJS fromEvent

* fix options

* 0.23.7

* --skipLibCheck

* 0.23.8

* public state for rxjs helper function visit

* 0.23.9

* 0.24.0 (wechaty#92)

* increase the cache size for RoomMemberPayload from 10K to 30K

* 0.23.10

* 0.25.1

Co-authored-by: Huan LI <zixia@zixia.net>

* feat: modify friendshipAdd for support add room member be friends

* 0.34.2

* fix: conflict bug

Co-authored-by: Huan (李卓桓) <zixia@zixia.net>

* clean name

* 0.34.3

Co-authored-by: Huan (李卓桓) <zixia@zixia.net>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
enhancement New feature or request question Further information is requested
Projects
None yet
Development

No branches or pull requests

2 participants