Skip to content
LuChao edited this page Apr 6, 2022 · 14 revisions

From v0.x to v1.x

This Wiki page is for Wechaty developers who are familiar with the v0.x version and want to upgrade their code to v1.x.

We list all changes below (still under construction), and want to make it easy and clear to all developers for the migrating steps, and help everyone enjoy the newly v1.x with the least trouble.

Getting Started

We are suggesting to start using Wechaty v1.x with our official getting started repo first, and then refer to our community bot second.

The Friday BOT

The Friday BOT is the bot that is serving the Wechaty community for the past years.

It is based on the latest Wechaty v1.x version, running online, and works like a charm.

Here's its source code repo on GitHub at http://github.com/wechaty/friday, and you can visit its running dashboard at http://friday.chatie.io:5200/

1. Wechaty became an Interface

- import { Wechaty } from 'wechaty'
+ import { WechatyBuilder } From 'wechaty'

- const bot = new Wechaty()
+ const bot = WechatyBuilder.build()
// or
- const bot = Wechaty.instance()
+ const bot = WechatyBuilder.singleton()

2. UrlLink can not be used without a wechaty instance

@atorber: 最需要改进的不是代码,而是文档,接口文档还是0.x,比如发送UrlLink怎么构建,摸索了两个小时才搞定...

So and MiniProgram, Location, and all other Wechaty User Modules (WUM)s.

- const urlLink = UrlLink.create('https://github.com')
+ const urlLink = bot.UrlLink.create('https://github.com')
// or
- const urlLink = new UrlLink ({
-   description : 'WeChat Bot SDK for Individual Account, Powered by TypeScript, Docker, and Love',
-   thumbnailUrl: 'https://avatars0.githubusercontent.com/u/25162437?s=200&v=4',
-   title       : 'Welcome to Wechaty',
-   url         : 'https://github.com/wechaty/wechaty',
- })
+ const urlLink = new bot.UrlLink ({
+   description : 'WeChat Bot SDK for Individual Account, Powered by TypeScript, Docker, and Love',
+   thumbnailUrl: 'https://avatars0.githubusercontent.com/u/25162437?s=200&v=4',
+   title       : 'Welcome to Wechaty',
+   url         : 'https://github.com/wechaty/wechaty',
+ })

3. PadLocal requires Wechaty Gateway (for now)

PadLocal has to use a token gateway for v1.x because it's not finished upgrading yet.

Here's the ongoing PR to fix it:

Workaround

Using a Wechaty Token Gateway.

Here's how Friday makes it: https://github.com/wechaty/friday/blob/main/scripts/token-gateway.sh

Explanation: use [email protected] to convert Puppet PadLocal to a standard Puppet Service, then use [email protected] with this new service via gRPC and a new token.

4. WXWork & Paimon requires to disable TLS (for now)

WXWork and Paimon have to disable TLS when you are using Wechaty v1.x because it does not support TLS yet.

Here's the related issue for the details:

Workaround

WECHATY_PUPPET_SERVICE_NO_TLS_INSECURE_CLIENT=true npm start

To Be Added ...

Contributions are welcome!