wechaty/plugin-contrib

New Plugin: Broadcast to Multiple Rooms

huan opened this issue · 1 comments

huan commented

Plugin Name

RoomBroadcast (?)

Plugin Options

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

interface Options {
  source: {
    room: IdOption,
    blackList: {
      messageType: MessageType | MessageType[],
      contact: IdOption,
    }
  },
  target: {
    room: string | string[] | RoomListFunction
  }
}

Description

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

huan commented

Implemented via e81eeca

Example

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

@Gcaufy