* Get the room from the message. * If the message is not in a room, then will return `null` * * @returns {(Room | null)} * @example * const bot = new Wechaty() * bot * .on('message', async m => { * const contact = msg.from() * const text = msg.text() * const room
()
| 326 | * .start() |
| 327 | */ |
| 328 | public room (): null | Room { |
| 329 | if (!this.payload) { |
| 330 | throw new Error('no payload') |
| 331 | } |
| 332 | const roomId = this.payload.roomId |
| 333 | if (!roomId) { |
| 334 | return null |
| 335 | } |
| 336 | |
| 337 | const room = this.wechaty.Room.load(roomId) |
| 338 | return room |
| 339 | } |
| 340 | |
| 341 | /** |
| 342 | * Get the text content of the message |
no test coverage detected