Skip to main content

Wechaty Plugin

Middleware is computer software that connects software components or applications. The software consists of a set of services that allows multiple processes running on one or more machines to interact.

See also: What is middleware exactly?

A Purpose from @Gcaufy

Yesterday, in our contributor group, @Gcaufy suggested that it would be great to add supporting of middleware to the Wechaty ecosystem, like the following usage:

有没有人把 踢人那个做成通用组件。。。那个很实用呀

room: 'RoomName',


I feel that it is a Brilliant idea!

So how about we design a middleware system like this:

Wechaty.use(middleware: WechatyMiddleware)

type WechatyMiddleware = (this: Wechaty) => void

class Wechaty {
public use (middleware: WechatyMiddleWare) {

const kickoutPlugin = (options = {}) => {
const roomTopic = options.roomTopic
return function (this: Wechaty) {
this.on('message'), message => {
if ( && === roomTopic) {
if (message.mentionSelf()) {
// check vote

const wechaty = new Wechaty()
wechaty.use(kickOffPlugin({ roomTopic: 'Test Room' }))

Any comments about this design will be welcome.

P.S. The Kickout Feature was originally introduced from the PR add vote manager to manage vote message in room #4 authored by @windmemory.