跳到主要内容

Polyglot: DIY

DIY Wechaty

Wechaty is mainly built on TypeScript, it is not very hard to translate the TypeScript(TS) to other programming languages wechaty has only 3,000 lines of the TS code, that are well designed and de-coupled by the wechaty-puppet abstraction. So after translation of those 3,000 lines of TypeScript code, Wechaty can be used in any programming language.

Wechaty already has an ecosystem in TypeScript, so you will not have to implement everything in other languages, especially since, in Feb 2020, Wechaty finished the wechaty-grpc service abstracting module with the wechaty-puppet-service implementation.

Architecture

The following diagram shows out that we can reuse almost everything in TypeScript, and what we need to do is only the block located at the top right of the diagram: Wechaty (Polyglot). Polyglot Architecture

  +--------------------------+ +--------------------------+
| | | |
| Wechaty (TypeScript) | | Wechaty(Polyglot) |
| | | Python, Go, Java, etc. |
+--------------------------+ +--------------------------+

+-------------------------------------------------------+
| Wechaty Puppet Servuce |
| |
| (wechaty-puppet-service) |
+-------------------------------------------------------+

+--------------------- wechaty_grpc ----------------------+

+-------------------------------------------------------+
| Wechaty Puppet Abstract |
| |
| (wechaty-puppet) |
+-------------------------------------------------------+

+--------------------------+ +--------------------------+
| Pad Protocol | | Web Protocol |
| | | |
| wechaty-puppet-padlocal | | (wechaty-puppet-wechat) |
+--------------------------+ +--------------------------+
+--------------------------+ +--------------------------+
| Windows Protocol | | WhatsApp Protocol |
| | | |
| (wechaty-puppet-xp) | | (wechaty-puppet-whatsapp)|
+--------------------------+ +--------------------------+

Chart made by AsciiFlow

Check-list

  • TS: TypeScript
  • SLOC: Source Lines Of Code

Wechaty Internal Modules

  1. Class Wechaty @wj-mCat TS SLOC(1160): https://github.com/wechaty/wechaty/blob/master/src/wechaty.ts
  2. Class Contact TS SLOC(804): https://github.com/wechaty/wechaty/blob/master/src/user/contact.ts
  3. Class ContactSelf TS SLOC(199): https://github.com/wechaty/wechaty/blob/master/src/user/contact-self.ts
  4. Class Message TS SLOC(1054): https://github.com/wechaty/wechaty/blob/master/src/user/message.ts
  5. Class Room TS SLOC(1194): https://github.com/wechaty/wechaty/blob/master/src/user/room.ts
  6. Class Image @wj-mCat TS SLOC(60): https://github.com/wechaty/wechaty/blob/master/src/user/image.ts
  7. Class Accessory @huan TS SLOC(179): https://github.com/wechaty/wechaty/blob/master/src/accessory.ts
  8. Class Config @wj-mCat TS SLOC(187): https://github.com/wechaty/wechaty/blob/master/src/config.ts
  9. Class Favorite TS SLOC(52): https://github.com/wechaty/wechaty/blob/master/src/user/favorite.ts
  10. Class Friendship TS SLOC(417): https://github.com/wechaty/wechaty/blob/master/src/user/friendship.ts
  11. Class MiniProgram TS SLOC(70): https://github.com/wechaty/wechaty/blob/master/src/user/mini-program.ts
  12. Class RoomInvitation TS SLOC(317): https://github.com/wechaty/wechaty/blob/master/src/user/room-invitation.ts
  13. Class Tag TS SLOC(190): https://github.com/wechaty/wechaty/blob/master/src/user/tag.ts
  14. Class UrlLink TS SLOC(107): https://github.com/wechaty/wechaty/blob/master/src/user/url-link.ts

Wechaty External Modules

  1. Class FileBox TS SLOC(638): https://github.com/huan/file-box/blob/master/src/file-box.ts
  2. Class MemoryCard TS SLOC(376): https://github.com/huan/memory-card/blob/master/src/memory-card.ts
  3. Class WechatyPuppet TS SLOC(1115): https://github.com/wechaty/wechaty-puppet/blob/master/src/puppet.ts
  4. Class WechatyPuppetHostie TS SLOC(909): https://github.com/wechaty/wechaty-puppet-hostie/blob/master/src/grpc/puppet-client.ts

History