wechaty / wechaty

Conversational RPA SDK for Chatbot Makers. Join our Discord: https://discord.gg/7q8NBZbQzt
https://wechaty.js.org
Apache License 2.0
20.04k stars 2.58k forks source link

Wechaty should support Channel Messages #2467

Open hcfw007 opened 1 year ago

hcfw007 commented 1 year ago

Intro

Channel is kinda like a special link url. In Wechat/Wecom eco, it specifies a video or a live show in a channel account. I'm not sure if other IM has similar messages.

Data Structure

In Wechat/Wecom eco, Channel is defined like this:

export interface ChannelPayload {
  avatar: string,
  coverUrl: string,
  desc: string,
  extras: string,
  feedType: number,
  nickname: string,
  thumbUrl: string,
  url: string,

  /**
   * The following two fields are required for Live Channel only.
   */
  objectId?: string,
  objectNonceId?: string,
}

The keys and data types are not very clear in semantic. So in wechaty puppet we should put it this way.

export interface ChannelPayload {
  avatar: string,
  coverUrl: string,
  description: string,
  channelType: ChannelType,
  nickname: string,
  thumbUrl: string,
  url: string,
  liveId?: string,
  liveNonceId?: string,
  extras: string
}

export enum ChannelType {
  Unknown = 0,
  Photo = 2,
  Video = 4,
  Live = 9,
}

Use in Wechaty

We use it just like miniProgram or urlLink. e.g.: receiving a channel message

const channel = await message.toChannel()
const nickname = channel.nickname()
const type = channel.channelType()

e.g.: sending a a channel message

const channel = new bot.Channel({
  avatar: 'http://some.website.com/some/avata.png',
  channelType: ChannelType.Video
  ...
})
await contact.say(channel)

e.g.: posting a channel moment

const builder = bot.Post.builder()
const channel = new bot.Channel({ ... })

builder.add('This is a channel moment')
builder.type(Post.Moment)
builder.add(channel)
const post = await builder.build()

const publishedPost = bot.publish(post)
hcfw007 commented 1 year ago

@huan ping

huan commented 1 year ago

It’s not very clear for me what the channel is exactly.

Could you please explain your code with some snapshots on the chat UI?

thank you very much.

hcfw007 commented 1 year ago

Sure. Channel is a special 'app like' message in wecom/wechat eco. In a wechat client, it look like this. This is a regular channel. image

This is a live channel. image

hcfw007 commented 1 year ago

@huan ping

nsnsqk commented 1 year ago

你们用中文吧 这是微信的视频号吧,这个类型用频道渠道 channel 来定义,有点不合适

hcfw007 commented 1 year ago

不合适有什么理由吗?

hcfw007 commented 1 year ago

@huan Maybe it's easier to understand with PRs: wechaty-puppet: https://github.com/wechaty/puppet/pull/212 wechaty-grpc: https://github.com/wechaty/grpc/pull/190 wechaty-puppet-service: https://github.com/wechaty/puppet-service/pull/228 wechaty: https://github.com/wechaty/wechaty/pull/2525

huan commented 1 year ago

After a quick review of those PRs for the Channel message, I roughly feel that the Channel message should be possible to be implemented with the Post data structure?

It would be great if we could reuse the Post with the Channel messages.

Do you think it's possible? If not, what are the blockers?

hcfw007 commented 1 year ago

If we pass the description, title, thumbnail and url as sayables and make it a Post, it seems to be OK.

However just like MiniProgram, there are fields that won't be dispalyed (or said as a sayable). Like appid and username (off MiniProgram), it won't be displayed and cannot be categorized into any sayable type.

huan commented 1 year ago

I'm still wondering if there's a way to generalize the Channel type so we can reuse some universal data types, like the Sayable.

For example, how will we categorize the following data types?

  1. TikTok video
  2. TikTok video live
  3. Twitter video
  4. Twitter Space (audio live)
  5. Instagram Post
  6. Instagram Reel
  7. Instagram Story
  8. Instagram Live
  9. YouTube Channel
  10. YouTube Live

Can we consider those data types when we add the new Channel type?

CC @windmemory @su-chang

huan commented 1 year ago

Guys, Any comments?

hcfw007 commented 1 year ago

It's hard to dig into it without knowing how these IMs implement such data structures. The key problem for Post is all the data in a Post are sayables, while wecom data is containings unsayable fields e.g. extra, feedType.

dosubot[bot] commented 10 months ago

Hi, @hcfw007! I'm Dosu, and I'm here to help the wechaty team manage their backlog. I wanted to let you know that we are marking this issue as stale.

From what I understand, you opened this issue requesting support for Channel Messages in Wechaty. You provided a proposed data structure and examples of how to use Channel Messages. In the comments, you explained what a channel is and even provided screenshots. There was also a discussion about how to implement the Channel type and whether it can be generalized to other data types like TikTok videos and Instagram posts.

However, it seems that this issue is still unresolved. Before we proceed, we would like to confirm if this issue is still relevant to the latest version of the wechaty repository. If it is, please let us know by commenting on this issue. Otherwise, feel free to close the issue yourself, or it will be automatically closed in 7 days.

Thank you for your understanding and contribution to the wechaty community! Let us know if you have any further questions or concerns.

dosubot[bot] commented 7 months ago

Hi, @hcfw007

I'm helping the Wechaty team manage their backlog and am marking this issue as stale. The issue you opened proposes adding support for Channel Messages in Wechaty, including defining the data structure for ChannelPayload and demonstrating how to receive, send, and post a channel message using Wechaty. There was a discussion about how to implement the Channel type and whether it can be generalized to other data types like TikTok videos and Instagram posts.

Could you please confirm if this issue is still relevant to the latest version of the Wechaty repository? If it is, please let the Wechaty team know by commenting on the issue. Otherwise, feel free to close the issue yourself, or it will be automatically closed in 7 days. Thank you!