wechaty / wishlist

Puppets, Bots, and other Tooling Requested by Community Members
6 stars 0 forks source link

Wechaty Plugin for sending Authing mini-program to contacts #58

Open huan opened 2 years ago

huan commented 2 years ago

Feature to be plugined:

import { WechatyAuthing } from 'wechaty-authing'
const bot = new Wechaty()
const authing = new WechatyAuthing({
  authingId: 'xxx',
  authingKey: 'xxx',
  callbackUrl: 'https://xxx',
})
bot.use(authing.plugin())

bot.on('message', async message => {
  const talker = message.talker()
  const profile = authing.getProfile(talker)
  if (!profile) {
    await message.say('Hello new user!, please click the mini program to auth yourself before we can talk more secrets')
    miniProgram = botAuthing.getAuthMiniProgram(contact)
    message.say(miniProgram)
  } else {
    await message.say('Hello old friends!, I know you a lot: ' + JSON.stringify(profile))
  }
})

Reference material (API docs, etc):

@leinue @wechaty/bot5

huan commented 2 years ago

@Huan (李卓桓) 李老师 我问下哈,Wechaty Contact 中的 Id 是 微信官方标识的唯一 ID 吗?还是说咱们将这个 ID 进行了一次封装呀

Contact 中的 Id 是否微信官方标识的唯一 ID 这个取决于底层的 Puppet Provider 实现。See: https://wechaty.js.org/docs/puppet-providers/

比如:

Xuancaosu commented 2 years ago

@huan 李老师,我问下哈。Wechaty MiniProgram 这个类有没有一个使用上的文档。我现在在使用这个类的时候是没有办法走通流程的,我是用的方式是参考 https://wechaty.js.org/docs/api/message/#example-5

huan commented 2 years ago

@Xuancaosu The mini-program docs are very limited. The best way to learn it is by reading the source code.

Here are some related links:

Xuancaosu commented 2 years ago

@huan 李老师,我在使用,发送小程序链接的时。小程序链接可以正常发送出去,但是我在接收端,无法正常打开。请问是我使用的 Puppet 问题还是说我的调用方式问题。 Puppet:wechaty-puppet-padlocal Code:

  await message.say(
    new MiniProgram({
      appid: 'wxa0435021fd7xxxx',
      username: 'gh_a781a79xxxx',
      title: '小登录',
      description: '小登录',
      pagepath: 'routes/explore.html',
      iconUrl: 'http://files.authing.co/authing-console/authing-console-logo.png',
      thumbnailUrl:  thumbnailUrl
    })
  )
su-chang commented 2 years ago

建议使用以下方式,先获取对应小程序的参数(给bot发送一个你想要通过bot发送的小程序),校验无误后再进行发送。目前怀疑是参数不正确导致无法正常打开。

if (message.type() === MessageType.MiniProgram) {
  const payload = await message.toMiniProgram()
  console.log(JSON.stringify(payload))
}
huan commented 7 months ago

Update Nov 2023:

Thanks, @willin, for all your previous work! We have the current resources available for future development based on the following: