Skip to main content

Processing files

Sending File#

import { FileBox } from 'wechaty'
const fileBox = FileBox.fromUrl('')await bot.say(fileBox)

Receiving File#

import { Message } from 'wechaty'
async function onMessage (message: Message) {  const fileTypeList = [    Message.Type.Attachment,    Message.Type.Audio,    Message.Type.Image,    Message.Type.Video,  ]  if (fileTypeList.includes(message.type())) {    const fileBox = await message.toFileBox()`Saving file {$}...`)    await fileBox.toFile()  }}
bot.on('message', onMessage)

About FileBox#

Learn more about how to use FileBox module by reading its document at