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

enhance the use plugin type

上级 afeedfa9
......@@ -4,6 +4,9 @@
"description": "Wechaty is a Bot SDK for Individual Account, Powered by TypeScript, Docker, and 💖",
"main": "dist/src/index.js",
"typings": "dist/src/index.d.ts",
"engines": {
"node": ">= 12"
},
"wechaty": {
"DEFAULT_PORT": 8080,
"DEFAULT_PROTOCOL": "io|0.0.1",
......@@ -79,9 +82,6 @@
"url": "https://opencollective.com/wechaty"
},
"homepage": "https://github.com/wechaty/",
"engines": {
"node": ">= 12"
},
"dependencies": {
"brolog": "^1.8.3",
"clone-class": "^0.7.3",
......
......@@ -240,9 +240,10 @@ export class Wechaty extends EventEmitter implements Sayable {
* bot.use(WechatyReportPlugin({ url: 'http://somewhere.to.report.your.data.com' })
*/
public static use (
...plugins: WechatyPlugin[]
...plugins: (WechatyPlugin | WechatyPlugin[])[]
) {
this.globalPluginList = this.globalPluginList.concat(plugins)
const pluginList = plugins.flat()
this.globalPluginList = this.globalPluginList.concat(pluginList)
}
/**
......@@ -589,8 +590,9 @@ export class Wechaty extends EventEmitter implements Sayable {
* // The same usage with Wechaty.use().
*
*/
public use (...plugins: WechatyPlugin[]) {
plugins.forEach(plugin => plugin(this))
public use (...plugins: (WechatyPlugin | WechatyPlugin[])[]) {
const pluginList = plugins.flat()
pluginList.forEach(plugin => plugin(this))
return this
}
......
Markdown is supported
0% .
You are about to add 0 people to the discussion. Proceed with caution.
先完成此消息的编辑!
想要评论请 注册