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

run example http://pad-local.com/#/learn failed. #252

Open
RustChater opened this issue Mar 24, 2022 · 15 comments
Open

run example http://pad-local.com/#/learn failed. #252

RustChater opened this issue Mar 24, 2022 · 15 comments
Labels

Comments

@RustChater
Copy link

When I run example http://pad-local.com/#/learn step-by-step, got error at last step "npm run demo"

Env:

wechaty-puppet-padlocal-demo: 0.1.2
wechaty: 0.60.12
wechaty-puppet-padlocal: 0.4.2
node: v17.8.0
npm: 8.5.5
OS: macOS BigSur 11.6 intel

Error:

➜  wechaty-puppet-padlocal-demo git:(master) ✗ sudo npm run demo

> [email protected] demo
> ./node_modules/.bin/ts-node main.ts


/Users/xxx/tmp/wechaty2/wechaty-puppet-padlocal-demo/node_modules/ts-node/src/index.ts:513
return new TSError(diagnosticText, diagnosticCodes)
^
TSError: ⨯ Unable to compile TypeScript:
main.ts:13:5 - error TS2322: Type 'PuppetPadlocal' is not assignable to type '"wechaty-puppet-hostie" | "wechaty-puppet-puppeteer" | "wechaty-puppet-service" | "wechaty-puppet-mock" | "wechaty-puppet-wechat" | "wechaty-puppet-wechat4u" | "wechaty-puppet-padlocal" | ... 6 more ... | Puppet'.
Type 'PuppetPadlocal' is missing the following properties from type 'Puppet': cacheContactPayload, cacheFriendshipPayload, cacheMessagePayload, cacheRoomPayload, and 17 more.

13     puppet,
~~~~~~

node_modules/wechaty/dist/src/wechaty.d.ts:13:5
13     puppet?: PuppetModuleName | Puppet;
~~~~~~
The expected type comes from property 'puppet' which is declared here on type 'WechatyOptions'

    at createTSError (/Users/xxx/tmp/wechaty2/wechaty-puppet-padlocal-demo/node_modules/ts-node/src/index.ts:513:12)
    at reportTSError (/Users/xxx/tmp/wechaty2/wechaty-puppet-padlocal-demo/node_modules/ts-node/src/index.ts:517:19)
    at getOutput (/Users/xxx/tmp/wechaty2/wechaty-puppet-padlocal-demo/node_modules/ts-node/src/index.ts:752:36)
    at Object.compile (/Users/xxx/tmp/wechaty2/wechaty-puppet-padlocal-demo/node_modules/ts-node/src/index.ts:968:32)
    at Module.m._compile (/Users/xxx/tmp/wechaty2/wechaty-puppet-padlocal-demo/node_modules/ts-node/src/index.ts:1056:42)
    at Module._extensions..js (node:internal/modules/cjs/loader:1153:10)
    at Object.require.extensions.<computed> [as .ts] (/Users/xxx/tmp/wechaty2/wechaty-puppet-padlocal-demo/node_modules/ts-node/src/index.ts:1059:12)
    at Module.load (node:internal/modules/cjs/loader:975:32)
    at Function.Module._load (node:internal/modules/cjs/loader:822:12)
    at Function.executeUserEntryPoint [as runMain] (node:internal/modules/run_main:77:12)
@huan
Copy link
Member

huan commented Mar 24, 2022

Currently, we are working on upgrading the Puppet Padlocal to the latest version v1.x, you can learn the progress from this PR:

After it has been upgraded, we recommended using the Wechaty community officially getting started repo at https://github.com/wechaty/getting-started and it should be able to work out-of-the-box, which is very convenient to the newcomers.

For now, as a workaround, I'm using a Wechaty Token Gateway with Puppet Padlocal so that we can use the new Wechaty v1.x with the old Puppet Padlocal, and it works great with our community bot Friday BOT.

You can learn how the Friday BOT creates its Wechaty Token Gateway from this script. And after running this script, you can use the new Wechaty Puppet Service Token (which is compatible with Wechaty v1.x) and use it with the latest Wechaty v1.x code.

Please read those codes and I hope you can make it work soon. If you run into any hard-to-solve issue, unfortunately, please feel free to create a reproducible repo and I can take a look at it for you.

Good luck!

@huan huan transferred this issue from wechaty/wechaty Mar 24, 2022
@huan huan added the question label Mar 24, 2022
@RustChater
Copy link
Author

RustChater commented Mar 24, 2022

I follow the getting started document to run:

git clone https://github.com/wechaty/getting-started.git
cd getting-started
npm install

export WECHATY_LOG=verbose\nexport 
export WECHATY_PUPPET=wechaty-puppet-wechat
export WECHATY_PUPPET=wechaty-puppet-padlocal
export WECHATY_PUPPET_PADLOCAL_TOKEN='puppet_padlocal_58658ea9872846xxxxxxxxxxxxxxxxxxxx'
npm install wechaty-puppet-padlocal
npm start

got error:

➜  getting-started git:(main) ✗ npm start

> [email protected] start
> cross-env NODE_OPTIONS="--no-warnings --loader=ts-node/esm" node examples/ding-dong-bot.ts

12:16:58 INFO Config registering process.on("unhandledRejection") for development/debug
12:16:58 VERB Config constructor()
12:16:58 VERB PoolifyMixin poolifyMixin(EventEmitter)
12:16:58 VERB WechatifyMixin wechatifyMixin(AbstractPoolifyMixin)
12:16:58 VERB ValidationMixin validationMixin(ContactMixin)
12:16:58 VERB ValidationMixin validationMixin(ContactImplBase)
12:16:58 VERB PoolifyMixin poolifyMixin(ContactImpl)
12:16:58 VERB ValidationMixin validationMixin(ContactSelfMixin)
12:16:58 VERB WechatifyMixin wechatifyMixin(EmptyBase)
12:16:58 VERB ValidationMixin validationMixin(FavoriteMixin)
12:16:58 VERB WechatifyMixin wechatifyMixin(EventEmitter)
12:16:58 VERB ValidationMixin validationMixin(FriendshipMixin)
12:16:58 VERB WechatifyMixin wechatifyMixin(EmptyBase)
12:16:58 VERB ValidationMixin validationMixin(ImageMixin)
12:16:58 VERB WechatifyMixin wechatifyMixin(EmptyBase)
12:16:58 VERB ValidationMixin validationMixin(LocationMixin)
12:16:58 VERB WechatifyMixin wechatifyMixin(EmptyBase)
12:16:58 VERB ValidationMixin validationMixin(PostMixin)
12:16:58 VERB WechatifyMixin wechatifyMixin(EventEmitter)
12:16:58 VERB ValidationMixin validationMixin(MessageMixin)
12:16:58 VERB ValidationMixin validationMixin(MessageImplBase)
12:16:58 VERB WechatifyMixin wechatifyMixin(EmptyBase)
12:16:58 VERB ValidationMixin validationMixin(MiniProgramMixin)
12:16:58 VERB WechatifyMixin wechatifyMixin(EmptyBase)
12:16:58 VERB ValidationMixin validationMixin(MomentMixin)
12:16:58 VERB WechatifyMixin wechatifyMixin(EmptyBase)
12:16:58 VERB ValidationMixin validationMixin(MoneyMixin)
12:16:58 VERB PoolifyMixin poolifyMixin(EventEmitter)
12:16:58 VERB WechatifyMixin wechatifyMixin(AbstractPoolifyMixin)
12:16:58 VERB ValidationMixin validationMixin(RoomMixin)
12:16:58 VERB WechatifyMixin wechatifyMixin(EmptyBase)
12:16:58 VERB ValidationMixin validationMixin(RoomInvitationMixin)
12:16:58 VERB WechatifyMixin wechatifyMixin(EmptyBase)
12:16:58 VERB PoolifyMixin poolifyMixin(AbstractWechatifyMixin)
12:16:58 VERB ValidationMixin validationMixin(TagMixin)
12:16:58 VERB WechatifyMixin wechatifyMixin(EmptyBase)
12:16:58 VERB ValidationMixin validationMixin(UrlLinkMixin)
12:16:58 VERB WechatifyMixin wechatifyMixin(EmptyBase)
12:16:58 VERB ValidationMixin validationMixin(DelayMixin)
12:16:58 VERB WechatyGErrorMixin gErrorMixin(WechatySkeleton)
12:16:58 VERB WechatifyUserModuleMixin wechatifyUserModuleMixin(GErrorMixin)
12:16:58 VERB WechatyIoMixin ioMixin(WechatifyUserModuleMixin)
12:16:58 VERB WechatyPuppetMixin puppetMixin(IoMixin)
12:16:58 VERB WechatyLoginMixin loginMixin(PuppetMixin)
12:16:58 VERB WechatyMiscMixin miscMixin(LoginMixin)
12:16:58 VERB WechatyPluginMixin pluginMixin(MiscMixin)
12:16:58 VERB ValidationMixin validationMixin(WechatyBase)
12:16:58 VERB ValidationMixin validationMixin(WechatyImplBase)
12:16:58 VERB wechaty-puppet-service monkeyPatchMetadataFromHttp2Headers()
12:16:58 VERB WechatyBuilder singleton()
12:16:58 VERB WechatyBuilder newInstance()
12:16:58 VERB WechatyLoginMixin constructor()
12:16:58 VERB WechatyPuppetMixin construct()
12:16:58 VERB WechatyIoMixin constructor()
12:16:58 VERB WechatifyUserModuleMixin constructor()
12:16:58 VERB WechatySkeleton constructor()
12:16:58 VERB StateSwitch constructor(WechatyReady, "{"log":{"enableTimestamp":true,"logLevel":4,"prefixFilter":{}}}")
12:16:58 VERB ServiceCtl<Wechaty> constructor()
12:16:58 VERB StateSwitch constructor(Wechaty, "{"log":{"enableTimestamp":true,"logLevel":4,"prefixFilter":{}}}")
12:16:58 VERB StateSwitch constructor(WechatyReset, "{"log":{"enableTimestamp":true,"logLevel":4,"prefixFilter":{}}}")
12:16:58 VERB Wechaty constructor()
12:16:58 VERB WechatySkeleton on(scan, listener) registering... listenerCount: 0
12:16:58 VERB WechatySkeleton on(login, listener) registering... listenerCount: 0
12:16:58 VERB WechatySkeleton on(logout, listener) registering... listenerCount: 0
12:16:58 VERB WechatySkeleton on(message, listener) registering... listenerCount: 0
12:16:58 VERB Wechaty start()
12:16:58 VERB WechatyLoginMixin init()
12:16:58 VERB WechatyPuppetMixin init()
12:16:58 VERB WechatifyUserModuleMixin init()
12:16:58 VERB WechatySkeleton init()
12:16:58 VERB WechatifyUserModuleMixin init() initializing Wechaty User Module (WUM) ...
12:16:58 VERB WechatifyMixin wechatifyUserModule(ContactImpl)
12:16:58 VERB WechatifyMixin wechatifyUserModule(ContactImpl)(Wechaty#0cdbbd15-a397-4183-8cfb-ccede3a45680<>(ding-dong-bot))
12:16:58 VERB WechatifyMixin wechatifyUserModule(ContactSelfImpl)
12:16:58 VERB WechatifyMixin wechatifyUserModule(ContactSelfImpl)(Wechaty#0cdbbd15-a397-4183-8cfb-ccede3a45680<>(ding-dong-bot))
12:16:58 VERB WechatifyMixin wechatifyUserModule(DelayImpl)
12:16:58 VERB WechatifyMixin wechatifyUserModule(DelayImpl)(Wechaty#0cdbbd15-a397-4183-8cfb-ccede3a45680<>(ding-dong-bot))
12:16:58 VERB WechatifyMixin wechatifyUserModule(FriendshipImpl)
12:16:58 VERB WechatifyMixin wechatifyUserModule(FriendshipImpl)(Wechaty#0cdbbd15-a397-4183-8cfb-ccede3a45680<>(ding-dong-bot))
12:16:58 VERB WechatifyMixin wechatifyUserModule(ImageImpl)
12:16:58 VERB WechatifyMixin wechatifyUserModule(ImageImpl)(Wechaty#0cdbbd15-a397-4183-8cfb-ccede3a45680<>(ding-dong-bot))
12:16:58 VERB WechatifyMixin wechatifyUserModule(LocationImpl)
12:16:58 VERB WechatifyMixin wechatifyUserModule(LocationImpl)(Wechaty#0cdbbd15-a397-4183-8cfb-ccede3a45680<>(ding-dong-bot))
12:16:58 VERB WechatifyMixin wechatifyUserModule(MessageImpl)
12:16:58 VERB WechatifyMixin wechatifyUserModule(MessageImpl)(Wechaty#0cdbbd15-a397-4183-8cfb-ccede3a45680<>(ding-dong-bot))
12:16:58 VERB WechatifyMixin wechatifyUserModule(MiniProgramImpl)
12:16:58 VERB WechatifyMixin wechatifyUserModule(MiniProgramImpl)(Wechaty#0cdbbd15-a397-4183-8cfb-ccede3a45680<>(ding-dong-bot))
12:16:58 VERB WechatifyMixin wechatifyUserModule(PostImpl)
12:16:58 VERB WechatifyMixin wechatifyUserModule(PostImpl)(Wechaty#0cdbbd15-a397-4183-8cfb-ccede3a45680<>(ding-dong-bot))
12:16:58 VERB WechatifyMixin wechatifyUserModule(RoomImpl)
12:16:58 VERB WechatifyMixin wechatifyUserModule(RoomImpl)(Wechaty#0cdbbd15-a397-4183-8cfb-ccede3a45680<>(ding-dong-bot))
12:16:58 VERB WechatifyMixin wechatifyUserModule(RoomInvitationImpl)
12:16:58 VERB WechatifyMixin wechatifyUserModule(RoomInvitationImpl)(Wechaty#0cdbbd15-a397-4183-8cfb-ccede3a45680<>(ding-dong-bot))
12:16:58 VERB WechatifyMixin wechatifyUserModule(TagImpl)
12:16:58 VERB WechatifyMixin wechatifyUserModule(TagImpl)(Wechaty#0cdbbd15-a397-4183-8cfb-ccede3a45680<>(ding-dong-bot))
12:16:58 VERB WechatifyMixin wechatifyUserModule(UrlLinkImpl)
12:16:58 VERB WechatifyMixin wechatifyUserModule(UrlLinkImpl)(Wechaty#0cdbbd15-a397-4183-8cfb-ccede3a45680<>(ding-dong-bot))
12:16:58 VERB WechatifyUserModuleMixin init() initializing Wechaty User Module (WUM) ... done
12:16:58 VERB WechatyPuppetMixin init() instanciating puppet instance ...
12:16:58 VERB Puppet resolvePuppet({puppet: wechaty-puppet-padlocal, puppetOptions: {}})
12:16:58 VERB Puppet resolvePuppet() resolving name "wechaty-puppet-padlocal" ...
12:16:58 VERB Puppet resolvePuppetName(wechaty-puppet-padlocal)
12:16:58 VERB Wechaty init() Raven disabled (import("raven") failed)
12:16:58 VERB Puppet resolvePuppetName(wechaty-puppet-padlocal): CJS resolved, retry times: 1
12:16:58 VERB Puppet resolvePuppet() resolving name "wechaty-puppet-padlocal" ... done
12:16:58 VERB Puppet resolvePuppet() instanciating puppet ...
12:16:58 VERB PuppetSkeleton constructor({})
12:16:58 VERB PuppetMemoryMixin constructor()
12:16:58 VERB PuppetLoginMixin constructor()
12:16:58 VERB PuppetCacheMixin constructor()
12:16:58 VERB PuppetCacheAgent constructor()
12:16:58 VERB PuppetContactMixin constructor()
12:16:58 VERB PuppetRoomMemberMixin constructor()
12:16:58 VERB PuppetRoomMixin constructor()
12:16:58 VERB PuppetFriendshipMixin constructor()
12:16:58 VERB PuppetTagMixin constructor()
12:16:58 VERB PuppetRoomInvitationMixin constructor()
12:16:58 VERB PuppetMessageMixin constructor()
12:16:58 VERB PuppetMiscMixin constructor()
12:16:58 VERB ServiceCtl<PuppetServiceMixin> constructor()
12:16:58 VERB StateSwitch constructor(PuppetServiceMixin, "{"log":{"enableTimestamp":true,"logLevel":4,"prefixFilter":{}}}")
12:16:58 VERB StateSwitch constructor(PuppetServiceMixinReset, "{"log":{"enableTimestamp":true,"logLevel":4,"prefixFilter":{}}}")
12:16:58 VERB PuppetServiceMixin constructor() #0
12:16:58 VERB PuppetWatchdogAgent constructor(a2abd807-9110-4007-ab14-08bcdbbe61cc)
12:16:58 VERB PuppetWatchdogAgent constructor() timeout 60 seconds
12:16:58 VERB ReadyMixin constructor()
12:16:58 VERB PuppetPostMixin constructor()
12:16:58 VERB PuppetSayableMixin constructor()
12:16:58 VERB TapMixin constructor()
12:16:58 VERB Puppet constructor({})
12:16:58 VERB Puppet resolvePuppet() instanciating puppet ... done
12:16:58 VERB WechatyPuppetMixin init() instanciating puppet instance ... done
12:16:58 VERB WechatyPuppetMixin init() setting memory ...
12:16:58 VERB PuppetMemoryMixin setMemory(ding-dong-bot)
12:16:58 VERB WechatyPuppetMixin init() setting memory ... done
12:16:58 VERB WechatyPuppetMixin init() setting up events ...
12:16:58 VERB WechatyPuppetMixin __setupPuppetEvents(Puppet<PuppetPadlocal>(ding-dong-bot))
12:16:58 VERB PuppetMixin __setupPuppetEvents() puppet.on(friendship) (listenerCount:0) registering...
12:16:58 VERB PuppetMixin __setupPuppetEvents() puppet.on(login) (listenerCount:0) registering...
12:16:58 VERB PuppetMixin __setupPuppetEvents() puppet.on(logout) (listenerCount:0) registering...
12:16:58 VERB PuppetMixin __setupPuppetEvents() puppet.on(message) (listenerCount:0) registering...
12:16:58 VERB PuppetMixin __setupPuppetEvents() puppet.on(post) (listenerCount:0) registering...
12:16:58 VERB PuppetMixin __setupPuppetEvents() puppet.on(room-invite) (listenerCount:0) registering...
12:16:58 VERB PuppetMixin __setupPuppetEvents() puppet.on(room-join) (listenerCount:0) registering...
12:16:58 VERB PuppetMixin __setupPuppetEvents() puppet.on(room-leave) (listenerCount:0) registering...
12:16:58 VERB PuppetMixin __setupPuppetEvents() puppet.on(room-topic) (listenerCount:0) registering...
12:16:58 VERB PuppetMixin __setupPuppetEvents() puppet.on(scan) (listenerCount:0) registering...
12:16:58 VERB PuppetMixin __setupPuppetEvents() puppet.on(dirty) (listenerCount:0) registering...
12:16:58 VERB PuppetMixin __setupPuppetEvents() puppet.on(dong) (listenerCount:0) registering...
12:16:58 VERB PuppetMixin __setupPuppetEvents() puppet.on(error) (listenerCount:0) registering...
12:16:58 VERB PuppetMixin __setupPuppetEvents() puppet.on(heartbeat) (listenerCount:0) registering...
12:16:58 VERB PuppetMixin __setupPuppetEvents() puppet.on(ready) (listenerCount:0) registering...
12:16:58 VERB PuppetMixin __setupPuppetEvents() puppet.on(reset) (listenerCount:0) registering...
12:16:58 VERB WechatyPuppetMixin __setupPuppetEvents() ... done
12:16:58 VERB WechatyPuppetMixin init() setting up events ... done
12:16:58 VERB WechatyPuppetMixin init() emitting "puppet" event ...
12:16:58 VERB WechatyPuppetMixin init() emitting "puppet" event ... done
12:16:58 VERB ServiceCtl<Wechaty> start()
12:16:58 VERB StateSwitch <Wechaty> active(pending) <- (false)
12:16:58 VERB ServiceCtl<Wechaty> start() super.start() ...
12:16:58 VERB WechatyPuppetMixin start()
12:16:58 VERB WechatyPuppetMixin start() super.start() ...
12:16:58 VERB WechatyIoMixin start()
12:16:58 VERB WechatySkeleton start()
12:16:58 VERB WechatyLoginMixin init()
12:16:58 VERB WechatyPuppetMixin init()
12:16:58 VERB WechatifyUserModuleMixin init()
12:16:58 VERB WechatySkeleton init()
12:16:58 VERB WechatifyUserModuleMixin init() Wechaty User Module (WUM)s have already wechatified: skip
12:16:58 VERB WechatyPuppetMixin init() skipped because this puppet has already been inited before.
12:16:58 VERB WechatyPuppetMixin start() super.start() ... done
12:16:58 VERB WechatyPuppetMixin start() starting puppet ...
12:16:58 ERR StarterBot TypeError: The "listener" argument must be of type function. Received undefined

@huan
Copy link
Member

huan commented Mar 24, 2022

You need to use the Friday BOT creates its Wechaty Token Gateway because the current PadLocal is not compatible with the latest Wechaty v1.x.

Solution

Wechaty Token Gateway

Try to start the Wechaty Token Gateway like this:

WECHATY_IMAGE=wechaty/wechaty:0.78
docker pull "$WECHATY_IMAGE"

docker run \
  -ti \
  --name friday_wechaty_puppet_service_token_gateway \
  --rm \
  --privileged \
  --network=host \
  -e WECHATY_LOG=verbose \
  -e WECHATY_PUPPET=wechaty-puppet-padlocal \
  -e WECHATY_PUPPET_PADLOCAL_TOKEN=puppet_padlocal_58658ea9872846xxxxxxxxxxxxxxxxxxxx \
  -e WECHATY_TOKEN=insecure_ebd42481-0c59-4563-a03b-c072ab782c2d \
  "$WECHATY_IMAGE"

Start Wechaty with the new Gated Token

After you have started the above script, you will get a valid Wechaty Puppet Service Token named insecure_ebd42481-0c59-4563-a03b-c072ab782c2d and you can use it with the getting-started repo like:

export WECHATY_PUPPET_SERVICE_TOKEN=insecure_ebd42481-0c59-4563-a03b-c072ab782c2d
export WECHATY_PUPPET=wechaty-puppet-service
export WECHATY_LOG=verbose
npm start

@RustChater
Copy link
Author

ok, it works! thanks!

@huan
Copy link
Member

huan commented Mar 24, 2022

Terrific, you are welcome!

@RustChater
Copy link
Author

Docker run successfully, then I scanned the QRCode URL, docker has been able to output some information of wechat.

but run npm start failed:

...
13:48:24 VERB GrpcManager startStream()
13:48:24 VERB GrpcManager startStream() grpc -> event() ...
13:48:24 VERB GrpcManager startStream() grpc -> event() ... done
13:48:24 VERB GrpcManager startStream() grpc -> event peeking data or timeout ...
13:48:26 VERB GrpcManager startStream() grpc -> event peeking data or timeout ... timeout
13:48:26 VERB GrpcManager startStream() grpc -> event peeking data or timeout ... data peeked
13:48:26 VERB GrpcManager startStream() initializing event stream ...
13:48:26 VERB GrpcManager startStream() initializing event stream ... done
13:48:26 VERB GrpcManager startStream() ... done
13:48:26 VERB GrpcManager start() starting stream ... done
13:48:26 VERB GrpcManager start() calling grpc server: start() ...
13:48:26 ERR StarterBot Error: 14 UNAVAILABLE: No connection established

docker console log:

...
05:48:18 WARN EventStreamManager grpcEmit(23, {"data":"ready"}) this.eventStream is undefined.
05:48:25 INFO Io on(jsonrpc): [object Object]
05:48:25 VERB Io on(jsonrpc) send({"id":-9007199254674491,"jsonrpc":"2.0","result":8788})

@huan
Copy link
Member

huan commented Mar 24, 2022

It seems that your gateway and the discover service works.

Could you check this issue:

And see if your issue is related to thel TLS?

It might because I use the wrong SNI insecure.

@RustChater
Copy link
Author

Follow your tips, closed TLS, it works!

export WECHATY_PUPPET_SERVICE_NO_TLS_INSECURE_CLIENT=true
npm start

successful log:

14:19:31 VERB Wechaty onStart()
14:19:31 VERB Wechaty <wechaty-puppet-service>(ding-dong-bot) onStart() v1.18.1 is starting...
14:19:31 VERB Wechaty id: xxxxx
14:19:31 VERB Wechaty onStart() ... done
14:19:31 VERB ServiceCtl<Wechaty> start() this.onStart() ... done
14:19:31 VERB StateSwitch <Wechaty> active(true) <- (pending)
14:19:31 VERB ServiceCtl<Wechaty> start() ... done
14:19:31 INFO StarterBot Starter Bot Started.

@huan
Copy link
Member

huan commented Mar 24, 2022

Congratulations!

That's because the TLS support has only been supported since v1.0 (and it has been enabled by default)

@Hamlet626
Copy link

You need to use the Friday BOT creates its Wechaty Token Gateway because the current PadLocal is not compatible with the latest Wechaty v1.x.

Solution

Wechaty Token Gateway

Try to start the Wechaty Token Gateway like this:

WECHATY_IMAGE=wechaty/wechaty:0.78
docker pull "$WECHATY_IMAGE"

docker run \
  -ti \
  --name friday_wechaty_puppet_service_token_gateway \
  --rm \
  --privileged \
  --network=host \
  -e WECHATY_LOG=verbose \
  -e WECHATY_PUPPET=wechaty-puppet-padlocal \
  -e WECHATY_PUPPET_PADLOCAL_TOKEN=puppet_padlocal_58658ea9872846xxxxxxxxxxxxxxxxxxxx \
  -e WECHATY_TOKEN=insecure_ebd42481-0c59-4563-a03b-c072ab782c2d \
  "$WECHATY_IMAGE"

Start Wechaty with the new Gated Token

After you have started the above script, you will get a valid Wechaty Puppet Service Token named insecure_ebd42481-0c59-4563-a03b-c072ab782c2d and you can use it with the getting-started repo like:

export WECHATY_PUPPET_SERVICE_TOKEN=insecure_ebd42481-0c59-4563-a03b-c072ab782c2d
export WECHATY_PUPPET=wechaty-puppet-service
export WECHATY_LOG=verbose
npm start

Excuse me, @huan could you provide more explanation on "-e WECHATY_TOKEN=insecure_ebd42481-0c59-4563-a03b-c072ab782c2d " in gateway script?Since if we already provide that token then how could we GET the granted token? and is that token just an example or unchanged? I ran that script and the bot just started running but didn't give me any token.Thanks very much in advance for the help.

@huan
Copy link
Member

huan commented Apr 27, 2022

@Hamlet626 what do you mean "if we already provide that token"?

It would be great if you can create a new issue and descript your question in detail.

@Hamlet626
Copy link

Hamlet626 commented Apr 27, 2022

@Hamlet626 what do you mean "if we already provide that token"?

It would be great if you can create a new issue and descript your question in detail.

@huan Oh so just because I saw in the script line 13 we already wrote that token there right? I just don't understand is such script helping us get the token, or otherwise how should we get that "insecure_edb..." token, so that we use that token to run our own program right?

Thanks for replying, not sure my understanding was right. And sure,I will start a new issue just after few more tries.

@huan
Copy link
Member

huan commented Apr 28, 2022

You are welcome.

There might be confusing to users that when we are saying "TOKEN", there are two types of them:

  1. Wechaty Puppet Provider (WPP) TOKEN
  2. Wechaty Puppet Service (WPS) TOKEN

The WPP TOKEN and the WPS TOKEN are totally different, and if you use one for another, it will not work.

Wechaty Puppet Provider (WPP)

  1. PadLocal (wechaty-puppet-padlocal) token is only for PadLocal
  2. SimplePad (wechaty-puppet-simplepad) token is only for SimplePad

And here's the most important one: Wechaty Puppet Service (WPS, wechaty-puppet-service) token

Wechaty Puppet Service (WPS)

The WPS TOKEN is the most compatible token for Polyglot (Python, Go, .NET, etc) Wechaty:

  1. You can use a Wechaty Gateway to convert the WPP (PadLocal / SimplePad / XP) token to a WPS token (refer to How to create a Wechaty Token Gateway for Puppet XP puppet-xp#38):
    npm install -g [email protected]
    wechaty gateway
  2. Or you can use native WPS like Paimon, WXWork, which means their TOKEN is a WPS TOKEN and gateway is not required.

I hope the above information can help you to have a better understanding of the WPS TOKEN v.s. the WPP TOKEN, please feel free to file an new issue if you have more questions.

@Hamlet626
Copy link

You are welcome.

There might be confusing to users that when we are saying "TOKEN", there are two types of them:

  1. Wechaty Puppet Provider (WPP) TOKEN
  2. Wechaty Puppet Service (WPS) TOKEN

The WPP TOKEN and the WPS TOKEN are totally different, and if you use one for another, it will not work.

Wechaty Puppet Provider (WPP)

  1. PadLocal (wechaty-puppet-padlocal) token is only for PadLocal
  2. SimplePad (wechaty-puppet-simplepad) token is only for SimplePad

And here's the most important one: Wechaty Puppet Service (WPS, wechaty-puppet-service) token

Wechaty Puppet Serviooce (WPS)

The WPS TOKEN is the most compatible token for Polyglot (Python, Go, .NET, etc) Wechaty:

  1. You can use a Wechaty Gateway to convert the WPP (PadLocal / SimplePad / XP) token to a WPS token (refer to How to create a Wechaty Token Gateway for Puppet XP puppet-xp#38):
    npm install -g [email protected]
    wechaty gateway
  2. Or you can use native WPS like Paimon, WXWork, which means their TOKEN is a WPS TOKEN and gateway is not required.

I hope the above information can help you to have a better understanding of the WPS TOKEN v.s. the WPP TOKEN, please feel free to file an new issue if you have more questions.

Yeah, it resolves my confusion indeed. Thanks a lot for the explanation and your patient. Just going to try it out soon!

@huan
Copy link
Member

huan commented Apr 28, 2022

Great to know that your confusion had been resolved!

Looking forward to seeing your future process, and have a nice day!

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Projects
None yet
Development

No branches or pull requests

3 participants