How to use the file-box.FileBox.fromUrl function in file-box

To help you get started, we’ve selected a few file-box examples, based on popular ways it is used in public projects.

Secure your code as it's written. Use Snyk Code to scan source code in minutes - no build needed - and fix issues immediately.

github BUPT / ai-ml.club / src / pr-number-to-title.ts View on Github external
export async function prNumberToTitleByApi (
  org: string,
  repo: string,
  pr: number,
): Promise {
  const fileBox = FileBox.fromUrl(
    // https://stackoverflow.com/a/34601082/1123955
    `https://api.github.com/repos/${org}/${repo}/pulls/${pr}`,
    'pr.json',
    {
      'User-Agent': 'FileBox',
    }
  )
  const prJsonText = (await fileBox.toBuffer()).toString()
  // console.log(prJsonText)
  const prJson = JSON.parse(prJsonText)
  const prTitle = prJson.title as string
  return prTitle
}
github BUPT / ai-ml.club / src / pr-number-to-title.ts View on Github external
export async function prNumberToTitle (
  org: string,
  repo: string,
  pr: number,
): Promise {
  const fileBox = FileBox.fromUrl(
    `https://github.com/${org}/${repo}/pull/${pr}`,
    'pr.json',
  )
  const prHtml = (await fileBox.toBuffer()).toString()
  // console.log(prHtml)

  const matches = prHtml.match(/.+?<title>(.+?) by .+? · Pull Request #\d+.+?&lt;\/title&gt;/si)
  if (!matches) {
    throw new Error('no matches for pr title')
  }
  const prTitle = matches[1]
  return prTitle
}
</title>
github wechaty / wechaty / examples / ding-dong-bot.ts View on Github external
/* && !msg.self() */
  ) {
    console.info('Message discarded because it does not match ding/ping/bing/code')
    return
  }

  /**
   * 1. reply 'dong'
   */
  await msg.say('dong')
  console.info('REPLY: dong')

  /**
   * 2. reply image(qrcode image)
   */
  const fileBox = FileBox.fromUrl('https://chatie.io/wechaty/images/bot-qr-code.png')

  await msg.say(fileBox)
  console.info('REPLY: %s', fileBox.toString())

  /**
   * 3. reply 'scan now!'
   */
  await msg.say([
    'Join Wechaty Developers Community\n\n',
    'Scan now, because other Wechaty developers want to talk with you too!\n\n',
    '(secret code: wechaty)',
  ].join(''))
}

file-box

Pack a File into Box for easy move/transfer between servers no matter of where it is.(local path, remote url, or cloud storage)

Apache-2.0
Latest version published 2 years ago

Package Health Score

42 / 100
Full package analysis