-
-
Notifications
You must be signed in to change notification settings - Fork 2.7k
Open
Labels
feature requeststaleIssue has not had recent activity or appears to be solved. Stale issues will be automatically closedIssue has not had recent activity or appears to be solved. Stale issues will be automatically closed
Description
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)
Metadata
Metadata
Assignees
Labels
feature requeststaleIssue has not had recent activity or appears to be solved. Stale issues will be automatically closedIssue has not had recent activity or appears to be solved. Stale issues will be automatically closed