wechaty / plugin-contrib

Wechaty Plugin Ecosystem Contrib Package
https://paka.dev/npm/wechaty-plugin-contrib
Apache License 2.0
33 stars 12 forks source link

New Plugin: Sync Between Multiple Rooms #3

Closed huan closed 4 years ago

huan commented 4 years ago

Plugin Name

SyncRoom (?)

Plugin Options

type IdListFunction = (wechaty: Wechaty) => string | string[]
type IdOption = string | string[] | IdListFunction

interface Options {
  room: IdOption
  blackList: {
    contact: IdOption,
    messageType: Message.Type | Message.Type[],
  },
  whiteList: {
    contact: IdOption,
    messageType: Message.Type | Message.Type[],
  }
}

Description

If there's any new message in the rooms, the bot will say this message in the other rooms.

huan commented 4 years ago

Implemented via https://github.com/wechaty/wechaty-plugin-contrib/commit/8b90048d89f68811608209f2fd14f0bf41644089

Example

6.2 ManyToOneRoomConnector()

wechaty.use(
  ManyToOneRoomConnector({
    blacklist: [ async () => true ],
    many: [
      '20049383519@chatroom',     // 小句子测试
      '5611663299@chatroom',      // 'ChatOps - Mike BO'
    ],
    map: async message => message.from()?.name() + '(many to one): ' + message.text(),
    one: '17237607145@chatroom',  // PreAngel 动态
    whitelist: [ async message => message.type() === Message.Type.Text ],
  }),

6.3 ManyToManyRoomConnector()

wechaty.use(
  ManyToManyRoomConnector({
    blacklist: [ async () => true ],
    many: [
      '20049383519@chatroom',     // 小句子测试
      '5611663299@chatroom',      // 'ChatOps - Mike BO'
    ],
    map: async message => message.from()?.name() + '(many to many): ' + message.text(),
    whitelist: [ async message => message.type() === Message.Type.Text ],
  })