Skip to content

Getting Started with Python Java Go

padlocal edited this page May 7, 2021 · 2 revisions

PadLocal only supports ts client at this moment. If you are using typescript or javascript, you can use PadLocal puppet directly with Wechaty as described here: Getting Started with TypeScript/Javascript.

For other languages(Python, Java and Go), you can use PadLocal via Gateway.

What is Wechaty gateway? It's a transport layer that use gRPC as intermediate service to translate data from ts/js to other languages. Hoping following graph can help to understand the topology of gateway.

Wechaty Puppet Service

Actions to take

1. Start gateway server

The gateway server is a "proxy" server for upstream PadLocal service. It provides two main functionalities:

  • Act as PadLocal client to communicate with PadLocal server. So you need to setup your PadLocal token here.
  • Act as wechaty-puppet-service server, to provide puppet behaviors to wechaty-puppet-service client that can be implemented with other languages.

Download all in one command: wechaty_token_gateway_padlocal.sh

$ ./wechaty_token_gateway_padlocal.sh puppet_padlocal_xxx

Then you can test whether the gateway server has been setup successfully with command:

$ curl https://api.chatie.io/v0/hosties/$WECHATY_PUPPET_PADLOCAL_TOKEN`

SUCCESS: {"ip":"191.xxx.xxx.xxx","port":8788}
FAIL: {"ip":"0.0.0.0","port":0}

2. Write your bot code

Then you can use puppet "wechaty-puppet-service" to implement your bot business logic. The peer gateway server you setup can be auto-discovered by WECHATY_PUPPET_SERVICE_TOKEN. Just make sure that the gateway server can be reached by your client.

export WECHATY_PUPPET=wechaty-puppet-service
export WECHATY_PUPPET_SERVICE_TOKEN=puppet_padlocal_xxx

make bot

Community Resources