提交 2ae6facd 编写于 作者: Huan (李卓桓)'s avatar Huan (李卓桓)

WIP: fix abstract class can not be instanciated...

上级 7ca7400f
......@@ -100,7 +100,7 @@ bot
/**
* 2. reply qrcode image
*/
const imageMessage = new bot.Message(BOT_QR_CODE_IMAGE_FILE)
const imageMessage = bot.Message.create(BOT_QR_CODE_IMAGE_FILE)
log.info('Bot', 'REPLY: %s', imageMessage)
await m.say(imageMessage)
......
......@@ -67,6 +67,13 @@ export abstract class Message extends PuppetAccessory implements Sayable {
]
}
public static create<T extends Message>(
this: { new (...args: any[]): T },
...args: any[],
): T {
return new this(...args)
}
/**
* @private
*/
......@@ -190,7 +197,7 @@ export abstract class Message extends PuppetAccessory implements Sayable {
* if (/^ding$/i.test(m.text())) {
* await m.say('hello world')
* console.log('Bot REPLY: hello world')
* await m.say(new Message(__dirname + '/wechaty.png'))
* await m.say(new bot.Message.create(__dirname + '/wechaty.png'))
* console.log('Bot REPLY: Image')
* }
* })
......
......@@ -22,7 +22,7 @@ import * as os from 'os'
import * as semver from 'semver'
import {
Constructor,
// Constructor,
cloneClass,
instanceToClass,
} from 'clone-class'
......@@ -113,13 +113,14 @@ export class Wechaty extends PuppetAccessory implements Sayable {
public readonly cuid: string
// tslint:disable-next-line:variable-name
public Contact : typeof Contact & Constructor<{}>
public Contact : typeof Contact // & Constructor<{}>
// tslint:disable-next-line:variable-name
public FriendRequest : typeof FriendRequest & Constructor<{}>
public FriendRequest : typeof FriendRequest // & Constructor<{}>
// tslint:disable-next-line:variable-name
public Message : typeof Message & Constructor<{}>
public Message : typeof Message // & Constructor<{}>
// tslint:disable-next-line:variable-name
public Room : typeof Room & Constructor<{}>
public Room : typeof Room // & Constructor<{}>
// public Room : typeof Room & Constructor<{}>
/**
* get the singleton instance of Wechaty
......@@ -259,7 +260,7 @@ export class Wechaty extends PuppetAccessory implements Sayable {
* @param {WechatyEventFunction} listener - Depends on the WechatyEvent
* @return {Wechaty} - this for chain
*
* More Example Gist: [Examples/Friend-Bot]{@link https://github.com/wechaty/wechaty/blob/master/examples/friend-bot.ts}
* More Example Gist: [Examples/Friend-Bot]{@link https://github.com/Chatie/wechaty/blob/master/examples/friend-bot.ts}
*
* @example <caption>Event:scan </caption>
* wechaty.on('scan', (url: string, code: number) => {
......
Markdown is supported
0% .
You are about to add 0 people to the discussion. Proceed with caution.
先完成此消息的编辑!
想要评论请 注册