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

Send MiniProgram using PadPro #55

Merged
merged 4 commits into from Jul 19, 2019
Merged
Changes from all commits
Commits
File filter...
Filter file types
Jump to…
Jump to file or symbol
Failed to load files and symbols.

Always

Just for now

@@ -63,3 +63,5 @@ typings/
package-lock.json
.DS_Store
t.*

.idea
@@ -1,6 +1,6 @@
{
"name": "wechaty-puppet",
"version": "0.15.23",
"version": "0.15.25",
"description": "Abstract Puppet for Wechaty",
"main": "dist/src/index.js",
"typings": "dist/src/index.d.ts",
@@ -31,6 +31,9 @@ export {
export {
UrlLinkPayload,
} from './schemas/url-link'
export {
MiniProgramPayload,
} from './schemas/mini-program'

export {
throwUnsupportedError,
@@ -40,6 +40,9 @@ import {
import {
UrlLinkPayload,
} from './schemas/url-link'
import {
MiniProgramPayload,
} from './schemas/mini-program'

import {
Receiver,
@@ -103,12 +106,14 @@ class PuppetTest extends Puppet {
*/
public async messageFile (messageId: string) : Promise<FileBox> { return { messageId } as any }
public async messageUrl (messageId: string) : Promise<UrlLinkPayload> { return { messageId } as any }
public async messageMiniProgram (messageId: string) : Promise<MiniProgramPayload> { return { messageId } as any }

public async messageForward (to: Receiver, messageId: string) : Promise<void> { return { messageId, to } as any }
public async messageSendContact (receiver: Receiver, contactId: string) : Promise<void> { return { contactId, receiver } as any }
public async messageSendFile (to: Receiver, file: FileBox) : Promise<void> { return { file, to } as any }
public async messageSendText (to: Receiver, text: string) : Promise<void> { return { text, to } as any }
public async messageSendUrl (to: Receiver, urlLinkPayload: UrlLinkPayload) : Promise<void> { return { to, urlLinkPayload } as any }
public async messageSendMiniProgram (to: Receiver, miniProgramPayload: MiniProgramPayload) : Promise<void> { return { miniProgramPayload, to } as any }

public async messageRawPayload (id: string) : Promise<any> { return { id } as any }
public async messageRawPayloadParser (rawPayload: any) : Promise<MessagePayload> { return { rawPayload } as any }
@@ -71,6 +71,9 @@ import {
import {
UrlLinkPayload,
} from './schemas/url-link'
import {
MiniProgramPayload,
} from './schemas/mini-program'
import {
PuppetEventName,
PuppetOptions,
@@ -748,12 +751,14 @@ export abstract class Puppet extends EventEmitter {
*/
public abstract async messageFile (messageId: string) : Promise<FileBox>
public abstract async messageUrl (messageId: string) : Promise<UrlLinkPayload>
public abstract async messageMiniProgram (messageId: string) : Promise<MiniProgramPayload>

public abstract async messageForward (receiver: Receiver, messageId: string) : Promise<void>
public abstract async messageSendText (receiver: Receiver, text: string, mentionIdList?: string[]) : Promise<void>
public abstract async messageSendContact (receiver: Receiver, contactId: string) : Promise<void>
public abstract async messageSendFile (receiver: Receiver, file: FileBox) : Promise<void>
public abstract async messageSendUrl (receiver: Receiver, urlLinkPayload: UrlLinkPayload) : Promise<void>
public abstract async messageSendMiniProgram (receiver: Receiver, miniProgramPayload: MiniProgramPayload) : Promise<void>

protected abstract async messageRawPayload (messageId: string) : Promise<any>
protected abstract async messageRawPayloadParser (rawPayload: any) : Promise<MessagePayload>
@@ -0,0 +1,8 @@
export interface MiniProgramPayload {
appid? : string, // optional, appid, get from wechat (mp.weixin.qq.com)
description? : string, // optional, mini program title
pagepath? : string, // optional, mini program page path
thumbnailurl? : string, // optional, default picture, convert to thumbnail
title? : string, // optional, mini program title
username? : string, // original ID, get from wechat (mp.weixin.qq.com)
}
@@ -27,6 +27,7 @@ import {
RoomQueryFilter,

UrlLinkPayload,
MiniProgramPayload,

VERSION,
} from 'wechaty-puppet'
@@ -90,12 +91,14 @@ class PuppetTest extends Puppet {
*/
public async messageFile (messageId: string) : Promise<FileBox> { return { messageId } as any }
public async messageUrl (messageId: string) : Promise<UrlLinkPayload> { return { messageId } as any }
public async messageMiniProgram (messageId: string) : Promise<MiniProgramPayload> { return { messageId } as any }

public async messageForward (to: Receiver, messageId: string) : Promise<void> { return { to, messageId } as any }
public async messageSendContact (receiver: Receiver, contactId: string) : Promise<void> { return { receiver, contactId } as any }
public async messageSendFile (to: Receiver, file: FileBox) : Promise<void> { return { to, file } as any }
public async messageSendText (to: Receiver, text: string) : Promise<void> { return { to, text } as any }
public async messageSendUrl (to: Receiver, urlLinkPayload: UrlLinkPayload) : Promise<void> { return { to, urlLinkPayload } as any }
public async messageSendMiniProgram (to: Receiver, miniProgramPayload: MiniProgramPayload) : Promise<void> { return { miniProgramPayload, to } as any }

public async messageRawPayload (id: string) : Promise<any> { return { id } as any }
public async messageRawPayloadParser (rawPayload: any) : Promise<MessagePayload> { return { rawPayload } as any }
ProTip! Use n and p to navigate between commits in a pull request.
You can’t perform that action at this time.