wechaty / puppet-padlocal

Puppet PadLocal is a Pad Protocol for WeChat
https://wechaty.js.org/docs/puppet-providers/padlocal
Apache License 2.0
642 stars 88 forks source link

How to send a MiniProgram? #4

Closed hzzzzzz closed 3 years ago

hzzzzzz commented 3 years ago

Construct a MiniProgram with params like this:

// params are just for example 
const msg = new wechaty.MiniProgram({
  appid: 'foo_appid',
  username: 'foo_name@app',
  title: 'foo_title',
  description: 'blabla',
  pagePath: 'foo_path',
  iconUrl: 'foo_icon',
  thumbUrl: 'foo_url',
  thumbKey: 'foo_key',
});

Error occured when trying send the msg:

Error: originalMessageToUserName is required

Then I looked into the codes:

https://github.com/padlocal/wechaty-puppet-padlocal/blob/5608567a6c8b75839a90f50d61768b06e7391042/src/puppet-padlocal.ts#L797-L802

and in PadLocalClientApi#getEncryptedFile, there was a check for params:

  checkRequiredField(originalMessageToUserName, "originalMessageToUserName");

Obviously, the given value "" for originalMessageToUserName which could not pass the validation caused the error πŸ’‘.

I changed the value of originalMessageToUserName to the bot's wechat id manually(is that right? what is originalMessageToUserName?), and sent the msg again...

It worked πŸŽ‰! MiniProgram was sent and received successfully.

But another error printed:

Error: can not find message in cache for messageId: xxxxx

πŸ˜“

So, what is the way to send a MiniProgram correctly?

padlocal commented 3 years ago

Thanks for your reporting, this is a client side coding issue. Will be fixed soon.

padlocal commented 3 years ago

fixed: https://github.com/padlocal/wechaty-puppet-padlocal/commit/63105ca34a38e6562fb9805364ee88f3946049d1